mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-22 21:22:33 +08:00
♻️ Refactoring code. 重构前端部分接口支持新的验证码接口
This commit is contained in:
parent
3d680f474a
commit
231361be88
@ -2,7 +2,7 @@ import request from '/@/utils/request';
|
|||||||
|
|
||||||
export function fetchList(query: object) {
|
export function fetchList(query: object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/admin/token/page',
|
url: '/admin/sys-token/page',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: query,
|
data: query,
|
||||||
});
|
});
|
||||||
@ -10,7 +10,7 @@ export function fetchList(query: object) {
|
|||||||
|
|
||||||
export function delObj(accessTokens: string[]) {
|
export function delObj(accessTokens: string[]) {
|
||||||
return request({
|
return request({
|
||||||
url: '/admin/token/delete',
|
url: '/admin/sys-token/delete',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
data: accessTokens,
|
data: accessTokens,
|
||||||
});
|
});
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
import { nextTick, defineAsyncComponent } from 'vue';
|
import {nextTick, defineAsyncComponent} from 'vue';
|
||||||
import type { App } from 'vue';
|
import type {App} from 'vue';
|
||||||
import * as svg from '@element-plus/icons-vue';
|
import * as svg from '@element-plus/icons-vue';
|
||||||
import router from '/@/router/index';
|
import router from '/@/router/index';
|
||||||
import pinia from '/@/stores/index';
|
import pinia from '/@/stores/index';
|
||||||
import { storeToRefs } from 'pinia';
|
import {storeToRefs} from 'pinia';
|
||||||
import { useThemeConfig } from '/@/stores/themeConfig';
|
import {useThemeConfig} from '/@/stores/themeConfig';
|
||||||
import { i18n } from '/@/i18n/index';
|
import {i18n} from '/@/i18n/index';
|
||||||
import { Local } from '/@/utils/storage';
|
import {Local} from '/@/utils/storage';
|
||||||
import { verifyUrl } from '/@/utils/toolsValidate';
|
import {verifyUrl} from '/@/utils/toolsValidate';
|
||||||
import request from '/@/utils/request';
|
import request from '/@/utils/request';
|
||||||
import { useMessage } from '/@/hooks/message';
|
import {useMessage} from '/@/hooks/message';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import * as CryptoJS from 'crypto-js';
|
import * as CryptoJS from 'crypto-js';
|
||||||
import {sm4} from 'sm-crypto'
|
import {sm4} from 'sm-crypto'
|
||||||
import { validateNull } from './validate';
|
import {validateNull} from './validate';
|
||||||
import { RouteItem, RouteItems, RouteToFrom } from '/@/types/global';
|
import {RouteItem, RouteItems, RouteToFrom} from '/@/types/global';
|
||||||
|
|
||||||
// 引入组件
|
// 引入组件
|
||||||
const SvgIcon = defineAsyncComponent(() => import('/@/components/SvgIcon/index.vue'));
|
const SvgIcon = defineAsyncComponent(() => import('/@/components/SvgIcon/index.vue'));
|
||||||
@ -25,11 +25,11 @@ const SvgIcon = defineAsyncComponent(() => import('/@/components/SvgIcon/index.v
|
|||||||
* @description 使用:https://element-plus.gitee.io/zh-CN/component/icon.html
|
* @description 使用:https://element-plus.gitee.io/zh-CN/component/icon.html
|
||||||
*/
|
*/
|
||||||
export function elSvg(app: App) {
|
export function elSvg(app: App) {
|
||||||
const icons = svg as any;
|
const icons = svg as any;
|
||||||
for (const i in icons) {
|
for (const i in icons) {
|
||||||
app.component(`ele-${icons[i].name}`, icons[i]);
|
app.component(`ele-${icons[i].name}`, icons[i]);
|
||||||
}
|
}
|
||||||
app.component('SvgIcon', SvgIcon);
|
app.component('SvgIcon', SvgIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,13 +37,13 @@ export function elSvg(app: App) {
|
|||||||
* @method const title = useTitle(); ==> title()
|
* @method const title = useTitle(); ==> title()
|
||||||
*/
|
*/
|
||||||
export function useTitle() {
|
export function useTitle() {
|
||||||
const stores = useThemeConfig(pinia);
|
const stores = useThemeConfig(pinia);
|
||||||
const { themeConfig } = storeToRefs(stores);
|
const {themeConfig} = storeToRefs(stores);
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
let globalTitle: string = themeConfig.value.globalTitle;
|
let globalTitle: string = themeConfig.value.globalTitle;
|
||||||
let webTitle = setMenuI18n(router.currentRoute.value);
|
let webTitle = setMenuI18n(router.currentRoute.value);
|
||||||
document.title = `${webTitle} - ${globalTitle}` || globalTitle;
|
document.title = `${webTitle} - ${globalTitle}` || globalTitle;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,12 +54,12 @@ export function useTitle() {
|
|||||||
* @returns {string} - 国际化后的名称
|
* @returns {string} - 国际化后的名称
|
||||||
*/
|
*/
|
||||||
export function setMenuI18n(item: any) {
|
export function setMenuI18n(item: any) {
|
||||||
let name = i18n.global.t(item.name);
|
let name = i18n.global.t(item.name);
|
||||||
if (name !== item.name) {
|
if (name !== item.name) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i18n.global.locale.value === 'en' ? item.meta.enName : item.meta.title;
|
return i18n.global.locale.value === 'en' ? item.meta.enName : item.meta.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,21 +69,21 @@ export function setMenuI18n(item: any) {
|
|||||||
* @description data-xxx 属性用于存储页面或应用程序的私有自定义数据
|
* @description data-xxx 属性用于存储页面或应用程序的私有自定义数据
|
||||||
*/
|
*/
|
||||||
export const lazyImg = (el: string, arr: EmptyArrayType) => {
|
export const lazyImg = (el: string, arr: EmptyArrayType) => {
|
||||||
const io = new IntersectionObserver((res) => {
|
const io = new IntersectionObserver((res) => {
|
||||||
res.forEach((v: any) => {
|
res.forEach((v: any) => {
|
||||||
if (v.isIntersecting) {
|
if (v.isIntersecting) {
|
||||||
const { img, key } = v.target.dataset;
|
const {img, key} = v.target.dataset;
|
||||||
v.target.src = img;
|
v.target.src = img;
|
||||||
v.target.onload = () => {
|
v.target.onload = () => {
|
||||||
io.unobserve(v.target);
|
io.unobserve(v.target);
|
||||||
arr[key]['loading'] = false;
|
arr[key]['loading'] = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
document.querySelectorAll(el).forEach((img) => io.observe(img));
|
document.querySelectorAll(el).forEach((img) => io.observe(img));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,9 +91,9 @@ export const lazyImg = (el: string, arr: EmptyArrayType) => {
|
|||||||
* @returns 返回 `window.localStorage` 中读取的缓存值 `globalComponentSize`
|
* @returns 返回 `window.localStorage` 中读取的缓存值 `globalComponentSize`
|
||||||
*/
|
*/
|
||||||
export const globalComponentSize = (): string => {
|
export const globalComponentSize = (): string => {
|
||||||
const stores = useThemeConfig(pinia);
|
const stores = useThemeConfig(pinia);
|
||||||
const { themeConfig } = storeToRefs(stores);
|
const {themeConfig} = storeToRefs(stores);
|
||||||
return Local.get('themeConfig')?.globalComponentSize || themeConfig.value?.globalComponentSize;
|
return Local.get('themeConfig')?.globalComponentSize || themeConfig.value?.globalComponentSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,35 +102,35 @@ export const globalComponentSize = (): string => {
|
|||||||
* @returns 克隆后的对象
|
* @returns 克隆后的对象
|
||||||
*/
|
*/
|
||||||
export function deepClone(obj: EmptyObjectType) {
|
export function deepClone(obj: EmptyObjectType) {
|
||||||
let newObj: EmptyObjectType;
|
let newObj: EmptyObjectType;
|
||||||
try {
|
try {
|
||||||
newObj = obj.push ? [] : {};
|
newObj = obj.push ? [] : {};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
newObj = {};
|
newObj = {};
|
||||||
}
|
}
|
||||||
for (let attr in obj) {
|
for (let attr in obj) {
|
||||||
if (obj[attr] && typeof obj[attr] === 'object') {
|
if (obj[attr] && typeof obj[attr] === 'object') {
|
||||||
newObj[attr] = deepClone(obj[attr]);
|
newObj[attr] = deepClone(obj[attr]);
|
||||||
} else {
|
} else {
|
||||||
newObj[attr] = obj[attr];
|
newObj[attr] = obj[attr];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newObj;
|
return newObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否是移动端
|
* 判断是否是移动端
|
||||||
*/
|
*/
|
||||||
export function isMobile() {
|
export function isMobile() {
|
||||||
if (
|
if (
|
||||||
navigator.userAgent.match(
|
navigator.userAgent.match(
|
||||||
/('phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone')/i
|
/('phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone')/i
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,18 +140,18 @@ export function isMobile() {
|
|||||||
* @returns 删除空值后的数组对象
|
* @returns 删除空值后的数组对象
|
||||||
*/
|
*/
|
||||||
export function handleEmpty(list: EmptyArrayType) {
|
export function handleEmpty(list: EmptyArrayType) {
|
||||||
const arr = [] as any[];
|
const arr = [] as any[];
|
||||||
for (const i in list) {
|
for (const i in list) {
|
||||||
const d = [] as any[];
|
const d = [] as any[];
|
||||||
for (const j in list[i]) {
|
for (const j in list[i]) {
|
||||||
d.push(list[i][j]);
|
d.push(list[i][j]);
|
||||||
}
|
}
|
||||||
const leng = d.filter((item) => item === '').length;
|
const leng = d.filter((item) => item === '').length;
|
||||||
if (leng !== d.length) {
|
if (leng !== d.length) {
|
||||||
arr.push(list[i]);
|
arr.push(list[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -159,41 +159,41 @@ export function handleEmpty(list: EmptyArrayType) {
|
|||||||
* @param val 当前点击项菜单
|
* @param val 当前点击项菜单
|
||||||
*/
|
*/
|
||||||
export function handleOpenLink(val: RouteItem) {
|
export function handleOpenLink(val: RouteItem) {
|
||||||
router.push(val.path);
|
router.push(val.path);
|
||||||
if (verifyUrl(<string>val.meta?.isLink)) window.open(val.meta?.isLink);
|
if (verifyUrl(<string>val.meta?.isLink)) window.open(val.meta?.isLink);
|
||||||
else window.open(`${val.meta?.isLink}`);
|
else window.open(`${val.meta?.isLink}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开小窗口
|
* 打开小窗口
|
||||||
*/
|
*/
|
||||||
export const openWindow = (url: string, title: string, w: number, h: number) => {
|
export const openWindow = (url: string, title: string, w: number, h: number) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left;
|
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top;
|
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top;
|
||||||
|
|
||||||
const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
|
const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
|
||||||
const height = window.innerHeight
|
const height = window.innerHeight
|
||||||
? window.innerHeight
|
? window.innerHeight
|
||||||
: document.documentElement.clientHeight
|
: document.documentElement.clientHeight
|
||||||
? document.documentElement.clientHeight
|
? document.documentElement.clientHeight
|
||||||
: screen.height;
|
: screen.height;
|
||||||
|
|
||||||
const left = width / 2 - w / 2 + dualScreenLeft;
|
const left = width / 2 - w / 2 + dualScreenLeft;
|
||||||
const top = height / 2 - h / 2 + dualScreenTop;
|
const top = height / 2 - h / 2 + dualScreenTop;
|
||||||
return window.open(
|
return window.open(
|
||||||
url,
|
url,
|
||||||
title,
|
title,
|
||||||
'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' +
|
'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' +
|
||||||
w +
|
w +
|
||||||
', height=' +
|
', height=' +
|
||||||
h +
|
h +
|
||||||
', top=' +
|
', top=' +
|
||||||
top +
|
top +
|
||||||
', left=' +
|
', left=' +
|
||||||
left
|
left
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -201,14 +201,14 @@ export const openWindow = (url: string, title: string, w: number, h: number) =>
|
|||||||
*加密处理
|
*加密处理
|
||||||
*/
|
*/
|
||||||
export function encryption(src: string, keyWord: string) {
|
export function encryption(src: string, keyWord: string) {
|
||||||
const key = CryptoJS.enc.Utf8.parse(keyWord);
|
const key = CryptoJS.enc.Utf8.parse(keyWord);
|
||||||
// 加密
|
// 加密
|
||||||
var encrypted = CryptoJS.AES.encrypt(src, key, {
|
var encrypted = CryptoJS.AES.encrypt(src, key, {
|
||||||
iv: key,
|
iv: key,
|
||||||
mode: CryptoJS.mode.CFB,
|
mode: CryptoJS.mode.CFB,
|
||||||
padding: CryptoJS.pad.NoPadding,
|
padding: CryptoJS.pad.NoPadding,
|
||||||
});
|
});
|
||||||
return encrypted.toString();
|
return encrypted.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -217,22 +217,22 @@ export function encryption(src: string, keyWord: string) {
|
|||||||
* @returns 明文
|
* @returns 明文
|
||||||
*/
|
*/
|
||||||
export function decryption(src: string, keyWord: string) {
|
export function decryption(src: string, keyWord: string) {
|
||||||
const key = CryptoJS.enc.Utf8.parse(keyWord);
|
const key = CryptoJS.enc.Utf8.parse(keyWord);
|
||||||
// 解密逻辑
|
// 解密逻辑
|
||||||
var decryptd = CryptoJS.AES.decrypt(src, key, {
|
var decryptd = CryptoJS.AES.decrypt(src, key, {
|
||||||
iv: key,
|
iv: key,
|
||||||
mode: CryptoJS.mode.CFB,
|
mode: CryptoJS.mode.CFB,
|
||||||
padding: CryptoJS.pad.NoPadding,
|
padding: CryptoJS.pad.NoPadding,
|
||||||
});
|
});
|
||||||
|
|
||||||
return decryptd.toString(CryptoJS.enc.Utf8);
|
return decryptd.toString(CryptoJS.enc.Utf8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SM4加密处理
|
* SM4加密处理
|
||||||
*/
|
*/
|
||||||
export function sm4Encryption(src: string, keyWord: string) {
|
export function sm4Encryption(src: string, keyWord: string) {
|
||||||
return sm4.encrypt(src, keyWord);
|
return sm4.encrypt(src, keyWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,7 +241,7 @@ export function sm4Encryption(src: string, keyWord: string) {
|
|||||||
* @returns 明文
|
* @returns 明文
|
||||||
*/
|
*/
|
||||||
export function sm4Decryption(src: string, keyWord: string) {
|
export function sm4Decryption(src: string, keyWord: string) {
|
||||||
return sm4.decrypt(src, keyWord);
|
return sm4.decrypt(src, keyWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -251,8 +251,8 @@ export function sm4Decryption(src: string, keyWord: string) {
|
|||||||
* @returns 密文
|
* @returns 密文
|
||||||
*/
|
*/
|
||||||
export function base64Encrypt(src: string) {
|
export function base64Encrypt(src: string) {
|
||||||
const encodedWord = CryptoJS.enc.Utf8.parse(src);
|
const encodedWord = CryptoJS.enc.Utf8.parse(src);
|
||||||
return CryptoJS.enc.Base64.stringify(encodedWord);
|
return CryptoJS.enc.Base64.stringify(encodedWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -263,14 +263,14 @@ export function base64Encrypt(src: string) {
|
|||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
export function downBlobFile(url: any, query: any, fileName: string) {
|
export function downBlobFile(url: any, query: any, fileName: string) {
|
||||||
return request({
|
return request({
|
||||||
url: url,
|
url: url,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
params: query,
|
params: query,
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
handleBlobFile(response, fileName);
|
handleBlobFile(response, fileName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -279,26 +279,26 @@ export function downBlobFile(url: any, query: any, fileName: string) {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function handleBlobFile(response: any, fileName: string) {
|
export function handleBlobFile(response: any, fileName: string) {
|
||||||
// 处理返回的文件流
|
// 处理返回的文件流
|
||||||
const blob = response;
|
const blob = response;
|
||||||
if (blob && blob.size === 0) {
|
if (blob && blob.size === 0) {
|
||||||
useMessage().error('内容为空,无法下载');
|
useMessage().error('内容为空,无法下载');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
|
|
||||||
// 兼容一下 入参不是 File Blob 类型情况
|
// 兼容一下 入参不是 File Blob 类型情况
|
||||||
var binaryData = [] as any;
|
var binaryData = [] as any;
|
||||||
binaryData.push(response);
|
binaryData.push(response);
|
||||||
link.href = window.URL.createObjectURL(new Blob(binaryData));
|
link.href = window.URL.createObjectURL(new Blob(binaryData));
|
||||||
link.download = fileName;
|
link.download = fileName;
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
URL.revokeObjectURL(blob);
|
URL.revokeObjectURL(blob);
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,31 +306,31 @@ export function handleBlobFile(response: any, fileName: string) {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
export function generateUUID() {
|
export function generateUUID() {
|
||||||
if (typeof crypto === 'object') {
|
if (typeof crypto === 'object') {
|
||||||
if (typeof crypto.randomUUID === 'function') {
|
if (typeof crypto.randomUUID === 'function') {
|
||||||
return crypto.randomUUID();
|
return crypto.randomUUID();
|
||||||
}
|
}
|
||||||
if (typeof crypto.getRandomValues === 'function' && typeof Uint8Array === 'function') {
|
if (typeof crypto.getRandomValues === 'function' && typeof Uint8Array === 'function') {
|
||||||
const callback = (c: any) => {
|
const callback = (c: any) => {
|
||||||
const num = Number(c);
|
const num = Number(c);
|
||||||
return (num ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (num / 4)))).toString(16);
|
return (num ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (num / 4)))).toString(16);
|
||||||
};
|
};
|
||||||
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, callback);
|
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let timestamp = new Date().getTime();
|
let timestamp = new Date().getTime();
|
||||||
let performanceNow = (typeof performance !== 'undefined' && performance.now && performance.now() * 1000) || 0;
|
let performanceNow = (typeof performance !== 'undefined' && performance.now && performance.now() * 1000) || 0;
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
||||||
let random = Math.random() * 16;
|
let random = Math.random() * 16;
|
||||||
if (timestamp > 0) {
|
if (timestamp > 0) {
|
||||||
random = (timestamp + random) % 16 | 0;
|
random = (timestamp + random) % 16 | 0;
|
||||||
timestamp = Math.floor(timestamp / 16);
|
timestamp = Math.floor(timestamp / 16);
|
||||||
} else {
|
} else {
|
||||||
random = (performanceNow + random) % 16 | 0;
|
random = (performanceNow + random) % 16 | 0;
|
||||||
performanceNow = Math.floor(performanceNow / 16);
|
performanceNow = Math.floor(performanceNow / 16);
|
||||||
}
|
}
|
||||||
return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16);
|
return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -346,85 +346,85 @@ export function generateUUID() {
|
|||||||
* @method handleOpenLink 打开外部链接
|
* @method handleOpenLink 打开外部链接
|
||||||
*/
|
*/
|
||||||
const other = {
|
const other = {
|
||||||
elSvg: (app: App) => {
|
elSvg: (app: App) => {
|
||||||
elSvg(app);
|
elSvg(app);
|
||||||
},
|
},
|
||||||
useTitle: () => {
|
useTitle: () => {
|
||||||
useTitle();
|
useTitle();
|
||||||
},
|
},
|
||||||
setMenuI18n(item: RouteItems) {
|
setMenuI18n(item: RouteItems) {
|
||||||
return setMenuI18n(item);
|
return setMenuI18n(item);
|
||||||
},
|
},
|
||||||
lazyImg: (el: string, arr: EmptyArrayType) => {
|
lazyImg: (el: string, arr: EmptyArrayType) => {
|
||||||
lazyImg(el, arr);
|
lazyImg(el, arr);
|
||||||
},
|
},
|
||||||
globalComponentSize: () => {
|
globalComponentSize: () => {
|
||||||
return globalComponentSize();
|
return globalComponentSize();
|
||||||
},
|
},
|
||||||
deepClone: (obj: EmptyObjectType) => {
|
deepClone: (obj: EmptyObjectType) => {
|
||||||
return deepClone(obj);
|
return deepClone(obj);
|
||||||
},
|
},
|
||||||
isMobile: () => {
|
isMobile: () => {
|
||||||
return isMobile();
|
return isMobile();
|
||||||
},
|
},
|
||||||
handleEmpty: (list: EmptyArrayType) => {
|
handleEmpty: (list: EmptyArrayType) => {
|
||||||
return handleEmpty(list);
|
return handleEmpty(list);
|
||||||
},
|
},
|
||||||
handleOpenLink: (val: RouteItem) => {
|
handleOpenLink: (val: RouteItem) => {
|
||||||
handleOpenLink(val);
|
handleOpenLink(val);
|
||||||
},
|
},
|
||||||
encryption: (src: string, keyWord: string) => {
|
encryption: (src: string, keyWord: string) => {
|
||||||
return encryption(src, keyWord);
|
return encryption(src, keyWord);
|
||||||
},
|
},
|
||||||
decryption: (src: string, keyWord: string) => {
|
decryption: (src: string, keyWord: string) => {
|
||||||
return decryption(src, keyWord);
|
return decryption(src, keyWord);
|
||||||
},
|
},
|
||||||
base64Encrypt: (data: any) => {
|
base64Encrypt: (data: any) => {
|
||||||
return base64Encrypt(data);
|
return base64Encrypt(data);
|
||||||
},
|
},
|
||||||
downBlobFile: (url: any, query: any, fileName: string) => {
|
downBlobFile: (url: any, query: any, fileName: string) => {
|
||||||
return downBlobFile(url, query, fileName);
|
return downBlobFile(url, query, fileName);
|
||||||
},
|
},
|
||||||
toUnderline: (str: string) => {
|
toUnderline: (str: string) => {
|
||||||
return toUnderline(str);
|
return toUnderline(str);
|
||||||
},
|
},
|
||||||
openWindow: (url: string, title: string, w: number, h: number) => {
|
openWindow: (url: string, title: string, w: number, h: number) => {
|
||||||
return openWindow(url, title, w, h);
|
return openWindow(url, title, w, h);
|
||||||
},
|
},
|
||||||
getQueryString: (url: string, paraName: string) => {
|
getQueryString: (url: string, paraName: string) => {
|
||||||
return getQueryString(url, paraName);
|
return getQueryString(url, paraName);
|
||||||
},
|
},
|
||||||
adaptationUrl: (url?: string) => {
|
adaptationUrl: (url?: string) => {
|
||||||
return adaptationUrl(url);
|
return adaptationUrl(url);
|
||||||
},
|
},
|
||||||
resolveAllEunuchNodeId: (json: any[], idArr: any[], temp: any[] = []) => {
|
resolveAllEunuchNodeId: (json: any[], idArr: any[], temp: any[] = []) => {
|
||||||
return resolveAllEunuchNodeId(json, idArr, temp);
|
return resolveAllEunuchNodeId(json, idArr, temp);
|
||||||
},
|
},
|
||||||
getNonDuplicateID: () => {
|
getNonDuplicateID: () => {
|
||||||
return getNonDuplicateID();
|
return getNonDuplicateID();
|
||||||
},
|
},
|
||||||
|
|
||||||
addUnit: (value: string | number, unit = 'px') => {
|
addUnit: (value: string | number, unit = 'px') => {
|
||||||
return addUnit(value, unit);
|
return addUnit(value, unit);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getQueryString(url: string, paraName: string) {
|
export function getQueryString(url: string, paraName: string) {
|
||||||
const arrObj = url.split('?');
|
const arrObj = url.split('?');
|
||||||
if (arrObj.length > 1) {
|
if (arrObj.length > 1) {
|
||||||
const arrPara = arrObj[1].split('&');
|
const arrPara = arrObj[1].split('&');
|
||||||
let arr;
|
let arr;
|
||||||
for (let i = 0; i < arrPara.length; i++) {
|
for (let i = 0; i < arrPara.length; i++) {
|
||||||
arr = arrPara[i].split('=');
|
arr = arrPara[i].split('=');
|
||||||
// eslint-disable-next-line eqeqeq
|
// eslint-disable-next-line eqeqeq
|
||||||
if (arr != null && arr[0] == paraName) {
|
if (arr != null && arr[0] == paraName) {
|
||||||
return arr[1];
|
return arr[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -437,31 +437,31 @@ export function getQueryString(url: string, paraName: string) {
|
|||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
export function handleTree(data: any, id: any, parentId: any, children: any, rootId: any) {
|
export function handleTree(data: any, id: any, parentId: any, children: any, rootId: any) {
|
||||||
id = id || 'id';
|
id = id || 'id';
|
||||||
parentId = parentId || 'parentId';
|
parentId = parentId || 'parentId';
|
||||||
children = children || 'children';
|
children = children || 'children';
|
||||||
rootId =
|
rootId =
|
||||||
rootId ||
|
rootId ||
|
||||||
Math.min.apply(
|
Math.min.apply(
|
||||||
Math,
|
Math,
|
||||||
data.map((item: any) => {
|
data.map((item: any) => {
|
||||||
return item[parentId];
|
return item[parentId];
|
||||||
})
|
})
|
||||||
) ||
|
) ||
|
||||||
0;
|
0;
|
||||||
//对源数据深度克隆
|
//对源数据深度克隆
|
||||||
const cloneData = JSON.parse(JSON.stringify(data));
|
const cloneData = JSON.parse(JSON.stringify(data));
|
||||||
//循环所有项
|
//循环所有项
|
||||||
const treeData = cloneData.filter((father: any) => {
|
const treeData = cloneData.filter((father: any) => {
|
||||||
const branchArr = cloneData.filter((child: any) => {
|
const branchArr = cloneData.filter((child: any) => {
|
||||||
//返回每一项的子级数组
|
//返回每一项的子级数组
|
||||||
return father[id] === child[parentId];
|
return father[id] === child[parentId];
|
||||||
});
|
});
|
||||||
branchArr.length > 0 ? (father[children] = branchArr) : '';
|
branchArr.length > 0 ? (father[children] = branchArr) : '';
|
||||||
//返回第一层
|
//返回第一层
|
||||||
return father[parentId] === rootId;
|
return father[parentId] === rootId;
|
||||||
});
|
});
|
||||||
return treeData !== '' ? treeData : data;
|
return treeData !== '' ? treeData : data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -469,14 +469,14 @@ export function handleTree(data: any, id: any, parentId: any, children: any, roo
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const resolveAllEunuchNodeId = (json: any[], idArr: any[], temp: any[] = []) => {
|
const resolveAllEunuchNodeId = (json: any[], idArr: any[], temp: any[] = []) => {
|
||||||
for (const item of json) {
|
for (const item of json) {
|
||||||
if (item.children && item.children.length !== 0) {
|
if (item.children && item.children.length !== 0) {
|
||||||
resolveAllEunuchNodeId(item.children, idArr, temp);
|
resolveAllEunuchNodeId(item.children, idArr, temp);
|
||||||
} else {
|
} else {
|
||||||
temp.push(...idArr.filter((id) => id === item.id));
|
temp.push(...idArr.filter((id) => id === item.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return temp;
|
return temp;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -485,7 +485,7 @@ const resolveAllEunuchNodeId = (json: any[], idArr: any[], temp: any[] = []) =>
|
|||||||
* @returns 下划线
|
* @returns 下划线
|
||||||
*/
|
*/
|
||||||
export function toUnderline(str: string) {
|
export function toUnderline(str: string) {
|
||||||
return str.replace(/([A-Z])/g, '_$1').toLowerCase();
|
return str.replace(/([A-Z])/g, '_$1').toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -496,23 +496,14 @@ export function toUnderline(str: string) {
|
|||||||
* @param originUrl 原始路径
|
* @param originUrl 原始路径
|
||||||
*/
|
*/
|
||||||
const adaptationUrl = (originUrl?: string) => {
|
const adaptationUrl = (originUrl?: string) => {
|
||||||
// 微服务架构 不做路径转换,为空不做路径转换
|
// 微服务架构 不做路径转换,为空不做路径转换
|
||||||
const isMicro = import.meta.env.VITE_IS_MICRO;
|
const isMicro = import.meta.env.VITE_IS_MICRO;
|
||||||
if (validateNull(isMicro) || isMicro === 'true') {
|
if (validateNull(isMicro) || isMicro === 'true') {
|
||||||
return originUrl;
|
return originUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证码服务
|
// 转为 /admin 路由前缀的请求
|
||||||
if (originUrl?.startsWith('/code/')) {
|
return `/admin/${originUrl?.split('/').splice(2).join('/')}`;
|
||||||
return `/admin${originUrl}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果是代码生成服务,不做路径转换
|
|
||||||
if (originUrl?.startsWith('/gen')) {
|
|
||||||
return originUrl;
|
|
||||||
}
|
|
||||||
// 转为 /admin 路由前缀的请求
|
|
||||||
return `/admin/${originUrl?.split('/').splice(2).join('/')}`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -521,9 +512,9 @@ const adaptationUrl = (originUrl?: string) => {
|
|||||||
* @return { String } id
|
* @return { String } id
|
||||||
*/
|
*/
|
||||||
const getNonDuplicateID = (length = 8) => {
|
const getNonDuplicateID = (length = 8) => {
|
||||||
let idStr = Date.now().toString(36);
|
let idStr = Date.now().toString(36);
|
||||||
idStr += Math.random().toString(36).substring(3, length);
|
idStr += Math.random().toString(36).substring(3, length);
|
||||||
return idStr;
|
return idStr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -532,7 +523,7 @@ const getNonDuplicateID = (length = 8) => {
|
|||||||
* @param {String} unit 单位 px em rem
|
* @param {String} unit 单位 px em rem
|
||||||
*/
|
*/
|
||||||
const addUnit = (value: string | number, unit = 'px') => {
|
const addUnit = (value: string | number, unit = 'px') => {
|
||||||
return !Object.is(Number(value), NaN) ? `${value}${unit}` : value;
|
return !Object.is(Number(value), NaN) ? `${value}${unit}` : value;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 统一批量导出
|
// 统一批量导出
|
||||||
|
@ -95,7 +95,7 @@ const imgSrc = ref('')
|
|||||||
//获取验证码图片
|
//获取验证码图片
|
||||||
const getVerifyCode = () => {
|
const getVerifyCode = () => {
|
||||||
state.ruleForm.randomStr = generateUUID()
|
state.ruleForm.randomStr = generateUUID()
|
||||||
imgSrc.value = `${import.meta.env.VITE_API_URL}${import.meta.env.VITE_IS_MICRO == 'false' ? '/admin' : ''}/code/image?randomStr=${state.ruleForm.randomStr}`
|
imgSrc.value = `${import.meta.env.VITE_API_URL}${import.meta.env.VITE_IS_MICRO == 'false' ? '/admin' : '/auth'}/code/image?randomStr=${state.ruleForm.randomStr}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 账号密码登录
|
// 账号密码登录
|
||||||
|
Loading…
Reference in New Issue
Block a user