wip: 🚧 个人中心临时提交
This commit is contained in:
@@ -21,6 +21,7 @@ module.exports = {
|
|||||||
"ci", // 修改 CI 配置、脚本
|
"ci", // 修改 CI 配置、脚本
|
||||||
"revert", // 回滚 commit
|
"revert", // 回滚 commit
|
||||||
"chore", // 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)
|
"chore", // 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)
|
||||||
|
"wip", // 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
"subject-case": [0], // subject大小写不做校验
|
"subject-case": [0], // subject大小写不做校验
|
||||||
|
|||||||
@@ -136,6 +136,23 @@ class UserAPI {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取个人中心用户信息 */
|
||||||
|
static getProfile(id: number) {
|
||||||
|
return request<any, UserProfileVO>({
|
||||||
|
url: `${USER_BASE_URL}/${id}/profile`,
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改个人中心用户信息 */
|
||||||
|
static updateProfile(id: number, data: UserProfileForm) {
|
||||||
|
return request({
|
||||||
|
url: `${USER_BASE_URL}/${id}/profile`,
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UserAPI;
|
export default UserAPI;
|
||||||
@@ -143,7 +160,7 @@ export default UserAPI;
|
|||||||
/** 登录用户信息 */
|
/** 登录用户信息 */
|
||||||
export interface UserInfo {
|
export interface UserInfo {
|
||||||
/** 用户ID */
|
/** 用户ID */
|
||||||
userId?: number;
|
userId: number;
|
||||||
|
|
||||||
/** 用户名 */
|
/** 用户名 */
|
||||||
username?: string;
|
username?: string;
|
||||||
@@ -227,3 +244,51 @@ export interface UserForm {
|
|||||||
/** 用户名 */
|
/** 用户名 */
|
||||||
username?: string;
|
username?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 个人中心用户信息 */
|
||||||
|
export interface UserProfileVO {
|
||||||
|
/** 用户ID */
|
||||||
|
id?: number;
|
||||||
|
|
||||||
|
/** 用户名 */
|
||||||
|
username?: string;
|
||||||
|
|
||||||
|
/** 昵称 */
|
||||||
|
nickname?: string;
|
||||||
|
|
||||||
|
/** 头像URL */
|
||||||
|
avatar?: string;
|
||||||
|
|
||||||
|
/** 性别 */
|
||||||
|
gender?: number;
|
||||||
|
|
||||||
|
/** 手机号 */
|
||||||
|
mobile?: string;
|
||||||
|
|
||||||
|
/** 邮箱 */
|
||||||
|
email?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 个人中心用户信息表单 */
|
||||||
|
export interface UserProfileForm {
|
||||||
|
/** 用户ID */
|
||||||
|
id?: number;
|
||||||
|
|
||||||
|
/** 用户名 */
|
||||||
|
username?: string;
|
||||||
|
|
||||||
|
/** 昵称 */
|
||||||
|
nickname?: string;
|
||||||
|
|
||||||
|
/** 头像URL */
|
||||||
|
avatar?: string;
|
||||||
|
|
||||||
|
/** 性别 */
|
||||||
|
gender?: number;
|
||||||
|
|
||||||
|
/** 手机号 */
|
||||||
|
mobile?: string;
|
||||||
|
|
||||||
|
/** 邮箱 */
|
||||||
|
email?: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -77,6 +77,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item divided @click="handleOpenUserProfile">
|
||||||
|
{{ $t("navbar.profile") }}
|
||||||
|
</el-dropdown-item>
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://gitee.com/youlaiorg/vue3-element-admin"
|
href="https://gitee.com/youlaiorg/vue3-element-admin"
|
||||||
@@ -166,6 +169,11 @@ const getFilteredMessages = (type: MessageTypeEnum) => {
|
|||||||
return messages.value.filter((message) => message.type === type);
|
return messages.value.filter((message) => message.type === type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** 打开个人中心 */
|
||||||
|
function handleOpenUserProfile() {
|
||||||
|
router.push({ name: "Profile" });
|
||||||
|
}
|
||||||
|
|
||||||
/* 注销 */
|
/* 注销 */
|
||||||
function logout() {
|
function logout() {
|
||||||
ElMessageBox.confirm("确定注销并退出系统吗?", "提示", {
|
ElMessageBox.confirm("确定注销并退出系统吗?", "提示", {
|
||||||
|
|||||||
@@ -5,8 +5,9 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="mb-[20px]"
|
class="mb-[20px]"
|
||||||
>示例源码 请点击>>>></el-link
|
|
||||||
>
|
>
|
||||||
|
示例源码 请点击>>>>
|
||||||
|
</el-link>
|
||||||
<el-row :gutter="10">
|
<el-row :gutter="10">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-card>
|
<el-card>
|
||||||
@@ -18,21 +19,23 @@
|
|||||||
class="ml-5"
|
class="ml-5"
|
||||||
@click="connectWebSocket"
|
@click="connectWebSocket"
|
||||||
:disabled="isConnected"
|
:disabled="isConnected"
|
||||||
>连接</el-button
|
|
||||||
>
|
>
|
||||||
|
连接
|
||||||
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="disconnectWebSocket"
|
@click="disconnectWebSocket"
|
||||||
:disabled="!isConnected"
|
:disabled="!isConnected"
|
||||||
>断开</el-button
|
|
||||||
>
|
>
|
||||||
|
断开
|
||||||
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="8" class="text-right">
|
<el-col :span="8" class="text-right">
|
||||||
连接状态:
|
连接状态:
|
||||||
<el-tag class="ml-2" type="success" v-if="isConnected"
|
<el-tag class="ml-2" type="success" v-if="isConnected">
|
||||||
>已连接</el-tag
|
已连接
|
||||||
>
|
</el-tag>
|
||||||
<el-tag class="ml-2" type="info" v-else>已断开</el-tag>
|
<el-tag class="ml-2" type="info" v-else>已断开</el-tag>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -59,9 +62,9 @@
|
|||||||
<el-input v-model="receiver" />
|
<el-input v-model="receiver" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button @click="sendToUser" type="primary"
|
<el-button @click="sendToUser" type="primary">
|
||||||
>发送点对点消息</el-button
|
发送点对点消息
|
||||||
>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="profile-page">
|
<div class="profile-page">
|
||||||
<el-card>
|
<el-card>
|
||||||
<el-avatar :src="user.avatar" size="large" />
|
<el-avatar :src="userProfile.avatar" size="large" />
|
||||||
<div class="profile-info">
|
<div class="profile-info">
|
||||||
<h2>{{ user.name }}</h2>
|
<h2>{{ userProfile.username }}</h2>
|
||||||
<p>{{ user.email }}</p>
|
<h2>{{ userProfile.nickname }}</h2>
|
||||||
|
<p>{{ userProfile.email }}</p>
|
||||||
<el-button type="primary" @click="goToEdit">编辑个人信息</el-button>
|
<el-button type="primary" @click="goToEdit">编辑个人信息</el-button>
|
||||||
<el-button @click="goToChangePassword">修改密码</el-button>
|
<el-button @click="goToChangePassword">修改密码</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -13,16 +14,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive } from "vue";
|
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
import UserAPI, { UserProfileVO, UserProfileForm } from "@/api/user";
|
||||||
|
import { useUserStore } from "@/store/modules/user";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const user = reactive({
|
const userProfile = ref<UserProfileVO>({});
|
||||||
name: "张三",
|
|
||||||
email: "zhangsan@example.com",
|
|
||||||
avatar: "https://example.com/avatar.jpg",
|
|
||||||
});
|
|
||||||
|
|
||||||
const goToEdit = () => {
|
const goToEdit = () => {
|
||||||
router.push({ name: "ProfileEdit" });
|
router.push({ name: "ProfileEdit" });
|
||||||
@@ -31,6 +30,11 @@ const goToEdit = () => {
|
|||||||
const goToChangePassword = () => {
|
const goToChangePassword = () => {
|
||||||
router.push({ name: "ChangePassword" });
|
router.push({ name: "ChangePassword" });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const data = await UserAPI.getProfile(userStore.user.userId);
|
||||||
|
userProfile.value = data;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@@ -44,15 +48,6 @@ const goToChangePassword = () => {
|
|||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
|
||||||
margin: 0 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
color: #888;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-card {
|
.el-card {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
|||||||
"element-plus/es/components/badge/style/css",
|
"element-plus/es/components/badge/style/css",
|
||||||
"element-plus/es/components/steps/style/css",
|
"element-plus/es/components/steps/style/css",
|
||||||
"element-plus/es/components/step/style/css",
|
"element-plus/es/components/step/style/css",
|
||||||
|
"element-plus/es/components/avatar/style/cs",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
// 构建配置
|
// 构建配置
|
||||||
|
|||||||
Reference in New Issue
Block a user