Skip to content

Commit 501942f

Browse files
committed
chore: 移动路由相对路径转换
- 处理 VueCropper 打开报错问题
1 parent 1315f99 commit 501942f

File tree

6 files changed

+42
-42
lines changed

6 files changed

+42
-42
lines changed

src/config/router.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const asyncRouterMap = [
2020
meta: { title: '仪表盘', keepAlive: true, icon: bxAnaalyse, permission: [ 'dashboard' ] },
2121
children: [
2222
{
23-
path: 'analysis',
23+
path: 'analysis/:pageNo([1-9]\\d*)?',
2424
name: 'Analysis',
2525
component: () => import('@/views/dashboard/Analysis'),
2626
meta: { title: '分析页', keepAlive: false, permission: [ 'dashboard' ] }
@@ -232,31 +232,31 @@ export const asyncRouterMap = [
232232
path: '/account/settings/base',
233233
name: 'BaseSettings',
234234
component: () => import('@/views/account/settings/BaseSetting'),
235-
meta: { title: '基本设置', permission: [ 'user' ] }
235+
meta: { title: '基本设置', hidden: true, permission: [ 'user' ] }
236236
},
237237
{
238238
path: '/account/settings/security',
239239
name: 'SecuritySettings',
240240
component: () => import('@/views/account/settings/Security'),
241-
meta: { title: '安全设置', keepAlive: true, permission: [ 'user' ] }
241+
meta: { title: '安全设置', hidden: true, keepAlive: true, permission: [ 'user' ] }
242242
},
243243
{
244244
path: '/account/settings/custom',
245245
name: 'CustomSettings',
246246
component: () => import('@/views/account/settings/Custom'),
247-
meta: { title: '个性化设置', keepAlive: true, permission: [ 'user' ] }
247+
meta: { title: '个性化设置', hidden: true, keepAlive: true, permission: [ 'user' ] }
248248
},
249249
{
250250
path: '/account/settings/binding',
251251
name: 'BindingSettings',
252252
component: () => import('@/views/account/settings/Binding'),
253-
meta: { title: '账户绑定', keepAlive: true, permission: [ 'user' ] }
253+
meta: { title: '账户绑定', hidden: true, keepAlive: true, permission: [ 'user' ] }
254254
},
255255
{
256256
path: '/account/settings/notification',
257257
name: 'NotificationSettings',
258258
component: () => import('@/views/account/settings/Notification'),
259-
meta: { title: '新消息通知', keepAlive: true, permission: [ 'user' ] }
259+
meta: { title: '新消息通知', hidden: true, keepAlive: true, permission: [ 'user' ] }
260260
}
261261
]
262262
}

src/core/lazy_use.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Viser from 'viser-vue'
88

99
// ext library
1010
import VueClipboard from 'vue-clipboard2'
11+
import VueCropper from 'vue-cropper'
1112
import MultiTab from '@/components/MultiTab'
1213
import PageLoading from '@/components/PageLoading'
1314
import PermissionHelper from '@/utils/helper/permission'
@@ -21,3 +22,4 @@ Vue.use(PageLoading)
2122
Vue.use(VueStorage, config.storageOptions)
2223
Vue.use(VueClipboard)
2324
Vue.use(PermissionHelper)
25+
Vue.use(VueCropper)

src/layouts/BasicLayout.vue

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -70,36 +70,7 @@ import SideMenu from '@/components/Menu/SideMenu'
7070
import GlobalHeader from '@/components/GlobalHeader'
7171
import GlobalFooter from '@/components/GlobalFooter'
7272
import SettingDrawer from '@/components/SettingDrawer'
73-
import cloneDeep from 'lodash.clonedeep'
74-
75-
function convertRoutes (nodes) {
76-
if (!nodes) return null
77-
78-
nodes = cloneDeep(nodes)
79-
80-
let queue = Array.isArray(nodes) ? nodes.concat() : [nodes]
81-
82-
while (queue.length) {
83-
const levelSize = queue.length
84-
85-
for (let i = 0; i < levelSize; i++) {
86-
const node = queue.shift()
87-
88-
if (!node.children || !node.children.length) continue
89-
90-
node.children.forEach(child => {
91-
// 转化相对路径
92-
if (child.path[0] !== '/') {
93-
child.path = node.path.replace(/(\w*)[/]*$/, `$1/${child.path}`)
94-
}
95-
})
96-
97-
queue = queue.concat(node.children)
98-
}
99-
}
100-
101-
return nodes
102-
}
73+
import { convertRoutes } from '@/utils/routeConvert'
10374
10475
export default {
10576
name: 'BasicLayout',

src/utils/routeConvert.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import cloneDeep from 'lodash.clonedeep'
2+
3+
export function convertRoutes (nodes) {
4+
if (!nodes) return null
5+
6+
nodes = cloneDeep(nodes)
7+
8+
let queue = Array.isArray(nodes) ? nodes.concat() : [nodes]
9+
10+
while (queue.length) {
11+
const levelSize = queue.length
12+
13+
for (let i = 0; i < levelSize; i++) {
14+
const node = queue.shift()
15+
16+
if (!node.children || !node.children.length) continue
17+
18+
node.children.forEach(child => {
19+
console.log('child', child)
20+
// 转化相对路径
21+
if (child.path[0] !== '/' && !child.path.startsWith('http')) {
22+
child.path = node.path.replace(/(\w*)[/]*$/, `$1/${child.path}`)
23+
console.log('child.path', child.path)
24+
}
25+
})
26+
27+
queue = queue.concat(node.children)
28+
}
29+
}
30+
31+
return nodes
32+
}

src/views/account/settings/AvatarModal.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,7 @@
5555

5656
</template>
5757
<script>
58-
import { VueCropper } from 'vue-cropper'
59-
6058
export default {
61-
components: {
62-
VueCropper
63-
},
6459
data () {
6560
return {
6661
visible: false,

src/views/account/settings/Index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default {
8787
pageTitle: ''
8888
}
8989
},
90-
created () {
90+
mounted () {
9191
this.updateMenu()
9292
},
9393
methods: {

0 commit comments

Comments
 (0)