!379 【轻PR】label错误

Merge pull request !379 from NiceShow/master
This commit is contained in:
芋道源码 2024-02-17 08:41:07 +00:00 committed by Gitee
commit 96071bdcb7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 39 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "yudao-ui-admin-vue3",
"version": "1.8.3-snapshot",
"version": "2.0.0-snapshot",
"description": "基于vue3、vite4、element-plus、typesScript",
"author": "xingyu",
"private": false,

View File

@ -12,6 +12,40 @@ import { usePermissionStoreWithOut } from '@/store/modules/permission'
const { start, done } = useNProgress()
const { loadStart, loadDone } = usePageLoading()
const parseURL = (
url: string | null | undefined
): { basePath: string; paramsObject: { [key: string]: string } } => {
// 如果输入为 null 或 undefined返回空字符串和空对象
if (url == null) {
return { basePath: '', paramsObject: {} }
}
// 找到问号 (?) 的位置,它之前是基础路径,之后是查询参数
const questionMarkIndex = url.indexOf('?')
let basePath = url
const paramsObject: { [key: string]: string } = {}
// 如果找到了问号,说明有查询参数
if (questionMarkIndex !== -1) {
// 获取 basePath
basePath = url.substring(0, questionMarkIndex)
// 从 URL 中获取查询字符串部分
const queryString = url.substring(questionMarkIndex + 1)
// 使用 URLSearchParams 遍历参数
const searchParams = new URLSearchParams(queryString)
searchParams.forEach((value, key) => {
// 封装进 paramsObject 对象
paramsObject[key] = value
})
}
// 返回 basePath 和 paramsObject
return { basePath, paramsObject }
}
// 路由不重定向白名单
const whiteList = [
'/login',
@ -47,8 +81,10 @@ router.beforeEach(async (to, from, next) => {
router.addRoute(route as unknown as RouteRecordRaw) // 动态添加可访问路由表
})
const redirectPath = from.query.redirect || to.path
// 修复跳转时不带参数的问题
const redirect = decodeURIComponent(redirectPath as string)
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
const { basePath, paramsObject: query } = parseURL(redirect)
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect, query }
next(nextData)
} else {
next()

View File

@ -133,7 +133,7 @@ const crudSchemas = reactive<CrudSchema[]>([
}
},
{
label: '拼团商品',
label: '砍价商品',
field: 'spuId',
isSearch: false,
form: {