From d0feaa23e573a2825b3863aec17c1f4e97764f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Tue, 26 Dec 2023 10:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8F=98=E5=8C=96:=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9baseUrl=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/settings.ts | 3 +-- web/src/utils/baseUrl.ts | 16 +++++++++++++--- web/src/views/system/login/index.vue | 5 +++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/web/src/settings.ts b/web/src/settings.ts index 62349a0..ae19d19 100644 --- a/web/src/settings.ts +++ b/web/src/settings.ts @@ -12,6 +12,7 @@ import { FsExtendsEditor,FsExtendsUploader } from '@fast-crud/fast-extends'; import '@fast-crud/fast-extends/dist/style.css'; import { successMessage, successNotification } from '/@/utils/message'; import XEUtils from "xe-utils"; +import {commonCrudConfig} from "/@/utils/commonCrud"; export default { async install(app: any, options: any) { // 先安装ui @@ -22,10 +23,8 @@ export default { // 此处配置公共的dictRequest(字典请求) async dictRequest({ dict }: any) { const {isTree} = dict - console.log(222222,isTree) //根据dict的url,异步返回一个字典数组 return await request({ url: dict.url, params: dict.params || {} }).then((res:any)=>{ - console.log(XEUtils.toArrayTree(res.data,{parentKey:'parent'})) if(isTree){ return XEUtils.toArrayTree(res.data,{parentKey:'parent'}) } diff --git a/web/src/utils/baseUrl.ts b/web/src/utils/baseUrl.ts index c22daa8..d2e1af6 100644 --- a/web/src/utils/baseUrl.ts +++ b/web/src/utils/baseUrl.ts @@ -3,9 +3,9 @@ import { pluginsAll } from '/@/views/plugins/index'; /** * @description 校验是否为租户模式。租户模式把域名替换成 域名 加端口 */ -export const getBaseURL = function () { - var baseURL = import.meta.env.VITE_API_URL as any; - var param = baseURL.split('/')[3] || ''; +export const getBaseURL = function (url:string) { + let baseURL = import.meta.env.VITE_API_URL as any; + let param = baseURL.split('/')[3] || ''; // @ts-ignore if (pluginsAll && pluginsAll.indexOf('dvadmin3-tenants-web') !== -1 && (!param || baseURL.startsWith('/'))) { // 1.把127.0.0.1 替换成和前端一样域名 @@ -26,6 +26,16 @@ export const getBaseURL = function () { baseURL = location.protocol + '//' + location.hostname + (location.port ? ':' : '') + location.port + baseURL; } } + if(url){ + const regex = /^(http|https):\/\//; + if(regex.test(url)){ + return url + }else{ + if(url.startsWith('/')){ + return baseURL + url; + } + } + } if (!baseURL.endsWith('/')) { baseURL += '/'; } diff --git a/web/src/views/system/login/index.vue b/web/src/views/system/login/index.vue index 585ad5b..e57f316 100644 --- a/web/src/views/system/login/index.vue +++ b/web/src/views/system/login/index.vue @@ -48,9 +48,9 @@ | 帮助 | - 隐私 + 隐私 | - 条款 + 条款

@@ -65,6 +65,7 @@ import logoMini from '/@/assets/logo-mini.svg'; import loginMain from '/@/assets/login-main.svg'; import loginBg from '/@/assets/login-bg.svg'; import {SystemConfigStore} from '/@/stores/systemConfig' +import {getBaseURL} from "/@/utils/baseUrl"; // 引入组件 const Account = defineAsyncComponent(() => import('/@/views/system/login/component/account.vue')); const Mobile = defineAsyncComponent(() => import('/@/views/system/login/component/mobile.vue'));