From 8d45ba8885af755c12fc3e042630fa8b87d85b1c Mon Sep 17 00:00:00 2001
From: edgex
Date: Mon, 18 Mar 2024 12:06:10 +0800
Subject: [PATCH 1/2] feat: add user settings page
---
locales/zh-CN.yaml | 1 +
mock/region.ts | 52 +++++
mock/userInfo.ts | 21 ++
src/api/mock.ts | 5 +
src/api/user.ts | 19 ++
src/layout/components/navbar.vue | 10 +
src/layout/components/sidebar/horizontal.vue | 8 +-
src/layout/components/sidebar/mixNav.vue | 8 +-
src/layout/components/userSettings/index.vue | 64 ++++++
.../components/userSettings/safeManage.vue | 7 +
.../userSettings/userInfoManage.vue | 184 ++++++++++++++++++
src/layout/hooks/useNav.ts | 7 +-
src/router/modules/remaining.ts | 24 +++
13 files changed, 407 insertions(+), 3 deletions(-)
create mode 100644 mock/region.ts
create mode 100644 mock/userInfo.ts
create mode 100644 src/layout/components/userSettings/index.vue
create mode 100644 src/layout/components/userSettings/safeManage.vue
create mode 100644 src/layout/components/userSettings/userInfoManage.vue
diff --git a/locales/zh-CN.yaml b/locales/zh-CN.yaml
index 7af287541..ef8ad4f71 100644
--- a/locales/zh-CN.yaml
+++ b/locales/zh-CN.yaml
@@ -1,4 +1,5 @@
buttons:
+ hsUserSettings: 账户设置
hsLoginOut: 退出系统
hsfullscreen: 全屏
hsexitfullscreen: 退出全屏
diff --git a/mock/region.ts b/mock/region.ts
new file mode 100644
index 000000000..f7fa3cbf4
--- /dev/null
+++ b/mock/region.ts
@@ -0,0 +1,52 @@
+import { defineFakeRoute } from "vite-plugin-fake-server/client";
+
+export default defineFakeRoute([
+ {
+ url: "/get-regions",
+ method: "get",
+ response: () => {
+ return {
+ success: true,
+ data: [
+ {
+ code: "001",
+ name: "中国",
+ children: [
+ {
+ code: "001001",
+ name: "北京市",
+ children: [
+ {
+ code: "001001001",
+ name: "东城区"
+ },
+ {
+ code: "001001002",
+ name: "西城区"
+ }
+ // 其他区
+ ]
+ },
+ {
+ code: "001002",
+ name: "上海市",
+ children: [
+ {
+ code: "001002001",
+ name: "黄浦区"
+ },
+ {
+ code: "001002002",
+ name: "徐汇区"
+ }
+ // 其他区
+ ]
+ }
+ // 其他城市
+ ]
+ }
+ ]
+ };
+ }
+ }
+]);
diff --git a/mock/userInfo.ts b/mock/userInfo.ts
new file mode 100644
index 000000000..c1cc84a9a
--- /dev/null
+++ b/mock/userInfo.ts
@@ -0,0 +1,21 @@
+import { defineFakeRoute } from "vite-plugin-fake-server/client";
+
+export default defineFakeRoute([
+ {
+ url: "/get-user-info",
+ method: "get",
+ response: () => {
+ return {
+ success: true,
+ data: {
+ avatarUrl: "https://avatars.githubusercontent.com/u/44761321",
+ nickName: "企丸丸",
+ introduce: "我是幻兽帕鲁里的NO.1",
+ regionCode: "001002001",
+ address: "体育路冰鸟密域祭坛地下城",
+ userName: "admin"
+ }
+ };
+ }
+ }
+]);
diff --git a/src/api/mock.ts b/src/api/mock.ts
index 549e9d09b..61304822b 100644
--- a/src/api/mock.ts
+++ b/src/api/mock.ts
@@ -23,3 +23,8 @@ export const formUpload = data => {
}
);
};
+
+/**所在区域数据*/
+export const getRegions = (params?: object) => {
+ return http.request("get", "/get-regions", { params });
+};
diff --git a/src/api/user.ts b/src/api/user.ts
index 66a797cb9..4ae26ea74 100644
--- a/src/api/user.ts
+++ b/src/api/user.ts
@@ -28,6 +28,20 @@ export type RefreshTokenResult = {
};
};
+export type UserInfo = {
+ avatarUrl: string;
+ nickName: string;
+ introduce: string;
+ regionCode: string;
+ address: string;
+ userName: string;
+};
+
+export type UserInfoResult = {
+ success: boolean;
+ data: UserInfo;
+};
+
/** 登录 */
export const getLogin = (data?: object) => {
return http.request("post", "/login", { data });
@@ -37,3 +51,8 @@ export const getLogin = (data?: object) => {
export const refreshTokenApi = (data?: object) => {
return http.request("post", "/refresh-token", { data });
};
+
+/**获取个人信息 */
+export const getUserInfo = (data?: object) => {
+ return http.request("get", "/get-user-info", { data });
+};
diff --git a/src/layout/components/navbar.vue b/src/layout/components/navbar.vue
index 67774cc4f..2da8010ab 100644
--- a/src/layout/components/navbar.vue
+++ b/src/layout/components/navbar.vue
@@ -11,10 +11,13 @@ import globalization from "@/assets/svg/globalization.svg?component";
import LogoutCircleRLine from "@iconify-icons/ri/logout-circle-r-line";
import Setting from "@iconify-icons/ri/settings-3-line";
import Check from "@iconify-icons/ep/check";
+import UserSettingsLine from "@iconify-icons/ri/user-settings-line";
+
const {
layout,
device,
logout,
+ handleOpenUserSettings,
onPanel,
pureApp,
username,
@@ -91,6 +94,13 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
+
+
+ {{ t("buttons.hsUserSettings") }}
+
@@ -107,6 +109,10 @@ nextTick(() => {
{{ username }}
+
+
+ {{ t("buttons.hsUserSettings") }}
+
{{ username }}
+
+
+ {{ t("buttons.hsUserSettings") }}
+
+import { ref, onMounted, onBeforeUnmount } from "vue";
+import { useNav } from "@/layout/hooks/useNav";
+import leftLine from "@iconify-icons/ri/arrow-left-s-line";
+import userLine from "@iconify-icons/ri/user-3-line";
+import profileLine from "@iconify-icons/ri/profile-line";
+import { useRoute, useRouter } from "vue-router";
+import { getUserInfo } from "@/api/user";
+const route = useRoute();
+const router = useRouter();
+const { userAvatar, getLogo, username } = useNav();
+const defaultActive = ref(route.path as string);
+const userInfo = ref({
+ nickName: "",
+ avatarUrl: "",
+ userName: ""
+});
+getUserInfo().then(res => {
+ userInfo.value = res.data;
+});
+const handleBack = () => {
+ router.go(-1);
+};
+
+
+
+
+
+
+
+
+
+ 返回
+
+
+
+
+
+
+
{{ userInfo.nickName }}
+
{{ userInfo.userName }}
+
+
+
+
+ 基本设置
+
+
+
+ 安全设置
+
+
+
+
+
+
+
+
+
+
diff --git a/src/layout/components/userSettings/safeManage.vue b/src/layout/components/userSettings/safeManage.vue
new file mode 100644
index 000000000..c016f4df3
--- /dev/null
+++ b/src/layout/components/userSettings/safeManage.vue
@@ -0,0 +1,7 @@
+
+
+
+
+ 安全设置
+
+
diff --git a/src/layout/components/userSettings/userInfoManage.vue b/src/layout/components/userSettings/userInfoManage.vue
new file mode 100644
index 000000000..61e987c43
--- /dev/null
+++ b/src/layout/components/userSettings/userInfoManage.vue
@@ -0,0 +1,184 @@
+
+
+
+
+ 基本信息
+
+
+
+
+
+
+ 更新头像
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 更新基本信息
+
+
+
+
+
+
+
+
+
+
diff --git a/src/layout/hooks/useNav.ts b/src/layout/hooks/useNav.ts
index 4b40833a4..e51e40fda 100644
--- a/src/layout/hooks/useNav.ts
+++ b/src/layout/hooks/useNav.ts
@@ -99,6 +99,10 @@ export function useNav() {
emitter.emit("openPanel");
}
+ function handleOpenUserSettings() {
+ router.push({ name: "UserInfoManage" });
+ }
+
function toggleSideBar() {
pureApp.toggleSideBar();
}
@@ -160,6 +164,7 @@ export function useNav() {
avatarsStyle,
tooltipEffect,
getDropdownItemStyle,
- getDropdownItemClass
+ getDropdownItemClass,
+ handleOpenUserSettings
};
}
diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts
index 0fcf6c552..afc0abcc8 100644
--- a/src/router/modules/remaining.ts
+++ b/src/router/modules/remaining.ts
@@ -38,5 +38,29 @@ export default [
showLink: false,
rank: 103
}
+ },
+ {
+ path: "/user-settings",
+ name: "UserSettings",
+ component: () => import("@/layout/components/userSettings/index.vue"),
+ meta: {
+ title: $t("buttons.hsUserSettings"),
+ showLink: false,
+ rank: 103
+ },
+ children: [
+ {
+ path: "user-info-manage",
+ name: "UserInfoManage",
+ component: () =>
+ import("@/layout/components/userSettings/userInfoManage.vue")
+ },
+ {
+ path: "safe-manage",
+ name: "SafeManage",
+ component: () =>
+ import("@/layout/components/userSettings/safeManage.vue")
+ }
+ ]
}
] satisfies Array;
From 42617902582aebc8d9ce0fe9cff9e7dce9fbb24b Mon Sep 17 00:00:00 2001
From: edgex
Date: Mon, 18 Mar 2024 13:01:36 +0800
Subject: [PATCH 2/2] wip: dev safe-manage in user-settings module
---
.../components/userSettings/safeManage.vue | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/src/layout/components/userSettings/safeManage.vue b/src/layout/components/userSettings/safeManage.vue
index c016f4df3..581cc50e7 100644
--- a/src/layout/components/userSettings/safeManage.vue
+++ b/src/layout/components/userSettings/safeManage.vue
@@ -3,5 +3,54 @@
安全设置
+
+
+
+
+
密保手机
+
+ 已经绑定手机:138****1234
+
+
+
+ 修改
+
+
+
+
+
+
密保问题
+
+
+ 未设置密保问题,密保问题可有效保护账户安全
+
+
+
+
+ 设置
+
+
+
+
+
+
备用邮箱
+
+ 已绑定邮箱:ant***sign.com
+
+
+
+ 修改
+
+