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