fix: app 打包失败BUG

This commit is contained in:
Burt
2024-01-19 17:28:04 +08:00
parent 2e3c18f9a6
commit 7ba6f95b53
7 changed files with 203 additions and 9 deletions

View File

@@ -34,7 +34,10 @@
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
],
"minSdkVersion": 30,
"targetSdkVersion": 30,
"abiFilters": ["armeabi-v7a", "arm64-v8a"]
},
"ios": {},
"sdkConfigs": {},

View File

@@ -29,6 +29,12 @@
"pagePath": "pages/index/index",
"text": "首页"
},
{
"iconPath": "static/tabbar/example.png",
"selectedIconPath": "static/tabbar/exampleHL.png",
"pagePath": "pages/demo/index",
"text": "示例"
},
{
"iconPath": "static/tabbar/personal.png",
"selectedIconPath": "static/tabbar/personalHL.png",
@@ -45,6 +51,10 @@
"navigationBarTitleText": "首页"
}
},
{
"path": "pages/demo/index",
"type": "page"
},
{
"path": "pages/login/index",
"type": "page",
@@ -58,6 +68,151 @@
"style": {
"navigationBarTitleText": "我的"
}
},
{
"path": "pages/demo/demo/clock",
"type": "page",
"style": {
"navigationBarTitleText": "动态时钟"
}
},
{
"path": "pages/demo/demo/component-auto-import",
"type": "page",
"style": {
"navigationBarTitleText": "easycom 自动导入"
}
},
{
"path": "pages/demo/demo/lottery",
"type": "page",
"style": {
"navigationBarTitleText": "九宫格抽奖"
}
},
{
"path": "pages/demo/demo/lottery2",
"type": "page",
"style": {
"navigationBarTitleText": "大转盘抽奖"
}
},
{
"path": "pages/demo/demo/mp-weixin-share",
"type": "page",
"style": {
"navigationBarTitleText": "微信分享"
}
},
{
"path": "pages/demo/demo/navbar",
"type": "page",
"style": {
"navigationBarTitleText": "自定义导航栏",
"navigationStyle": "custom"
}
},
{
"path": "pages/demo/demo/pages-auto-import",
"type": "page",
"style": {
"navigationBarTitleText": "pages 自动导入"
}
},
{
"path": "pages/demo/demo/pinia",
"type": "page",
"layout": "display",
"style": {
"navigationBarTitleText": "pinia+持久化"
}
},
{
"path": "pages/demo/demo/request",
"type": "page",
"style": {
"navigationBarTitleText": "request请求+请求拦截"
}
},
{
"path": "pages/demo/demo/throughout",
"type": "page",
"style": {
"navigationBarTitleText": "通屏+下拉刷新+自定义导航栏",
"enablePullDownRefresh": false,
"backgroundColor": "#23c09c",
"app-plus": {
"titleNView": {
"type": "transparent"
}
},
"mp-weixin": {
"navigationStyle": "custom"
}
}
},
{
"path": "pages/demo/demo/uni-ui-icons",
"type": "page",
"style": {
"navigationBarTitleText": "UniUI Icons 使用"
}
},
{
"path": "pages/demo/demo/uni-ui",
"type": "page",
"style": {
"navigationBarTitleText": "UniUI 使用"
}
},
{
"path": "pages/demo/demo/unocss-icons",
"type": "page",
"style": {
"navigationBarTitleText": "UnoCss Icons 使用"
}
},
{
"path": "pages/demo/demo/unocss",
"type": "page",
"style": {
"navigationBarTitleText": "UnoCss 使用"
}
},
{
"path": "pages/demo/demo/img-min/index",
"type": "page"
},
{
"path": "pages/demo/demo/lottery/big-wheel",
"type": "page",
"style": {
"navigationBarTitleText": "大转盘抽奖"
}
},
{
"path": "pages/demo/demo/lottery/nine-grid",
"type": "page",
"style": {
"navigationBarTitleText": "九宫格抽奖"
}
},
{
"path": "pages/demo/demo/throughout/index",
"type": "page",
"style": {
"navigationBarTitleText": "通屏+下拉刷新+自定义导航栏",
"enablePullDownRefresh": true,
"backgroundColor": "#23c09c",
"app-plus": {
"titleNView": {
"type": "transparent"
}
},
"mp-weixin": {
"navigationStyle": "custom"
}
}
}
],
"subPackages": []

1
src/typings.d.ts vendored
View File

@@ -1,6 +1,7 @@
export type UserInfo = {
nickname: string
avatar: string
token?: string
}
export type UserItem = {
username: string

View File

@@ -2,7 +2,6 @@
import { useUserStore } from '@/store'
import { UserInfo } from '@/typings'
const userStore = useUserStore()
type Data<T> = {
code: number
msg: string
@@ -29,6 +28,7 @@ const httpInterceptor = {
...options.header,
}
// 4. 添加 token 请求头标识
const userStore = useUserStore()
const { token } = userStore.userInfo as unknown as UserInfo
if (token) {
options.header.Authorization = `Bearer ${token}`
@@ -54,8 +54,8 @@ export const http = <T>(options: UniApp.RequestOptions) => {
resolve(res.data as Data<T>)
} else if (res.statusCode === 401) {
// 401错误 -> 清理用户信息,跳转到登录页
userStore.clearUserInfo()
uni.navigateTo({ url: '/pages/login/login' })
// userStore.clearUserInfo()
// uni.navigateTo({ url: '/pages/login/login' })
reject(res)
} else {
// 其他错误 -> 根据后端错误信息轻提示