Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
basic-uniapp-v3
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-uniapp-v3
Commits
1a838b31
提交
1a838b31
authored
11月 03, 2025
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修复接口配置、退出登录后校验登录信息引起的错误
上级
12722441
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
52 行增加
和
29 行删除
+52
-29
.env.development
.env.development
+1
-1
App.vue
src/App.vue
+1
-15
manifest.json
src/manifest.json
+0
-0
login.vue
src/pages/login/login.vue
+11
-7
shouye.vue
src/pages/shouye/shouye.vue
+21
-0
user.ts
src/store/modules/user.ts
+16
-5
index.ts
src/utils/http/axios/index.ts
+2
-1
没有找到文件。
.env.development
浏览文件 @
1a838b31
...
...
@@ -3,4 +3,4 @@ VITE_GLOB_API_URL=http://111.22.182.169:49600
# VITE_GLOB_API_URL=http://36.133.16.81:42111
# API 接口地址前缀
VITE_GLOB_API_URL_PREFIX=/jeecg
-
boot
VITE_GLOB_API_URL_PREFIX=/jeecgboot
src/App.vue
浏览文件 @
1a838b31
...
...
@@ -2,12 +2,6 @@
import
{
onExit
}
from
'@dcloudio/uni-app'
import
{
isDevMode
}
from
'@/utils/env'
import
{
usePermissions
}
from
'@/hooks/app/usePermissions'
import
*
as
UserInfoAPI
from
'@/api/model/userInfo'
import
{
useDictStore
}
from
'@/store/modules/dict'
import
{
useUserStore
}
from
'@/store/modules/user'
const
userStore
=
useUserStore
()
const
dictStore
=
useDictStore
()
// import * as Push from '@/utils/push'
...
...
@@ -35,13 +29,6 @@
}
// #endif
})
function
getDictList
()
{
if
(
!
userStore
.
getToken
)
return
if
(
Object
.
keys
(
dictStore
.
getDictList
).
length
!==
0
)
return
UserInfoAPI
.
dictList
().
then
((
res
)
=>
{
dictStore
.
setDictList
(
res
)
})
}
onExit
(()
=>
{
// 停用监听权限
...
...
@@ -50,7 +37,6 @@
onShow
(()
=>
{
console
.
log
(
'App Show'
)
getDictList
()
})
onHide
(()
=>
{
...
...
@@ -58,7 +44,7 @@
})
onError
((
err
)
=>
{
//
Message.toast(`App Error: ${err}`)
Message
.
toast
(
`App Error:
${
err
}
`
)
console
.
error
(
'App Error:'
,
err
)
})
...
...
src/manifest.json
浏览文件 @
1a838b31
差异被折叠。
点击展开。
src/pages/login/login.vue
浏览文件 @
1a838b31
...
...
@@ -8,7 +8,7 @@
const
userStore
=
useUserStore
()
on
Load
(
async
()
=>
{
on
Show
(
async
()
=>
{
// 获取推送标识并设置 PushClientId 缓存
// uni.getPushClientId({
// success: (res) => {
...
...
@@ -37,6 +37,7 @@
// 跳转到登录页
goHome
()
Message
.
toast
(
`欢迎回来~`
)
}
else
{
// 关闭启动页并检查更新
try
{
...
...
@@ -59,7 +60,7 @@
show
:
false
,
isLogin
:
false
,
loading
:
false
,
text
:
''
,
text
:
defaultText
,
form
:
{
rules
:
[
{
...
...
@@ -128,7 +129,7 @@
// 打开登录页
goHome
()
Message
.
toast
(
`登录成功, 欢迎回来
!
`
)
Message
.
toast
(
`登录成功, 欢迎回来
~
`
)
}
else
{
Message
.
toast
(
body
.
message
)
return
false
...
...
@@ -153,7 +154,7 @@
// 添加欢迎登录的文字打字动态效果
let
loop
=
null
let
direction
=
'right'
const
count
=
ref
(
0
)
const
count
=
ref
(
defaultText
.
length
)
watch
(
()
=>
model
.
show
,
(
show
)
=>
{
...
...
@@ -185,9 +186,12 @@
},
)
onUnload
(()
=>
{
model
.
show
=
false
onHide
(()
=>
{
loop
&&
clearInterval
(
loop
)
loop
=
null
direction
=
'right'
count
.
value
=
0
model
.
show
=
false
})
function
onReadConfirm
(
val
)
{
...
...
@@ -392,7 +396,7 @@
//
position
:
absolute
;
//
left
:
40
rpx
;
//
bottom
:
40
rpx
;
font-size
:
40
rpx
;
font-size
:
38
rpx
;
color
:
#474747
;
display
:
flex
;
flex-direction
:
column
;
...
...
src/pages/shouye/shouye.vue
浏览文件 @
1a838b31
...
...
@@ -5,6 +5,12 @@
import
{
closeSplashscreenAndChechUpgrade
}
from
'@/utils/upgrade'
import
*
as
WeatherAPI
from
'@/api/model/weather'
import
*
as
HomeAPI
from
'@/api/model/home'
import
*
as
UserInfoAPI
from
'@/api/model/userInfo'
import
{
useDictStore
}
from
'@/store/modules/dict'
import
{
useUserStore
}
from
'@/store/modules/user'
const
userStore
=
useUserStore
()
const
dictStore
=
useDictStore
()
const
model
=
reactive
({
// 湖南省人民政府
...
...
@@ -47,6 +53,9 @@
},
})
// 获取字典数据
getDictList
()
// 查询金刚区数据
getServiceItems
()
getMenuItems
()
...
...
@@ -106,6 +115,18 @@
})
}
function
getDictList
()
{
if
(
!
userStore
.
getToken
)
{
return
}
if
(
Object
.
keys
(
dictStore
.
getDictList
).
length
!==
0
)
{
return
}
UserInfoAPI
.
dictList
().
then
((
res
)
=>
{
dictStore
.
setDictList
(
res
)
})
}
// 页面数据
const
pageData
=
reactive
({
// 顶部标题和搜索
...
...
src/store/modules/user.ts
浏览文件 @
1a838b31
import
{
defineStore
}
from
'pinia'
import
{
store
}
from
'/@/store'
import
{
useDictStore
}
from
'./dict'
import
{
Storage
}
from
'@/utils/storage'
import
{
TOKEN_KEY
,
USER_INFO_KEY
}
from
'@/enums/cacheEnum'
import
Navigate
from
'@/utils/page/navigate'
import
*
as
API
from
'/@/api/model/userInfo'
import
{
useDictStore
}
from
'./dict'
export
interface
UserInfo
{
id
:
string
...
...
@@ -37,6 +36,8 @@ export const useUserStore = defineStore({
this
.
token
=
token
return
token
}
return
null
},
getUserInfo
():
Nullable
<
UserInfo
>
{
if
(
this
.
userInfo
)
{
...
...
@@ -62,11 +63,19 @@ export const useUserStore = defineStore({
actions
:
{
setToken
(
token
:
string
)
{
this
.
token
=
token
Storage
.
set
(
TOKEN_KEY
,
token
)
if
(
!
token
)
{
Storage
.
remove
(
TOKEN_KEY
)
}
else
{
Storage
.
set
(
TOKEN_KEY
,
token
)
}
},
setUserInfo
(
info
:
UserInfo
)
{
this
.
userInfo
=
info
Storage
.
set
(
USER_INFO_KEY
,
info
?
JSON
.
stringify
(
info
)
:
null
)
if
(
!
info
)
{
Storage
.
remove
(
USER_INFO_KEY
)
}
else
{
Storage
.
set
(
USER_INFO_KEY
,
info
?
JSON
.
stringify
(
info
)
:
null
)
}
},
async
logout
()
{
if
(
this
.
loading
)
{
...
...
@@ -84,8 +93,10 @@ export const useUserStore = defineStore({
const
dictStore
=
useDictStore
(
store
)
dictStore
.
clearDict
()
await
Navigate
.
to
(
'/pages/login/login'
)
this
.
loading
=
false
uni
.
reLaunch
({
url
:
'/pages/login/login'
,
})
}
},
async
refreshUserInfo
()
{
...
...
src/utils/http/axios/index.ts
浏览文件 @
1a838b31
...
...
@@ -48,8 +48,9 @@ const transform: AxiosTransform = {
// 错误的时候返回
const
{
data
}
=
res
if
(
!
data
)
{
if
(
!
data
||
typeof
data
!==
'object'
)
{
// return '[HTTP] Request has no return value';
// Message.toast(`${JSON.stringify(options)} --- ${res.data}`)
throw
new
Error
(
t
(
'sys.api.apiRequestFailed'
))
}
// 这里 status,body,message为 后台统一的字段,需要在 types.ts 内修改为项目自己的接口返回格式
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论