提交 1e9f9499 authored 作者: 王鹏飞's avatar 王鹏飞

chore: 增加容错处理

上级 68945a8d
...@@ -76,7 +76,10 @@ export async function useMap() { ...@@ -76,7 +76,10 @@ export async function useMap() {
} }
authList.value = authList.value =
data.channel_auth_map.map((item: any) => { data.channel_auth_map.map((item: any) => {
const tags = item.roles.reduce((result: any, role: string) => Object.assign(result, data.role_tags[role]), {}) const tags = item.roles?.reduce(
(result: any, role: string) => Object.assign(result, data.role_tags[role]),
{}
)
return { ...item, tags } return { ...item, tags }
}) || [] }) || []
tags.value = data.tags || {} tags.value = data.tags || {}
...@@ -101,7 +104,7 @@ export async function useMap() { ...@@ -101,7 +104,7 @@ export async function useMap() {
// 暂时先返回true; 有项目ID的必须定义项目ID,要不等于没做权限处理 // 暂时先返回true; 有项目ID的必须定义项目ID,要不等于没做权限处理
if (!project) return true if (!project) return true
const prop = pre + key const prop = pre + key
return Object.prototype.hasOwnProperty.call(project.tags, prop) return Object.prototype.hasOwnProperty.call(project.tags || {}, prop)
} }
// 权限校验 // 权限校验
function checkAuth(key: string, pid: string = channelId.value, pre: string = prefix.value) { function checkAuth(key: string, pid: string = channelId.value, pre: string = prefix.value) {
......
...@@ -25,7 +25,10 @@ export async function useMap() { ...@@ -25,7 +25,10 @@ export async function useMap() {
status.value = data.project_status_map || [] status.value = data.project_status_map || []
authProjectList.value = authProjectList.value =
data.project_auth_map.map((item: any) => { data.project_auth_map.map((item: any) => {
const tags = item.roles.reduce((result: any, role: string) => Object.assign(result, data.role_tags[role]), {}) const tags = item.roles?.reduce(
(result: any, role: string) => Object.assign(result, data.role_tags[role]),
{}
)
return { ...item, tags } return { ...item, tags }
}) || [] }) || []
tags.value = data.tags || {} tags.value = data.tags || {}
...@@ -49,7 +52,7 @@ export async function useMap() { ...@@ -49,7 +52,7 @@ export async function useMap() {
// 暂时先返回true; 有项目ID的必须定义项目ID,要不等于没做权限处理 // 暂时先返回true; 有项目ID的必须定义项目ID,要不等于没做权限处理
if (!project) return true if (!project) return true
const prop = pre + key const prop = pre + key
return Object.prototype.hasOwnProperty.call(project.tags, prop) return Object.prototype.hasOwnProperty.call(project.tags || {}, prop)
} }
// 权限校验 // 权限校验
function checkAuth(key: string, pid: string = projectId.value, pre: string = prefix.value) { function checkAuth(key: string, pid: string = projectId.value, pre: string = prefix.value) {
......
...@@ -24,11 +24,11 @@ export default defineConfig(({ mode }) => ({ ...@@ -24,11 +24,11 @@ export default defineConfig(({ mode }) => ({
cert: fs.readFileSync(path.join(__dirname, './https/dev.ezijing.com.pem')) cert: fs.readFileSync(path.join(__dirname, './https/dev.ezijing.com.pem'))
}, },
proxy: { proxy: {
'/api/zws': { // '/api/zws': {
target: 'http://localhost-new-zws-backend.ezijing.com', // target: 'http://localhost-new-zws-backend.ezijing.com',
changeOrigin: true, // changeOrigin: true,
rewrite: path => path.replace(/^\/api\/zws/, '') // rewrite: path => path.replace(/^\/api\/zws/, '')
}, // },
'/api': 'https://zws-center.ezijing.com' '/api': 'https://zws-center.ezijing.com'
} }
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论