diff --git a/packages/ui/certd-client/src/api/modules/api.basic.ts b/packages/ui/certd-client/src/api/modules/api.basic.ts index 4507857a..96df9cb9 100644 --- a/packages/ui/certd-client/src/api/modules/api.basic.ts +++ b/packages/ui/certd-client/src/api/modules/api.basic.ts @@ -22,3 +22,18 @@ export async function getInstallInfo(): Promise { method: "get" }); } + +export async function getSiteInfo(): Promise { + return await request({ + url: "/basic/settings/siteInfo", + method: "get" + }); +} + +export async function bindUrl(data): Promise { + return await request({ + url: "/sys/plus/bindUrl", + method: "post", + data + }); +} diff --git a/packages/ui/certd-client/src/components/vip-button/index.vue b/packages/ui/certd-client/src/components/vip-button/index.vue index 762b9fb4..28dfa923 100644 --- a/packages/ui/certd-client/src/components/vip-button/index.vue +++ b/packages/ui/certd-client/src/components/vip-button/index.vue @@ -18,6 +18,7 @@ import dayjs from "dayjs"; import { message, Modal } from "ant-design-vue"; import * as api from "./api"; import { useSettingStore } from "/@/store/modules/settings"; +import { useRouter } from "vue-router"; const props = withDefaults( defineProps<{ @@ -90,6 +91,7 @@ const formState = reactive({ code: "" }); +const router = useRouter(); async function doActive() { if (!formState.code) { message.error("请输入激活码"); @@ -100,7 +102,19 @@ async function doActive() { await userStore.reInit(); Modal.success({ title: "激活成功", - content: `您已成功激活专业版,有效期至:${dayjs(userStore.plusInfo.expireTime).format("YYYY-MM-DD")}` + content: `您已成功激活专业版,有效期至:${dayjs(userStore.plusInfo.expireTime).format("YYYY-MM-DD")}`, + onOk() { + if (!(settingStore.installInfo.bindUserId > 0)) { + //未绑定账号 + Modal.confirm({ + title: "是否绑定袖手账号", + content: "绑定账号后,可以避免专业版License丢失,强烈建议绑定", + onOk() { + router.push("/sys/account"); + } + }); + } + } }); } } @@ -132,7 +146,7 @@ function openUpgrade() {
  • 可加VIP群,需求优先实现
  • 证书流水线数量无限制(免费版限制10条)
  • 免配置发邮件功能
  • -
  • FTP上传、cdnfly、宝塔、易盾等部署插件
  • +
  • FTP上传、cdnfly、宝塔、易盾、群晖等部署插件
  • 更多特权敬请期待
  • @@ -144,7 +158,6 @@ function openUpgrade() { 站点ID: -
    注意保存好数据库,暂不支持换绑(默认数据库路径/data/certd/db.sqlite)
    diff --git a/packages/ui/certd-client/src/router/source/modules/sys.ts b/packages/ui/certd-client/src/router/source/modules/sys.ts index a2da21b9..9dfebff1 100644 --- a/packages/ui/certd-client/src/router/source/modules/sys.ts +++ b/packages/ui/certd-client/src/router/source/modules/sys.ts @@ -70,7 +70,7 @@ export const sysResources = [ title: "账号绑定", name: "account", meta: { - icon: "ion:settings-outline", + icon: "ion:golf-outline", permission: "sys:settings:view" }, path: "/sys/account", diff --git a/packages/ui/certd-client/src/store/modules/settings.ts b/packages/ui/certd-client/src/store/modules/settings.ts index 6e4240d7..4c43d564 100644 --- a/packages/ui/certd-client/src/store/modules/settings.ts +++ b/packages/ui/certd-client/src/store/modules/settings.ts @@ -1,11 +1,13 @@ import { defineStore } from "pinia"; -import { theme } from "ant-design-vue"; +import { Modal, theme } from "ant-design-vue"; import _ from "lodash-es"; // @ts-ignore import { LocalStorage } from "/src/utils/util.storage"; import * as basicApi from "/@/api/modules/api.basic"; import { SysInstallInfo, SysPublicSetting } from "/@/api/modules/api.basic"; +import { useUserStore } from "/@/store/modules/user"; +import { mitter } from "/@/utils/util.mitt"; export type ThemeToken = { token: { @@ -24,6 +26,16 @@ export interface SettingState { installInfo?: { siteId: string; installTime?: number; + bindUserId?: number; + bindUrl?: string; + accountServerBaseUrl?: string; + appKey?: string; + }; + siteInfo?: { + TITLE: string; + SLOGAN: string; + LOGO: string; + ICP_NO: string; }; } @@ -45,7 +57,17 @@ export const useSettingStore = defineStore({ managerOtherUserPipeline: false }, installInfo: { - siteId: "" + siteId: "", + bindUserId: null, + bindUrl: "", + accountServerBaseUrl: "", + appKey: "" + }, + siteInfo: { + TITLE: "", + SLOGAN: "", + LOGO: "", + ICP_NO: "" } }), getters: { @@ -64,9 +86,59 @@ export const useSettingStore = defineStore({ const settings = await basicApi.getSysPublicSettings(); _.merge(this.sysPublic, settings); + const siteInfo = await basicApi.getSiteInfo(); + _.merge(this.siteInfo, siteInfo); + + await this.loadInstallInfo(); + + await this.checkUrlBound(); + }, + async loadInstallInfo() { const installInfo = await basicApi.getInstallInfo(); _.merge(this.installInfo, installInfo); }, + async checkUrlBound() { + const userStore = useUserStore(); + if (!userStore.isAdmin || !userStore.isPlus) { + return; + } + + 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.loadInstallInfo(); + }; + const baseUrl = getBaseUrl(); + if (!bindUrl) { + //绑定url + await doBindUrl(baseUrl); + } else { + //检查当前url 是否与绑定的url一致 + const url = window.location.href; + if (!url.startsWith(bindUrl)) { + Modal.confirm({ + title: "URL地址有变化", + content: "以后都用这个新地址访问本系统吗?", + onOk: async () => { + await doBindUrl(baseUrl); + }, + okText: "是的,继续", + cancelText: "不是,回到原来的地址", + onCancel: () => { + window.location.href = bindUrl; + } + }); + } + } + }, persistThemeConfig() { LocalStorage.set(SETTING_THEME_KEY, this.getThemeConfig); }, @@ -109,3 +181,7 @@ export const useSettingStore = defineStore({ } } }); + +mitter.on("app.login", async () => { + await useSettingStore().init(); +}); 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 492a7fc6..9889ac2a 100644 --- a/packages/ui/certd-client/src/views/sys/account/index.vue +++ b/packages/ui/certd-client/src/views/sys/account/index.vue @@ -1,12 +1,19 @@