diff --git a/core/app/api/v2/auth.go b/core/app/api/v2/auth.go index ac79fca60..ef686ffd8 100644 --- a/core/app/api/v2/auth.go +++ b/core/app/api/v2/auth.go @@ -2,6 +2,8 @@ package v2 import ( "encoding/base64" + "os" + "path" "github.com/1Panel-dev/1Panel/core/app/api/v2/helper" "github.com/1Panel-dev/1Panel/core/app/dto" @@ -125,6 +127,20 @@ func (b *BaseApi) GetResponsePage(c *gin.Context) { helper.SuccessWithData(c, pageCode) } +func (b *BaseApi) GetWelcomePage(c *gin.Context) { + count, _, _ := logService.PageLoginLog(c, dto.SearchLgLogWithPage{PageInfo: dto.PageInfo{Page: 1, PageSize: 10}}) + if count != 1 { + helper.Success(c) + return + } + file, err := os.ReadFile(path.Join(global.CONF.Base.InstallDir, "1panel/welcome/index.html")) + if err != nil { + helper.InternalServer(c, err) + return + } + helper.SuccessWithData(c, string(file)) +} + // @Tags Auth // @Summary Get Setting For Login // @Success 200 {object} dto.SystemSetting diff --git a/core/router/ro_base.go b/core/router/ro_base.go index e24824a01..962390d07 100644 --- a/core/router/ro_base.go +++ b/core/router/ro_base.go @@ -16,5 +16,6 @@ func (s *BaseRouter) InitRouter(Router *gin.RouterGroup) { baseRouter.POST("/login", baseApi.Login) baseRouter.POST("/logout", baseApi.LogOut) baseRouter.GET("/setting", baseApi.GetLoginSetting) + baseRouter.GET("/welcome", baseApi.GetWelcomePage) } } diff --git a/frontend/src/api/modules/auth.ts b/frontend/src/api/modules/auth.ts index 2ca46f8ef..1b85ec0ee 100644 --- a/frontend/src/api/modules/auth.ts +++ b/frontend/src/api/modules/auth.ts @@ -20,3 +20,8 @@ export const logOutApi = () => { export const getLoginSetting = () => { return http.get('/core/auth/setting'); }; + +export const getWelcomePage = () => { + return http.get('/core/auth/welcome'); +}; + diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue index 64d55e8ea..1d6430de0 100644 --- a/frontend/src/views/home/index.vue +++ b/frontend/src/views/home/index.vue @@ -302,6 +302,10 @@ + + +
+
@@ -323,6 +327,7 @@ import { getSettingInfo, listAllSimpleNodes, loadUpgradeInfo } from '@/api/modul import { GlobalStore } from '@/store'; import { storeToRefs } from 'pinia'; import { routerToFileWithPath, routerToPath } from '@/utils/router'; +import { getWelcomePage } from '@/api/modules/auth'; const router = useRouter(); const globalStore = GlobalStore(); @@ -331,6 +336,9 @@ const appRef = ref(); const isSafety = ref(); +const welcomeOpen = ref(); +const shadowContainer = ref(); + const chartOption = ref('network'); let timer: NodeJS.Timer | null = null; let isInit = ref(true); @@ -692,6 +700,21 @@ const fetchData = () => { onLoadSimpleNode(); }; +const loadWelcome = async () => { + await getWelcomePage().then((res) => { + if (res.data) { + welcomeOpen.value = true; + nextTick(() => { + const shadowRoot = shadowContainer.value.attachShadow({ mode: 'open' }); + shadowRoot.innerHTML = res.data; + }); + localStorage.setItem('welcomeShow', 'false'); + } else { + localStorage.setItem('welcomeShow', 'false'); + } + }); +}; + onBeforeRouteUpdate((to, from, next) => { if (to.name === 'home') { clearTimer(); @@ -707,6 +730,9 @@ const clearTimer = () => { onMounted(() => { fetchData(); + if (localStorage.getItem('welcomeShow') !== 'false') { + loadWelcome(); + } }); onBeforeUnmount(() => {