Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
Support
提交反馈
为 GitLab 提交贡献
登录
切换导航
H
HY占座系统
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
刘英杰
HY占座系统
提交
fff2df76
提交
fff2df76
编写于
5月 16, 2024
作者:
刘英杰
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
V20240515 保存项目框架
上级
1801a486
流水线
#26091
已通过 ,包含阶段
in 4 minute 和 14 second
变更
4
流水线
1
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
59 行增加
和
4 行删除
+59
-4
App.vue
src/App.vue
+4
-1
index.js
src/router/index.js
+5
-0
index.js
src/store/index.js
+3
-3
user.js
src/store/modules/user.js
+47
-0
未找到文件。
src/App.vue
浏览文件 @
fff2df76
<
script
setup
>
<
script
setup
>
import
{
useUserInfo
,
useUserInfoStoreWithOut
}
from
"
@/store/modules/user.js
"
;
const
userInfo
=
useUserInfoStoreWithOut
()
const
userInfo1
=
useUserInfo
()
console
.
log
(
userInfo1
.
setUserInfo
({
A
:
1
}),
"
🚀🚀🚀,
"
,)
</
script
>
</
script
>
<
template
>
<
template
>
...
...
src/router/index.js
浏览文件 @
fff2df76
...
@@ -2,6 +2,10 @@ import {createRouter, createWebHashHistory} from 'vue-router'
...
@@ -2,6 +2,10 @@ import {createRouter, createWebHashHistory} from 'vue-router'
import
routes
from
"
./routes.js
"
;
import
routes
from
"
./routes.js
"
;
import
*
as
api
from
'
@/api/dist/controller/index.js
'
import
*
as
api
from
'
@/api/dist/controller/index.js
'
import
Cookies
from
'
js-cookie
'
import
Cookies
from
'
js-cookie
'
import
{
useUserInfo
,
useUserInfoStoreWithOut
}
from
"
@/store/modules/user.js
"
;
const
userInfo
=
useUserInfoStoreWithOut
()
const
userInfo1
=
useUserInfo
()
const
router
=
new
createRouter
({
const
router
=
new
createRouter
({
history
:
createWebHashHistory
(),
history
:
createWebHashHistory
(),
...
@@ -9,6 +13,7 @@ const router = new createRouter({
...
@@ -9,6 +13,7 @@ const router = new createRouter({
})
})
// 全局守卫:登录拦截 本地没有存token,请重新登录
// 全局守卫:登录拦截 本地没有存token,请重新登录
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
console
.
log
(
userInfo1
.
getUserInfo
(),
"
🚀🚀use12312rInfo🚀,
"
,)
if
(
to
.
meta
.
isAuth
&&
to
.
meta
.
admin
)
{
if
(
to
.
meta
.
isAuth
&&
to
.
meta
.
admin
)
{
if
(
Cookies
.
get
(
'
site-user-info
'
))
{
if
(
Cookies
.
get
(
'
site-user-info
'
))
{
next
()
next
()
...
...
src/store/index.js
浏览文件 @
fff2df76
import
{
createPinia
}
from
"
pinia
"
;
import
{
createPinia
}
from
"
pinia
"
;
import
piniaPluginPersistedstate
from
"
pinia-plugin-persistedstate
"
;
import
piniaPluginPersistedstate
from
"
pinia-plugin-persistedstate
"
;
const
store
=
createPinia
();
export
const
store
=
createPinia
();
store
.
use
(
piniaPluginPersistedstate
);
store
.
use
(
piniaPluginPersistedstate
);
const
initStore
=
(
app
)
=>
{
export
const
initStore
=
(
app
)
=>
{
app
.
use
(
store
);
app
.
use
(
store
);
};
};
export
{
store
,
initStore
};
src/store/modules/user.js
浏览文件 @
fff2df76
import
{
defineStore
}
from
"
pinia
"
;
import
{
store
}
from
"
@/store/index.js
"
;
/***
* 用户状态管理
* */
export
const
useUserInfo
=
defineStore
({
id
:
'
occupancyUserInfo
'
,
state
:
()
=>
({
tokenInfo
:
{
access_token
:
{
token_content
:
""
,
expires
:
""
,
},
refresh_token
:
{
token_content
:
""
,
expires
:
""
,
}
},
userInfo
:
{}
}),
actions
:
{
setToken
(
response
)
{
//设置token
this
.
tokenInfo
=
response
},
getToken
()
{
//获取token
return
this
.
tokenInfo
},
setUserInfo
(
response
)
{
//设置用户信息
this
.
userInfo
=
response
},
getUserInfo
()
{
//获取用户信息
return
this
.
userInfo
},
},
getters
:
{},
persist
:
{
paths
:
[
"
tokenInfo
"
,
"
userInfo
"
]
}
})
export
const
useUserInfoStoreWithOut
=
()
=>
{
return
useUserInfo
(
store
);
};
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录