|
@@ -6,6 +6,7 @@ import { isUrl } from '/@/utils/is';
|
|
|
import { RouteParams } from 'vue-router';
|
|
|
import { toRaw } from 'vue';
|
|
|
import { defHttp } from '/@/utils/http/axios';
|
|
|
+import { useUserStoreWithOut } from '/@/store/modules/user';
|
|
|
|
|
|
let currentRouter = '';
|
|
|
export function getAllParentPath<T = Recordable>(treeData: T[], path: string) {
|
|
@@ -98,57 +99,61 @@ export function configureDynamicParamsMenu(menu: Menu, params: RouteParams) {
|
|
|
menu.children?.forEach((item) => configureDynamicParamsMenu(item, params));
|
|
|
}
|
|
|
|
|
|
-export async function addBrowseLog(to, from) {
|
|
|
- let currentBrowseId = '';
|
|
|
- if (to.path !== '/sys/log/addBrowseLog') {
|
|
|
- const url = '/sys/log/addBrowseLog';
|
|
|
+export async function addBrowseLog(to, from, whitePathList) {
|
|
|
+ const userStore = useUserStoreWithOut();
|
|
|
+ const token = userStore.getToken;
|
|
|
+ if (token) {
|
|
|
+ let currentBrowseId = '';
|
|
|
+ if (to.path !== '/sys/log/addBrowseLog') {
|
|
|
+ const url = '/sys/log/addBrowseLog';
|
|
|
|
|
|
- // 生成时间戳函数
|
|
|
- const formatTimestamp = () => {
|
|
|
- const date = new Date();
|
|
|
- return [
|
|
|
- date.getFullYear(),
|
|
|
- String(date.getMonth() + 1).padStart(2, '0'),
|
|
|
- String(date.getDate()).padStart(2, '0'),
|
|
|
- String(date.getHours()).padStart(2, '0'),
|
|
|
- String(date.getMinutes()).padStart(2, '0'),
|
|
|
- String(date.getSeconds()).padStart(2, '0'),
|
|
|
- String(date.getMilliseconds()).padStart(3, '0'),
|
|
|
- ].join('');
|
|
|
- };
|
|
|
- // 2. 记录新页面进入日志
|
|
|
- currentBrowseId = formatTimestamp();
|
|
|
- if (!currentRouter) {
|
|
|
- currentRouter = to.fullPath;
|
|
|
- try {
|
|
|
- await defHttp.post({
|
|
|
- url,
|
|
|
- params: {
|
|
|
- browseId: currentBrowseId,
|
|
|
- isEnd: false,
|
|
|
- method: to.fullPath,
|
|
|
- },
|
|
|
- });
|
|
|
- console.log('进入页面日志记录成功');
|
|
|
- } catch (e) {
|
|
|
- console.error('进入页面日志记录失败:', e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (from.fullPath === currentRouter) {
|
|
|
+ // 生成时间戳函数
|
|
|
+ const formatTimestamp = () => {
|
|
|
+ const date = new Date();
|
|
|
+ return [
|
|
|
+ date.getFullYear(),
|
|
|
+ String(date.getMonth() + 1).padStart(2, '0'),
|
|
|
+ String(date.getDate()).padStart(2, '0'),
|
|
|
+ String(date.getHours()).padStart(2, '0'),
|
|
|
+ String(date.getMinutes()).padStart(2, '0'),
|
|
|
+ String(date.getSeconds()).padStart(2, '0'),
|
|
|
+ String(date.getMilliseconds()).padStart(3, '0'),
|
|
|
+ ].join('');
|
|
|
+ };
|
|
|
+ // 2. 记录新页面进入日志
|
|
|
+ currentBrowseId = formatTimestamp();
|
|
|
+ if (!currentRouter && !whitePathList.includes(to.path)) {
|
|
|
+ currentRouter = to.fullPath;
|
|
|
try {
|
|
|
- currentRouter = '';
|
|
|
await defHttp.post({
|
|
|
url,
|
|
|
params: {
|
|
|
browseId: currentBrowseId,
|
|
|
- isEnd: true,
|
|
|
- method: from.fullPath,
|
|
|
+ isEnd: false,
|
|
|
+ method: to.fullPath,
|
|
|
},
|
|
|
});
|
|
|
console.log('进入页面日志记录成功');
|
|
|
} catch (e) {
|
|
|
console.error('进入页面日志记录失败:', e);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ if (from.fullPath === currentRouter) {
|
|
|
+ try {
|
|
|
+ currentRouter = '';
|
|
|
+ await defHttp.post({
|
|
|
+ url,
|
|
|
+ params: {
|
|
|
+ browseId: currentBrowseId,
|
|
|
+ isEnd: true,
|
|
|
+ method: from.fullPath,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ console.log('进入页面日志记录成功');
|
|
|
+ } catch (e) {
|
|
|
+ console.error('进入页面日志记录失败:', e);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|