优化网站导航模块

This commit is contained in:
2024-08-23 22:28:24 +08:00
parent 1d81fa9270
commit 13832d9de0
964 changed files with 90774 additions and 31362 deletions
+7 -5
View File
@@ -12,6 +12,7 @@ import CryptoJS from 'crypto-js';
// import { useTenantStore } from '@/store/modules/tenant';
// import { listMerchantAccount } from '@/api/shop/merchantAccount';
import { useRouter } from 'vue-router';
import { getSiteDomain } from "@/utils/domain";
type Events = {
message: ChatMessage;
@@ -77,12 +78,13 @@ export function openNew(url: string) {
* @constructor
*/
export function openPreview(url: string) {
if (url.slice(0, 4) == 'http') {
return window.open(url);
}
window.open(getDomainPath(url));
console.log(`${getSiteDomain()}${url}`);
return window.open(`${getSiteDomain()}${url}`);
// if (url.slice(0, 4) == 'http') {
// return window.open(url);
// }
// window.open(getDomainPath(url));
}
/**
* 获取网站域名
* @param path
+16
View File
@@ -1,4 +1,5 @@
import { isNumber } from 'ele-admin-pro';
import { listWebsite } from '@/api/cms/website';
// 解析域名结构
export function getHost(): any {
@@ -104,3 +105,18 @@ export function getProductCode(): string | null {
export function navSubDomain(path): string {
return `${window.location.protocol}//${path}.${getRootDomain()}`;
}
// 获取网站域名(推荐使用)
export function getSiteDomain(): string {
const siteDomain = localStorage.getItem('Domain');
if (!siteDomain) {
listWebsite({ limit: 1 }).then((list) => {
if (list.length > 0) {
const d = list[0];
localStorage.setItem('Domain', `${d.prefix}${d.domain}`);
return `${d.prefix}${d.domain}`;
}
});
}
return `${localStorage.getItem('Domain')}`;
}
-1
View File
@@ -41,7 +41,6 @@ service.interceptors.request.use(
// 解析二级域名获取租户ID
if (getTenantId()) {
config.headers.common['TenantId'] = getTenantId();
console.log('domain', getTenantId());
return config;
}
if (TENANT_ID) {