From 1747357e8b066f1fb3939b43964478b821799891 Mon Sep 17 00:00:00 2001
From: feige996 <1020102647@qq.com>
Date: Thu, 21 Aug 2025 15:50:35 +0800
Subject: [PATCH] =?UTF-8?q?feat(=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83):=20?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=E5=8F=8A=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 新增个人中心页面,包含用户信息展示、头像上传、登录/退出功能
- 更新路由配置和底部导航栏以支持个人中心页面
- 修改登录跳转路径从'/pages/common/login/index'到'/pages/login/login'
- 在cSpell字典中添加'chooseavatar'单词
- 更新tsconfig.json包含package.json文件
---
.vscode/settings.json | 1 +
src/http/alova.ts | 2 +-
src/pages.json | 13 +++
src/pages/me/me.vue | 219 ++++++++++++++++++++++++++++++++++++++++++
src/tabbar/config.ts | 23 +++--
src/utils/index.ts | 10 +-
tsconfig.json | 1 +
7 files changed, 255 insertions(+), 14 deletions(-)
create mode 100644 src/pages/me/me.vue
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 4fbb64b..020efc6 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -71,6 +71,7 @@
"cSpell.words": [
"alova",
"Aplipay",
+ "chooseavatar",
"climblee",
"commitlint",
"dcloudio",
diff --git a/src/http/alova.ts b/src/http/alova.ts
index 005b54b..06b7f2f 100644
--- a/src/http/alova.ts
+++ b/src/http/alova.ts
@@ -30,7 +30,7 @@ const { onAuthRequired, onResponseRefreshToken } = createServerTokenAuthenticati
}
catch (error) {
// 切换到登录页
- await uni.reLaunch({ url: '/pages/common/login/index' })
+ await uni.reLaunch({ url: '/pages/login/login' })
throw error
}
},
diff --git a/src/pages.json b/src/pages.json
index c2254af..89267e8 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -36,6 +36,12 @@
"selectedIconPath": "static/tabbar/exampleHL.png",
"pagePath": "pages/about/about",
"text": "关于"
+ },
+ {
+ "iconPath": "static/tabbar/personal.png",
+ "selectedIconPath": "static/tabbar/personalHL.png",
+ "pagePath": "pages/me/me",
+ "text": "个人"
}
]
},
@@ -88,6 +94,13 @@
"style": {
"navigationBarTitleText": "注册"
}
+ },
+ {
+ "path": "pages/me/me",
+ "type": "page",
+ "style": {
+ "navigationBarTitleText": "我的"
+ }
}
],
"subPackages": [
diff --git a/src/pages/me/me.vue b/src/pages/me/me.vue
new file mode 100644
index 0000000..67fce5c
--- /dev/null
+++ b/src/pages/me/me.vue
@@ -0,0 +1,219 @@
+
+{
+ style: {
+ navigationBarTitleText: '我的',
+ },
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ userInfo.username }}
+
+
+
+ ID: {{ userInfo.id }}
+
+
+
+
+
+ {{ JSON.stringify(userInfo, null, 2) }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/tabbar/config.ts b/src/tabbar/config.ts
index 8a28010..9fde129 100644
--- a/src/tabbar/config.ts
+++ b/src/tabbar/config.ts
@@ -38,6 +38,12 @@ export const nativeTabbarList: NativeTabBarItem[] = [
pagePath: 'pages/about/about',
text: '关于',
},
+ {
+ iconPath: 'static/tabbar/personal.png',
+ selectedIconPath: 'static/tabbar/personalHL.png',
+ pagePath: 'pages/me/me',
+ text: '个人',
+ },
]
export interface CustomTabBarItem {
@@ -71,17 +77,18 @@ export const customTabbarList: CustomTabBarItem[] = [
icon: 'i-carbon-code',
// badge: 10,
},
-
- // {
- // pagePath: 'pages/mine/index',
- // text: '我的',
- // // 注意 iconfont 图标需要额外加上 'iconfont',如下
- // iconType: 'iconfont',
- // icon: 'iconfont icon-my',
- // },
+ {
+ pagePath: 'pages/me/me',
+ text: '我的',
+ iconType: 'uniUi',
+ icon: 'contact',
+ },
// {
// pagePath: 'pages/index/index',
// text: '首页',
+ // 注意 iconfont 图标需要额外加上 'iconfont',如下
+ // iconType: 'iconfont',
+ // icon: 'iconfont icon-my',
// // 使用 ‘image’时,需要配置 icon + iconActive 2张图片(不推荐)
// // 既然已经用了自定义tabbar了,就不建议用图片了,所以不推荐
// iconType: 'image',
diff --git a/src/utils/index.ts b/src/utils/index.ts
index e0d28c5..9ef3987 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -12,7 +12,7 @@ export function getLastPage() {
/**
* 获取当前页面路由的 path 路径和 redirectPath 路径
- * path 如 '/pages/login/index'
+ * path 如 '/pages/login/login'
* redirectPath 如 '/pages/demo/base/route-interceptor'
*/
export function currRoute() {
@@ -25,8 +25,8 @@ export function currRoute() {
// 经过多端测试,只有 fullPath 靠谱,其他都不靠谱
const { fullPath } = currRoute as { fullPath: string }
// console.log(fullPath)
- // eg: /pages/login/index?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor (小程序)
- // eg: /pages/login/index?redirect=%2Fpages%2Froute-interceptor%2Findex%3Fname%3Dfeige%26age%3D30(h5)
+ // eg: /pages/login/login?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor (小程序)
+ // eg: /pages/login/login?redirect=%2Fpages%2Froute-interceptor%2Findex%3Fname%3Dfeige%26age%3D30(h5)
return getUrlObj(fullPath)
}
@@ -38,8 +38,8 @@ export function ensureDecodeURIComponent(url: string) {
}
/**
* 解析 url 得到 path 和 query
- * 比如输入url: /pages/login/index?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor
- * 输出: {path: /pages/login/index, query: {redirect: /pages/demo/base/route-interceptor}}
+ * 比如输入url: /pages/login/login?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor
+ * 输出: {path: /pages/login/login, query: {redirect: /pages/demo/base/route-interceptor}}
*/
export function getUrlObj(url: string) {
const [path, queryStr] = url.split('?')
diff --git a/tsconfig.json b/tsconfig.json
index c95ea2f..0a76bae 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -29,6 +29,7 @@
"plugins": ["@uni-helper/uni-types/volar-plugin"]
},
"include": [
+ "package.json",
"src/**/*.ts",
"src/**/*.js",
"src/**/*.d.ts",