提交代码

This commit is contained in:
yiqiuyang
2025-10-15 16:46:35 +08:00
parent 9a01223fc9
commit 502eaff488
36 changed files with 595 additions and 196 deletions
+43 -4
View File
@@ -4,10 +4,7 @@
* @returns {number} 自适应后的尺寸
*/
export function fontSize(res) {
let clientWidth =
window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth
let clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
if (!clientWidth) return
let fontSize = clientWidth / 1920
return res * fontSize
@@ -34,3 +31,45 @@ export function randomBgColor(type = 'hex') {
.padStart(6, '0')
)
}
/**
* 根据 url 递归查找对应的 label
* @param {Array} tree - header 数组
* @param {String} path - 要匹配的 url
* @returns {String|undefined} 找到返回 label,否则 undefined
*/
export function findLabelByUrl(tree, path) {
for (const node of tree) {
if (node.url === path) return node.label
if (node.hasChildren && node.children) {
const child = findLabelByUrl(node.children, path)
if (child) return child
}
}
}
/**
* get参数处理
* @param {*} params 参数
*/
export function tansParams(params) {
let result = ''
for (const propName of Object.keys(params)) {
const value = params[propName]
const part = `${encodeURIComponent(propName)}=`
if (value !== null && typeof value !== 'undefined') {
if (typeof value === 'object') {
for (const key of Object.keys(value)) {
if (value[key] !== null && typeof value[key] !== 'undefined') {
const params = `${propName}[${key}]`
const subPart = `${encodeURIComponent(params)}=`
result += `${subPart + encodeURIComponent(value[key])}&`
}
}
} else {
result += `${part + encodeURIComponent(value)}&`
}
}
}
return result
}
+7 -14
View File
@@ -50,10 +50,7 @@ service.interceptors.response.use(
const {data, config} = response
// 处理二进制数据响应
if (
config.responseType === 'blob' ||
config.responseType === 'arraybuffer'
) {
if (config.responseType === 'blob' || config.responseType === 'arraybuffer') {
return data
}
@@ -90,15 +87,11 @@ function handleAuthError(config, response) {
const excludeUrls = ['/Token/Logout', '/Token/Access']
if (!excludeUrls.includes(config.url)) {
ElMessageBox.confirm(
'登录状态已过期,您可以继续留在该页面,或者重新登录',
'系统提示',
{
confirmButtonText: '重新登录',
cancelButtonText: '取消',
type: 'warning',
}
)
ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
confirmButtonText: '重新登录',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
removeToken()
removeUserTenantInfo()
@@ -127,7 +120,7 @@ function handleNetworkError(message) {
ElMessage({
message: errorMsg,
type: 'error',
duration: 5 * 1000,
duration: 1000,
})
}