diff --git a/packages/libs/lib-iframe/src/lib/iframe.client.ts b/packages/libs/lib-iframe/src/lib/iframe.client.ts index 527f8dcd..f2d90a5f 100644 --- a/packages/libs/lib-iframe/src/lib/iframe.client.ts +++ b/packages/libs/lib-iframe/src/lib/iframe.client.ts @@ -65,7 +65,7 @@ export class IframeClient { return window.self !== window.top; } - register(action: string, handler: (data: IframeMessageData) => Promise) { + register(action: string, handler: (data: IframeMessageData) => Promise) { this.handlers[action] = handler; } diff --git a/packages/ui/certd-client/src/store/settings/index.ts b/packages/ui/certd-client/src/store/settings/index.ts index f5ef7a83..3222f557 100644 --- a/packages/ui/certd-client/src/store/settings/index.ts +++ b/packages/ui/certd-client/src/store/settings/index.ts @@ -10,6 +10,7 @@ import { updatePreferences } from "/@/vben/preferences"; import { useTitle } from "@vueuse/core"; import { utils } from "/@/utils"; import { cloneDeep } from "lodash-es"; + export interface SettingState { sysPublic?: SysPublicSetting; installInfo?: { @@ -184,6 +185,17 @@ export const useSettingStore = defineStore({ useTitle(this.siteInfo.title); } }, + getBaseUrl() { + let url = window.location.href; + //只要hash前面的部分 + url = url.split("#")[0]; + return url; + }, + async doBindUrl() { + const url = this.getBaseUrl(); + await basicApi.bindUrl({ url }); + await this.loadSysSettings(); + }, async checkUrlBound() { const userStore = useUserStore(); const settingStore = useSettingStore(); @@ -193,22 +205,9 @@ export const useSettingStore = defineStore({ const bindUrl = this.installInfo.bindUrl; - function getBaseUrl() { - let url = window.location.href; - //只要hash前面的部分 - url = url.split("#")[0]; - return url; - } - - const doBindUrl = async (url: string) => { - await basicApi.bindUrl({ url }); - await this.loadSysSettings(); - }; - - const baseUrl = getBaseUrl(); if (!bindUrl) { //绑定url - await doBindUrl(baseUrl); + await this.doBindUrl(); } else { //检查当前url 是否与绑定的url一致 const url = window.location.href; @@ -217,7 +216,7 @@ export const useSettingStore = defineStore({ title: "URL地址有变化", content: "以后都用这个新地址访问本系统吗?", onOk: async () => { - await doBindUrl(baseUrl); + await this.doBindUrl(); }, okText: "是的,继续", cancelText: "不是,回到原来的地址", diff --git a/packages/ui/certd-client/src/views/sys/account/index.vue b/packages/ui/certd-client/src/views/sys/account/index.vue index 400f0e44..635c3327 100644 --- a/packages/ui/certd-client/src/views/sys/account/index.vue +++ b/packages/ui/certd-client/src/views/sys/account/index.vue @@ -76,6 +76,7 @@ onMounted(() => { iframeClient.register("updateLicense", async req => { await api.UpdateLicense(req.data); await settingStore.init(); + await settingStore.doBindUrl(); notification.success({ message: "更新成功", description: "专业版/商业版已激活",