Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-sfa-ui
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-sfa-ui
Commits
c3f7190e
提交
c3f7190e
authored
4月 21, 2025
作者:
lidongxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(mobile): 重新设计移动端的缓存过程_重新定义路由路径分配方式
同上
上级
9f2e7c7a
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
63 行增加
和
55 行删除
+63
-55
README.md
README.md
+2
-2
App.vue
src/App.vue
+2
-15
index.vue
src/mobile/index.vue
+24
-0
index.vue
src/mobile/views/examine/index.vue
+0
-0
index.vue
src/mobile/views/promotion/plan/detail/index.vue
+2
-2
index.vue
src/mobile/views/promotion/plan/editing/index.vue
+0
-0
index.vue
src/mobile/views/promotion/plan/index/index.vue
+4
-4
index.js
src/router/index.js
+26
-27
index.vue
src/views/bi/competitor/index.vue
+3
-4
vite.config.js
vite.config.js
+0
-1
没有找到文件。
README.md
浏览文件 @
c3f7190e
<p>
王小卤
</p>
\ No newline at end of file
王小卤
\ No newline at end of file
src/App.vue
浏览文件 @
c3f7190e
<
template
>
<router-view
v-slot=
"
{ Component }">
<keep-alive
:include=
"cachedViews"
>
<component
:is=
"Component"
></component>
</keep-alive>
</router-view>
<back-to-up></back-to-up>
<router-view
/>
<back-to-up
/>
</
template
>
<
script
setup
>
import
useSettingsStore
from
'@/store/modules/settings'
import
{
handleThemeStyle
}
from
'@/utils/theme'
import
{
constantRoutes
}
from
'@/router'
onMounted
(()
=>
{
nextTick
(()
=>
{
// 初始化主题样式
handleThemeStyle
(
useSettingsStore
().
theme
)
})
})
const
cachedViews
=
ref
([])
constantRoutes
.
forEach
(
o
=>
{
// 暂时只缓存第一层
if
(
o
.
meta
?.
keepAlive
)
{
cachedViews
.
value
.
push
(
o
.
name
)
}
})
</
script
>
src/mobile/index.vue
0 → 100644
浏览文件 @
c3f7190e
<
template
>
<router-view
v-slot=
"
{ Component }">
<keep-alive
:include=
"cachedViews"
>
<component
:is=
"Component"
></component>
</keep-alive>
</router-view>
</
template
>
<
script
setup
>
import
{
constantMobileRoutes
}
from
'@/router'
// 递归判断有 children 往里走找到所有路由对象 meta 的 keepAlive 是 true 的然后返回 meta 同级的 name 名字的值,组成一个数组
const
cachedViews
=
[]
function
getKeepAliveName
(
routes
)
{
routes
.
forEach
((
item
)
=>
{
if
(
item
.
meta
?.
keepAlive
)
{
cachedViews
.
push
(
item
.
name
)
}
if
(
item
.
children
)
{
getKeepAliveName
(
item
.
children
)
}
})
}
getKeepAliveName
(
constantMobileRoutes
)
</
script
>
src/mobile
_views/promotion
/examine/index.vue
→
src/mobile
/views
/examine/index.vue
浏览文件 @
c3f7190e
File moved
src/mobile
_
views/promotion/plan/detail/index.vue
→
src/mobile
/
views/promotion/plan/detail/index.vue
浏览文件 @
c3f7190e
...
...
@@ -108,7 +108,7 @@ const newExamined = ref(0) // 没有默认创建的新的
const
planDetail
=
ref
({
}
)
const
planList
=
ref
([])
const
getPlanDetail
=
async
()
=>
{
const
res
=
await
getPlanDetailAPI
(
route
.
params
.
i
d
)
const
res
=
await
getPlanDetailAPI
(
route
.
params
.
planI
d
)
planDetail
.
value
=
res
.
data
.
planInfo
examined
.
value
=
res
.
data
.
examine
?.
id
...
...
@@ -222,7 +222,7 @@ const clickExamine = async () => {
}
newExamined
.
value
=
result
.
data
.
id
}
router
.
push
({
path
:
`/examine/${examined?.value || newExamined.value
}
`
}
)
router
.
push
({
path
:
`/
m/
examine/${examined?.value || newExamined.value
}
`
}
)
}
)
}
...
...
src/mobile
_views/promotion/plan/add-edit
.vue
→
src/mobile
/views/promotion/plan/editing/index
.vue
浏览文件 @
c3f7190e
File moved
src/mobile
_views/promotion/plan
/index.vue
→
src/mobile
/views/promotion/plan/index
/index.vue
浏览文件 @
c3f7190e
...
...
@@ -2,7 +2,7 @@
<div
class=
"mobile-container"
>
<van-nav-bar
right-text=
"搜索"
left-text=
"新增计划"
@
click-left=
"$router.push('/
promotion_add
')"
@
click-left=
"$router.push('/
m/promotion_plan_editing
')"
@
click-right=
"showSearch = true"
placeholder
fixed
/>
...
...
@@ -19,7 +19,7 @@
<van-swipe-cell
v-for=
"item in planList"
:key=
"item.id"
>
<van-cell
:title=
"item.storeName"
:to=
"`/
promotio
n_detail/$
{item.id}`">
:to=
"`/
m/promotion_pla
n_detail/$
{item.id}`">
<template
#
label
>
<p
class=
"employee"
>
{{
item
.
employeeName
}}
</p>
<p
v-if=
"item.planStatus === 0"
>
未执行
</p>
...
...
@@ -161,7 +161,7 @@
<
script
setup
>
// 指定当前组件的名字
defineOptions
({
name
:
'
Mobile_promotio
n'
name
:
'
m_promotion_pla
n'
}
)
import
{
parseTime
}
from
'@/utils'
import
{
useDatePickerOptions
}
from
'@/hooks'
...
...
@@ -372,7 +372,7 @@ const resetFn = () => {
// 编辑计划
const
editPlan
=
(
row
)
=>
{
router
.
push
(
`/
promotion_add
/${row.id
}
`
)
router
.
push
(
`/
m/promotion_plan_editing
/${row.id
}
`
)
}
// 删除计划
...
...
src/router/index.js
浏览文件 @
c3f7190e
...
...
@@ -84,39 +84,45 @@ export const constantPCRoutes = [
]
// 移动端 公共路由
export
const
constantMobileRoutes
=
[
{
path
:
'/'
,
redirect
:
'/promotion'
},
{
path
:
'/login'
,
component
:
()
=>
import
(
'@/views/login'
),
hidden
:
true
},
{
path
:
'/promotion'
,
component
:
()
=>
import
(
'@/mobile_views/promotion/plan/index'
),
name
:
'Mobile_promotion'
,
path
:
'/'
,
redirect
:
'/m'
},
{
path
:
'/m'
,
redirect
:
'/m/promotion_plan'
,
component
:
()
=>
import
(
'@/mobile/index'
),
hidden
:
true
,
children
:
[
// 促销计划
{
path
:
'promotion_plan'
,
// 列表
component
:
()
=>
import
(
'@/mobile/views/promotion/plan/index'
),
name
:
'm_promotion_plan'
,
meta
:
{
keepAlive
:
true
}
// 标记该路由需要缓存
},
{
path
:
'/promotion_detail/:id'
,
// 促销计划详情页
component
:
()
=>
import
(
'@/mobile_views/promotion/plan/detail'
),
name
:
'Detail'
,
hidden
:
true
,
path
:
'promotion_plan_detail/:planId'
,
// 详情
component
:
()
=>
import
(
'@/mobile/views/promotion/plan/detail'
),
name
:
'm_promotion_detail'
,
},
{
path
:
'/examine/:examineId'
,
// 稽查任务页
component
:
()
=>
import
(
'@/mobile_views/promotion/examine'
),
name
:
'Examine'
,
hidden
:
true
,
path
:
'promotion_plan_editing/:planId?'
,
// 增改
component
:
()
=>
import
(
'@/mobile/views/promotion/plan/editing'
),
name
:
'm_promotion_editing'
,
},
// 稽查
{
path
:
'/promotion_add/:planId?'
,
// 新增促销计划页
component
:
()
=>
import
(
'@/mobile_views/promotion/plan/add-edit'
),
name
:
'AddAndEdit'
,
hidden
:
true
,
path
:
'examine/:examineId'
,
component
:
()
=>
import
(
'@/mobile/views/examine'
),
name
:
'm_promotion_examine'
,
}
]
}
]
...
...
@@ -194,16 +200,9 @@ export const dynamicRoutes = [
}
]
// 判断移动端设置路由
if
(
isMobile
())
{
constantRoutes
=
constantMobileRoutes
}
else
{
constantRoutes
=
constantPCRoutes
}
const
router
=
createRouter
({
history
:
createWebHashHistory
(),
routes
:
[...
constantRoutes
],
routes
:
isMobile
()
?
[...
constantMobileRoutes
]
:
[...
constantPCRoutes
],
// 移动端单独静态公共路由表
scrollBehavior
(
to
,
from
,
savedPosition
)
{
if
(
savedPosition
)
{
return
savedPosition
...
...
src/views/bi/competitor/index.vue
浏览文件 @
c3f7190e
<
template
>
<div
class=
"app-container"
>
<div
class=
"container"
>
<el-tabs
v-model=
"activeName"
class=
"tabs"
>
<el-tabs
v-model=
"activeName"
class=
"tabs"
>
<el-tab-pane
v-for=
"item in list"
:label=
"item.name"
:name=
"item.name"
>
<keep-alive>
<component
:is=
"item.component"
></component>
</keep-alive>
</el-tab-pane>
</el-tabs>
</div>
...
...
@@ -32,7 +31,7 @@ provide('activeName', activeName);
lang=
"scss"
>
.app-container
{
.container
{
.container
{
display
:
flex
;
flex-direction
:
column
;
}
...
...
vite.config.js
浏览文件 @
c3f7190e
...
...
@@ -59,7 +59,6 @@ export default defineConfig(({ mode, command }) => {
},
pxtorem
({
rootValue
({
file
})
{
// ? 后面调整 vant 大小
return
37.5
;
},
propList
:
[
'*'
],
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论