mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-23 07:50:57 +08:00
feat: Add xplay welcome page (#10733)
This commit is contained in:
parent
274fd526b7
commit
3b82d2a1ee
4 changed files with 48 additions and 0 deletions
|
|
@ -2,6 +2,8 @@ package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/core/app/api/v2/helper"
|
"github.com/1Panel-dev/1Panel/core/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/core/app/dto"
|
"github.com/1Panel-dev/1Panel/core/app/dto"
|
||||||
|
|
@ -125,6 +127,20 @@ func (b *BaseApi) GetResponsePage(c *gin.Context) {
|
||||||
helper.SuccessWithData(c, pageCode)
|
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
|
// @Tags Auth
|
||||||
// @Summary Get Setting For Login
|
// @Summary Get Setting For Login
|
||||||
// @Success 200 {object} dto.SystemSetting
|
// @Success 200 {object} dto.SystemSetting
|
||||||
|
|
|
||||||
|
|
@ -16,5 +16,6 @@ func (s *BaseRouter) InitRouter(Router *gin.RouterGroup) {
|
||||||
baseRouter.POST("/login", baseApi.Login)
|
baseRouter.POST("/login", baseApi.Login)
|
||||||
baseRouter.POST("/logout", baseApi.LogOut)
|
baseRouter.POST("/logout", baseApi.LogOut)
|
||||||
baseRouter.GET("/setting", baseApi.GetLoginSetting)
|
baseRouter.GET("/setting", baseApi.GetLoginSetting)
|
||||||
|
baseRouter.GET("/welcome", baseApi.GetWelcomePage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,3 +20,8 @@ export const logOutApi = () => {
|
||||||
export const getLoginSetting = () => {
|
export const getLoginSetting = () => {
|
||||||
return http.get<Login.LoginSetting>('/core/auth/setting');
|
return http.get<Login.LoginSetting>('/core/auth/setting');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getWelcomePage = () => {
|
||||||
|
return http.get<string>('/core/auth/welcome');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -302,6 +302,10 @@
|
||||||
|
|
||||||
<LicenseImport ref="licenseRef" />
|
<LicenseImport ref="licenseRef" />
|
||||||
<QuickJump @search="onLoadBaseInfo(false, 'all')" ref="quickJumpRef" />
|
<QuickJump @search="onLoadBaseInfo(false, 'all')" ref="quickJumpRef" />
|
||||||
|
|
||||||
|
<DialogPro v-model="welcomeOpen" size="w-70">
|
||||||
|
<div ref="shadowContainer" />
|
||||||
|
</DialogPro>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -323,6 +327,7 @@ import { getSettingInfo, listAllSimpleNodes, loadUpgradeInfo } from '@/api/modul
|
||||||
import { GlobalStore } from '@/store';
|
import { GlobalStore } from '@/store';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { routerToFileWithPath, routerToPath } from '@/utils/router';
|
import { routerToFileWithPath, routerToPath } from '@/utils/router';
|
||||||
|
import { getWelcomePage } from '@/api/modules/auth';
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const globalStore = GlobalStore();
|
const globalStore = GlobalStore();
|
||||||
|
|
||||||
|
|
@ -331,6 +336,9 @@ const appRef = ref();
|
||||||
|
|
||||||
const isSafety = ref();
|
const isSafety = ref();
|
||||||
|
|
||||||
|
const welcomeOpen = ref();
|
||||||
|
const shadowContainer = ref();
|
||||||
|
|
||||||
const chartOption = ref('network');
|
const chartOption = ref('network');
|
||||||
let timer: NodeJS.Timer | null = null;
|
let timer: NodeJS.Timer | null = null;
|
||||||
let isInit = ref<boolean>(true);
|
let isInit = ref<boolean>(true);
|
||||||
|
|
@ -692,6 +700,21 @@ const fetchData = () => {
|
||||||
onLoadSimpleNode();
|
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) => {
|
onBeforeRouteUpdate((to, from, next) => {
|
||||||
if (to.name === 'home') {
|
if (to.name === 'home') {
|
||||||
clearTimer();
|
clearTimer();
|
||||||
|
|
@ -707,6 +730,9 @@ const clearTimer = () => {
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchData();
|
fetchData();
|
||||||
|
if (localStorage.getItem('welcomeShow') !== 'false') {
|
||||||
|
loadWelcome();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue