feat(配置管理): 添加服务器主机地址配置功能
- 在ConfigDTO中新增serverHost字段用于存储服务器主机地址 - 创建sysConfigStore管理服务器主机地址状态 - 在App.vue初始化时获取并设置服务器主机地址 - 修改所有硬编码的URL为使用配置的serverHost
This commit is contained in:
parent
e35e88d0d8
commit
f7677f136a
|
|
@ -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);
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ export type ConfigDTO = {
|
|||
isCaptchaOn: boolean;
|
||||
/** 系统字典配置(下拉选项之类的) */
|
||||
dictionary: Map<String, Array<DictionaryData>>;
|
||||
/**
|
||||
* 服务器主机地址
|
||||
*/
|
||||
serverHost: string;
|
||||
};
|
||||
|
||||
export type LoginByPasswordDTO = {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<IconifyIconOffline :icon="Iphone" />
|
||||
</el-icon>
|
||||
<div v-if="showQr" class="qr-popover">
|
||||
<ReQrcode text="http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth" :options="{ width: 200 }" />
|
||||
<ReQrcode :text="`${sysConfigStore.serverHost}/shop-api/api/shop/wechatAuth`" :options="{ width: 200 }" />
|
||||
<div class="qr-tip">微信扫码访问</div>
|
||||
<el-button class="copy-btn" type="primary" size="small" @click="copyLink">
|
||||
复制链接
|
||||
|
|
@ -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('复制失败,请手动复制');
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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" />
|
||||
<el-dialog v-model="qrVisible" title="微信扫码访问" width="300px">
|
||||
<div class="flex flex-col items-center">
|
||||
<ReQrcode :text="`http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth?shopId=${currentShopId}`"
|
||||
<ReQrcode :text="`${sysConfigStore.serverHost}/shop-api/api/shop/wechatAuth?shopId=${currentShopId}`"
|
||||
:options="{ width: 200 }" />
|
||||
<div class="mt-2 text-sm text-gray-500">微信扫码访问</div>
|
||||
<el-button class="mt-2" type="primary" size="small" @click="copyLink">
|
||||
|
|
|
|||
|
|
@ -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<UpdateShopCommand>({
|
||||
|
|
@ -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 = () => {
|
|||
</el-form-item>
|
||||
<el-form-item label="二维码">
|
||||
<div class="flex flex-col items-center">
|
||||
<ReQrcode :text="`http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth?shopId=${formData.shopId}`"
|
||||
<ReQrcode :text="`${sysConfigStore.serverHost}/shop-api/api/shop/wechatAuth?shopId=${formData.shopId}`"
|
||||
:options="{ width: 150 }" :width="150"/>
|
||||
<el-button type="primary" size="small" @click="copyLink" style="margin-left: 10px;">
|
||||
复制链接
|
||||
|
|
|
|||
Loading…
Reference in New Issue