From f7677f136a59b6849d69e91dc1753bcbecdbb50e Mon Sep 17 00:00:00 2001 From: dzq Date: Fri, 19 Sep 2025 10:26:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9C=8D=E5=8A=A1=E5=99=A8=E4=B8=BB=E6=9C=BA?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在ConfigDTO中新增serverHost字段用于存储服务器主机地址 - 创建sysConfigStore管理服务器主机地址状态 - 在App.vue初始化时获取并设置服务器主机地址 - 修改所有硬编码的URL为使用配置的serverHost --- src/App.vue | 5 +++++ src/api/common/login.ts | 4 ++++ src/components/QrCodeHover/index.vue | 6 ++++-- src/store/modules/sysConfig.ts | 20 ++++++++++++++++++++ src/views/cabinet/shop/index.vue | 6 ++++-- src/views/cabinet/shop/shop-form-modal.vue | 6 ++++-- 6 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 src/store/modules/sysConfig.ts diff --git a/src/App.vue b/src/App.vue index ad39175..0c05b13 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,12 +4,17 @@ import { ElConfigProvider } from "element-plus"; import zhCn from "element-plus/lib/locale/lang/zh-cn"; import { ReDialog } from "@/components/ReDialog"; import { useBtnPermissionStore } from "@/store/modules/btnPermission"; +import { useSysConfigStoreHook } from "./store/modules/sysConfig"; +import { getConfig } from "./api/common/login"; const currentLocale = computed(() => zhCn); const btnPermissionStore = useBtnPermissionStore(); +const sysConfigStore = useSysConfigStoreHook(); onMounted(async () => { await btnPermissionStore.fetchPermissions(); + const config : any = await getConfig(); + sysConfigStore.setServerHost(config.serverHost ? config.serverHost : config.data.serverHost); }) diff --git a/src/api/common/login.ts b/src/api/common/login.ts index 6518ad2..f4bd0e2 100644 --- a/src/api/common/login.ts +++ b/src/api/common/login.ts @@ -12,6 +12,10 @@ export type ConfigDTO = { isCaptchaOn: boolean; /** 系统字典配置(下拉选项之类的) */ dictionary: Map>; + /** + * 服务器主机地址 + */ + serverHost: string; }; export type LoginByPasswordDTO = { diff --git a/src/components/QrCodeHover/index.vue b/src/components/QrCodeHover/index.vue index ca4026c..12ff9b6 100644 --- a/src/components/QrCodeHover/index.vue +++ b/src/components/QrCodeHover/index.vue @@ -5,7 +5,7 @@
- +
微信扫码访问
复制链接 @@ -21,11 +21,13 @@ import { ElMessage } from 'element-plus' import ReQrcode from '@/components/ReQrcode' import Iphone from "@iconify-icons/ep/iphone"; import { copyTextToClipboard } from "@pureadmin/utils"; +import { useSysConfigStoreHook } from "@/store/modules/sysConfig"; const showQr = ref(false) +const sysConfigStore = useSysConfigStoreHook(); const copyLink = () => { - const success = copyTextToClipboard('http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth'); + const success = copyTextToClipboard(`${sysConfigStore.serverHost}/shop-api/api/shop/wechatAuth`); success ? ElMessage.success('链接复制成功') : ElMessage.error('复制失败,请手动复制'); } diff --git a/src/store/modules/sysConfig.ts b/src/store/modules/sysConfig.ts new file mode 100644 index 0000000..62f51ea --- /dev/null +++ b/src/store/modules/sysConfig.ts @@ -0,0 +1,20 @@ +import { defineStore } from "pinia"; +import { ref } from "vue"; +import { store } from "@/store"; + +export const useSysConfigStore = defineStore("sys-config", () => { + const serverHost = ref(""); + + const setServerHost = (host: string) => { + serverHost.value = host; + } + + return { + serverHost, + setServerHost + }; +}); + +export function useSysConfigStoreHook() { + return useSysConfigStore(store); +} diff --git a/src/views/cabinet/shop/index.vue b/src/views/cabinet/shop/index.vue index a418774..9df0d68 100644 --- a/src/views/cabinet/shop/index.vue +++ b/src/views/cabinet/shop/index.vue @@ -14,12 +14,14 @@ import ShopFormModal from "./shop-form-modal.vue"; import ReQrcode from "@/components/ReQrcode"; import { copyTextToClipboard } from "@pureadmin/utils"; import { useWxStore } from "@/store/modules/wx"; +import { useSysConfigStoreHook } from "@/store/modules/sysConfig"; defineOptions({ name: "Shop" }); const wxStore = useWxStore(); +const sysConfigStore = useSysConfigStoreHook(); const formRef = ref(); const tableRef = ref(); const modalVisible = ref(false); @@ -129,7 +131,7 @@ const showQrCode = (shopId: number) => { }; const copyLink = () => { - const url = `http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth?shopId=${currentShopId.value}`; + const url = `${sysConfigStore.serverHost}/shop-api/api/shop/wechatAuth?shopId=${currentShopId.value}`; const success = copyTextToClipboard(url); success ? ElMessage.success('链接复制成功') : ElMessage.error('复制失败,请手动复制'); }; @@ -198,7 +200,7 @@ getList(); @refresh="handleRefresh" />
-
微信扫码访问
diff --git a/src/views/cabinet/shop/shop-form-modal.vue b/src/views/cabinet/shop/shop-form-modal.vue index 830b797..03a74d8 100644 --- a/src/views/cabinet/shop/shop-form-modal.vue +++ b/src/views/cabinet/shop/shop-form-modal.vue @@ -5,6 +5,7 @@ import { paymentMethodOptions, modeToPaymentMethodMap } from "@/utils/maps/payme import { addShop, updateShop, ShopDTO, UpdateShopCommand, AddShopCommand } from "@/api/shop/shop"; import { useWxStore } from "@/store/modules/wx"; import Upload from "@iconify-icons/ep/upload"; +import { useSysConfigStoreHook } from "@/store/modules/sysConfig"; import ReQrcode from "@/components/ReQrcode"; import { copyTextToClipboard } from "@pureadmin/utils"; const { VITE_APP_BASE_API } = import.meta.env; @@ -23,6 +24,7 @@ const props = defineProps({ const emit = defineEmits(["update:visible", "refresh"]); const wxStore = useWxStore(); +const sysConfigStore = useSysConfigStoreHook(); const formRef = ref(); const formData = ref({ @@ -128,7 +130,7 @@ const copyLink = () => { ElMessage.warning("店铺ID不存在,无法复制链接"); return; } - const url = `http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth?shopId=${formData.value.shopId}`; + const url = `${sysConfigStore.serverHost}/shop-api/api/shop/wechatAuth?shopId=${formData.value.shopId}`; const success = copyTextToClipboard(url); success ? ElMessage.success('链接复制成功') : ElMessage.error('复制失败,请手动复制'); }; @@ -197,7 +199,7 @@ const copyLink = () => {
- 复制链接