⚡优化路由参数
This commit is contained in:
parent
43485dddfa
commit
7c6e21531b
@ -22,7 +22,7 @@ export function getUser(userId) {
|
|||||||
// 新增用户
|
// 新增用户
|
||||||
export function addUser(data) {
|
export function addUser(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/edit',
|
url: '/system/user/add',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
|
|||||||
@ -68,12 +68,17 @@ function close() {
|
|||||||
}
|
}
|
||||||
function change(val) {
|
function change(val) {
|
||||||
const path = val.path
|
const path = val.path
|
||||||
|
const query = val.query
|
||||||
if (isHttp(path)) {
|
if (isHttp(path)) {
|
||||||
// http(s):// 路径新窗口打开
|
// http(s):// 路径新窗口打开
|
||||||
const pindex = path.indexOf('http')
|
const pindex = path.indexOf('http')
|
||||||
window.open(path.substr(pindex, path.length), '_blank')
|
window.open(path.substr(pindex, path.length), '_blank')
|
||||||
} else {
|
} else {
|
||||||
router.push(path)
|
if (query) {
|
||||||
|
router.push({ path: path, query: JSON.parse(query) })
|
||||||
|
} else {
|
||||||
|
router.push(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
search.value = ''
|
search.value = ''
|
||||||
@ -104,7 +109,7 @@ function initFuse(list) {
|
|||||||
}
|
}
|
||||||
// Filter out the routes that can be displayed in the sidebar
|
// Filter out the routes that can be displayed in the sidebar
|
||||||
// And generate the internationalized title
|
// And generate the internationalized title
|
||||||
function generateRoutes(routes, basePath = '', prefixTitle = []) {
|
function generateRoutes(routes, basePath = '', prefixTitle = [], query = {}) {
|
||||||
let res = []
|
let res = []
|
||||||
|
|
||||||
for (const r of routes) {
|
for (const r of routes) {
|
||||||
@ -130,6 +135,9 @@ function generateRoutes(routes, basePath = '', prefixTitle = []) {
|
|||||||
res.push(data)
|
res.push(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (r.query) {
|
||||||
|
data.query = r.query
|
||||||
|
}
|
||||||
|
|
||||||
// recursive child routes
|
// recursive child routes
|
||||||
if (r.children) {
|
if (r.children) {
|
||||||
|
|||||||
@ -126,7 +126,13 @@ function handleSelect(key, keyPath) {
|
|||||||
window.open(key, '_blank')
|
window.open(key, '_blank')
|
||||||
} else if (!route || !route.children) {
|
} else if (!route || !route.children) {
|
||||||
// 没有子路由路径内部打开
|
// 没有子路由路径内部打开
|
||||||
router.push({ path: key })
|
const routeMenu = childrenMenus.value.find((item) => item.path === key)
|
||||||
|
if (routeMenu && routeMenu.query) {
|
||||||
|
let query = JSON.parse(routeMenu.query)
|
||||||
|
router.push({ path: key, query: query })
|
||||||
|
} else {
|
||||||
|
router.push({ path: key })
|
||||||
|
}
|
||||||
appStore.toggleSideBarHide(true)
|
appStore.toggleSideBarHide(true)
|
||||||
} else {
|
} else {
|
||||||
// 显示左侧联动菜单
|
// 显示左侧联动菜单
|
||||||
|
|||||||
@ -123,6 +123,13 @@ fpPromise
|
|||||||
visitorId = result.visitorId
|
visitorId = result.visitorId
|
||||||
userStore.setClientId(visitorId)
|
userStore.setClientId(visitorId)
|
||||||
})
|
})
|
||||||
|
watch(
|
||||||
|
route,
|
||||||
|
(newRoute) => {
|
||||||
|
redirect.value = newRoute.query && newRoute.query.redirect
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
function handleLogin() {
|
function handleLogin() {
|
||||||
proxy.$refs.loginRef.validate((valid) => {
|
proxy.$refs.loginRef.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user