改造文章管理系统

This commit is contained in:
2024-08-27 07:22:22 +08:00
parent 13832d9de0
commit 31ec8e057a
41 changed files with 4041 additions and 525 deletions
+46 -8
View File
@@ -9,10 +9,9 @@ import mitt from 'mitt';
import { ChatMessage } from '@/api/system/chat/model';
import { useUserStore } from '@/store/modules/user';
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";
import { getSiteDomain, getTenantId } from '@/utils/domain';
import { uuid } from 'ele-admin-pro';
type Events = {
message: ChatMessage;
@@ -60,6 +59,47 @@ export function openUrl(url: string, params?: any): void {
}
}
/**
* 跳转页面函数
* 携带用于统计用户行为的参数
* @param path /product/detail.html
* @param id 128
* @param d 项目数据
* 拼接规则: {域名}{path}?spm=c.{用户ID}.{租户ID}.{栏目ID}.{商品ID}.{timestamp}&token={token}
* @return https:///websoft.top/product/detail/128.html?spm=c.5.3057.10005.undefined&token=DDkr1PpE9DouIVMjLEMt9733QsgG7oNV
*/
export function openSpmUrl(path: string, d?: any, id = 0): void {
const domain = getSiteDomain();
const spm = ref<string>('');
const token = ref<string>();
const url = ref<string>();
const tid = getTenantId() || 0;
const pid = d?.parentId || 0;
const cid = d?.categoryId || 0;
const uid = localStorage.getItem('UserId') || 0;
const timestamp = ref(Date.now() / 1000);
token.value = `&token=${uuid()}`;
// TODO 含http直接跳转
if (path.slice(0, 4) == 'http') {
window.open(`${path}`);
return;
}
// TODO 不传data
if (!d) {
window.open(`${domain}${path}`);
return;
}
// TODO 封装租户ID和店铺ID
spm.value = `?spm=c.${uid}.${tid}.${pid}.${cid}.${id}.${timestamp.value}`;
// 跳转页面
url.value = `${domain}${path}${spm.value}${token.value}`;
window.open(url.value);
}
/**
* 弹出新窗口
* @param url
@@ -78,12 +118,10 @@ export function openNew(url: string) {
* @constructor
*/
export function openPreview(url: string) {
console.log(`${getSiteDomain()}${url}`);
if (url.slice(0, 4) == 'http') {
return window.open(url);
}
return window.open(`${getSiteDomain()}${url}`);
// if (url.slice(0, 4) == 'http') {
// return window.open(url);
// }
// window.open(getDomainPath(url));
}
/**
* 获取网站域名