Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-sfa-ui
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-sfa-ui
Commits
42ae05d6
提交
42ae05d6
authored
8月 27, 2025
作者:
lidongxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mobile/router): 新增:促销移动端菜单也是动态创建的
上级
a76059c7
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
80 行增加
和
19 行删除
+80
-19
permission.js
src/permission.js
+2
-1
app.js
src/store/modules/app.js
+7
-1
permission.js
src/store/modules/permission.js
+9
-0
user.js
src/store/modules/user.js
+4
-1
index.vue
src/views/mobile/views/menu/index.vue
+58
-16
没有找到文件。
src/permission.js
浏览文件 @
42ae05d6
...
@@ -10,6 +10,7 @@ import useUserStore from '@/store/modules/user'
...
@@ -10,6 +10,7 @@ import useUserStore from '@/store/modules/user'
import
useSettingsStore
from
'@/store/modules/settings'
import
useSettingsStore
from
'@/store/modules/settings'
import
usePermissionStore
from
'@/store/modules/permission'
import
usePermissionStore
from
'@/store/modules/permission'
import
useVersionStore
from
'@/store/modules/version'
import
useVersionStore
from
'@/store/modules/version'
import
useAppStore
from
'@/store/modules/app'
NProgress
.
configure
({
showSpinner
:
false
})
NProgress
.
configure
({
showSpinner
:
false
})
...
@@ -41,7 +42,7 @@ router.beforeEach((to, from, next) => {
...
@@ -41,7 +42,7 @@ router.beforeEach((to, from, next) => {
useVersionStore
().
getVersion
().
then
((
res
)
=>
{
useVersionStore
().
getVersion
().
then
((
res
)
=>
{
// 生成可访问路由表
// 生成可访问路由表
accessRoutes
.
forEach
(
route
=>
{
accessRoutes
.
forEach
(
route
=>
{
if
(
!
isHttp
(
route
.
path
))
{
if
(
!
isHttp
(
route
.
path
)
)
{
router
.
addRoute
(
route
)
router
.
addRoute
(
route
)
}
}
})
})
...
...
src/store/modules/app.js
浏览文件 @
42ae05d6
import
Cookies
from
'js-cookie'
import
Cookies
from
'js-cookie'
import
{
set
}
from
'nprogress'
;
const
useAppStore
=
defineStore
(
const
useAppStore
=
defineStore
(
'app'
,
'app'
,
...
@@ -10,7 +11,8 @@ const useAppStore = defineStore(
...
@@ -10,7 +11,8 @@ const useAppStore = defineStore(
hide
:
false
hide
:
false
},
},
device
:
'desktop'
,
device
:
'desktop'
,
size
:
Cookies
.
get
(
'size'
)
||
'default'
size
:
Cookies
.
get
(
'size'
)
||
'default'
,
belongSys
:
Cookies
.
get
(
'belongSys'
)
||
'链路中心'
,
}),
}),
actions
:
{
actions
:
{
toggleSideBar
(
withoutAnimation
)
{
toggleSideBar
(
withoutAnimation
)
{
...
@@ -39,6 +41,10 @@ const useAppStore = defineStore(
...
@@ -39,6 +41,10 @@ const useAppStore = defineStore(
},
},
toggleSideBarHide
(
status
)
{
toggleSideBarHide
(
status
)
{
this
.
sidebar
.
hide
=
status
this
.
sidebar
.
hide
=
status
},
setBelongSys
(
belongSys
)
{
this
.
belongSys
=
belongSys
Cookies
.
set
(
'belongSys'
,
belongSys
)
}
}
}
}
})
})
...
...
src/store/modules/permission.js
浏览文件 @
42ae05d6
...
@@ -5,6 +5,7 @@ import Layout from '@/layout/index'
...
@@ -5,6 +5,7 @@ import Layout from '@/layout/index'
import
ParentView
from
'@/components/ParentView'
import
ParentView
from
'@/components/ParentView'
import
InnerLink
from
'@/layout/components/InnerLink'
import
InnerLink
from
'@/layout/components/InnerLink'
import
useUserStore
from
'@/store/modules/user'
import
useUserStore
from
'@/store/modules/user'
import
useAppStore
from
'@/store/modules/app'
// 匹配views里面所有的.vue文件
// 匹配views里面所有的.vue文件
const
modules
=
import
.
meta
.
glob
(
'./../../views/**/*.vue'
)
const
modules
=
import
.
meta
.
glob
(
'./../../views/**/*.vue'
)
...
@@ -37,6 +38,14 @@ const usePermissionStore = defineStore(
...
@@ -37,6 +38,14 @@ const usePermissionStore = defineStore(
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
// 向后端请求路由数据
// 向后端请求路由数据
getRouters
().
then
(
res
=>
{
getRouters
().
then
(
res
=>
{
// 判断链路中心0,还是勤策1 的路由表
if
(
useAppStore
().
belongSys
==
0
)
{
// 链路中心
res
.
data
=
res
.
data
.
filter
(
item
=>
item
.
belongSys
==
0
)
}
else
{
// 勤策
res
.
data
=
res
.
data
.
filter
(
item
=>
item
.
belongSys
==
1
)
}
const
sdata
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
))
const
sdata
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
))
const
rdata
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
))
const
rdata
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
))
const
defaultData
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
))
const
defaultData
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
))
...
...
src/store/modules/user.js
浏览文件 @
42ae05d6
import
{
login
,
fsLogin
,
getInfo
,
qcLogin
,
refreshTokenAPI
}
from
'@/api'
import
{
login
,
fsLogin
,
getInfo
,
qcLogin
,
refreshTokenAPI
}
from
'@/api'
import
{
getToken
,
setToken
,
removeToken
,
getRefreshToken
,
setRefreshToken
,
removeRefreshToken
}
from
'@/utils/auth'
import
{
getToken
,
setToken
,
removeToken
,
getRefreshToken
,
setRefreshToken
,
removeRefreshToken
}
from
'@/utils/auth'
import
useAppStore
from
'@/store/modules/app'
import
{
isHttp
,
isEmpty
}
from
"@/utils/validate"
import
{
isHttp
,
isEmpty
}
from
"@/utils/validate"
import
defAva
from
'@/assets/images/profile.jpg'
import
defAva
from
'@/assets/images/profile.jpg'
...
@@ -32,6 +32,7 @@ export default defineStore(
...
@@ -32,6 +32,7 @@ export default defineStore(
// this.refreshToken = res.data.refresh_token
// this.refreshToken = res.data.refresh_token
setToken
(
res
.
data
.
access_token
)
setToken
(
res
.
data
.
access_token
)
// setRefreshToken(res.data.refresh_token)
// setRefreshToken(res.data.refresh_token)
useAppStore
().
setBelongSys
(
'0'
)
// 0 链路中心
resolve
()
resolve
()
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
reject
(
error
)
reject
(
error
)
...
@@ -41,6 +42,7 @@ export default defineStore(
...
@@ -41,6 +42,7 @@ export default defineStore(
fsLogin
({
code
}).
then
(
res
=>
{
fsLogin
({
code
}).
then
(
res
=>
{
setToken
(
res
.
access_token
)
setToken
(
res
.
access_token
)
this
.
token
=
res
.
access_token
this
.
token
=
res
.
access_token
useAppStore
().
setBelongSys
(
'0'
)
// 0 链路中心
resolve
()
resolve
()
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
reject
(
error
)
reject
(
error
)
...
@@ -51,6 +53,7 @@ export default defineStore(
...
@@ -51,6 +53,7 @@ export default defineStore(
qcLogin
({
code
}).
then
(
res
=>
{
qcLogin
({
code
}).
then
(
res
=>
{
setToken
(
res
.
access_token
)
setToken
(
res
.
access_token
)
this
.
token
=
res
.
access_token
this
.
token
=
res
.
access_token
useAppStore
().
setBelongSys
(
'1'
)
// 1 勤策
resolve
()
resolve
()
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
reject
(
error
)
reject
(
error
)
...
...
src/views/mobile/views/menu/index.vue
浏览文件 @
42ae05d6
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
@
click=
"handleIconClick(icon)"
>
@
click=
"handleIconClick(icon)"
>
<div
class=
"function-icon-wrap"
<div
class=
"function-icon-wrap"
:style=
"
{ backgroundColor: icon.iconColor }">
:style=
"
{ backgroundColor: icon.iconColor }">
<
van-icon
:name
=
"icon.iconName"
/>
<
svg-icon
:icon-class
=
"icon.iconName"
/>
</div>
</div>
<p>
{{
icon
.
name
}}
</p>
<p>
{{
icon
.
name
}}
</p>
</div>
</div>
...
@@ -21,21 +21,63 @@
...
@@ -21,21 +21,63 @@
</
template
>
</
template
>
<
script
setup
>
<
script
setup
>
import
usePermissionStore
from
'@/store/modules/permission'
;
const
router
=
useRouter
();
const
router
=
useRouter
();
const
modules
=
[
const
permissionStore
=
usePermissionStore
();
{
const
modules
=
ref
([]);
// 替换原有的静态modules
title
:
'CP 活动'
,
// const modules = [
icons
:
[
// {
{
name
:
'促销计划'
,
iconName
:
'shop-o'
,
iconColor
:
'#5aaeec'
,
to
:
'/m/promotion_plan'
}
// title: 'CP 活动',
]
// icons: [
// { name: '促销计划', iconName: 'shop-o', iconColor: '#5aaeec', to: '/m/promotion_plan' }
// ]
// },
// {
// title: '稽核活动',
// icons: [
// { name: '售点稽查', iconName: 'manager-o', iconColor: '#feb73b', to: '/m/promotion_plan' }
// ]
// }
// ]
// 观察路由挂载后事件
// 格式化路由为菜单所需结构
const
formatRoutesToModules
=
(
routes
)
=>
{
// 根据实际路由结构转换,这里假设需要提取一级路由作为模块
modules
.
value
=
routes
[
0
].
children
.
map
(
o
=>
{
return
{
title
:
o
.
meta
.
title
,
icons
:
o
.
children
?.
map
(
child
=>
({
name
:
child
.
meta
.
title
,
iconName
:
child
.
meta
.
icon
||
'default'
,
iconColor
:
child
.
meta
.
color
||
'#5aaeec'
,
to
:
child
.
path
}))
||
[]
}
})
// .map(route => ({
// title: route.meta.title,
// icons: route.children?.map(child => ({
// name: child.meta.title,
// iconName: child.meta.icon || 'default',
// iconColor: child.meta.color || '#5aaeec',
// to: child.path
// })) || []
// }))
}
// 监听路由变化
watch
(
()
=>
permissionStore
.
sidebarRouters
,
(
newRoutes
)
=>
{
if
(
newRoutes
.
length
>
0
)
{
// 路由加载完成后转换格式
// 把 hidden: true 的筛选掉
const
filterRoutes
=
newRoutes
.
filter
(
route
=>
!
route
?.
hidden
);
formatRoutesToModules
(
filterRoutes
);
}
},
},
{
{
immediate
:
true
,
deep
:
true
}
title
:
'稽核活动'
,
);
icons
:
[
{
name
:
'售点稽查'
,
iconName
:
'manager-o'
,
iconColor
:
'#feb73b'
,
to
:
'/m/promotion_plan'
}
]
}
]
const
handleIconClick
=
(
icon
)
=>
{
const
handleIconClick
=
(
icon
)
=>
{
router
.
push
(
icon
.
to
)
router
.
push
(
icon
.
to
)
...
@@ -95,9 +137,9 @@ const handleIconClick = (icon) => {
...
@@ -95,9 +137,9 @@ const handleIconClick = (icon) => {
border-radius
:
50%
;
border-radius
:
50%
;
box-shadow
:
0
2px
12px
0
rgba
(
0
,
0
,
0
,
0
.1
);
box-shadow
:
0
2px
12px
0
rgba
(
0
,
0
,
0
,
0
.1
);
.
van
-icon
{
.
svg
-icon
{
color
:
white
;
color
:
white
;
font-size
:
22
px
;
font-size
:
16
px
;
}
}
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论