ProfileView.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <WorkerLayout>
  3. <div class="profile-view">
  4. <!-- 用户信息卡片 -->
  5. <a-card>
  6. <div class="user-info">
  7. <a-avatar size="large" class="user-avatar">
  8. {{ authStore.user?.name?.charAt(0) }}
  9. </a-avatar>
  10. <div class="user-detail">
  11. <h3>{{ authStore.user?.name }}</h3>
  12. <p>{{ authStore.user?.phone }}</p>
  13. <a-tag color="blue">工人</a-tag>
  14. </div>
  15. </div>
  16. </a-card>
  17. <!-- 功能菜单 -->
  18. <a-card class="mt-3">
  19. <a-list>
  20. <a-list-item @click="router.push('/change-password')">
  21. <a-list-item-meta>
  22. <template #avatar><KeyOutlined /></template>
  23. <template #title>修改密码</template>
  24. </a-list-item-meta>
  25. <template #action><RightOutlined /></template>
  26. </a-list-item>
  27. <a-list-item v-if="authStore.user?.must_change_password">
  28. <a-list-item-meta>
  29. <template #avatar><WarningOutlined /></template>
  30. <template #title>
  31. <a-badge status="warning" text="需要修改密码" />
  32. </template>
  33. </a-list-item-meta>
  34. </a-list-item>
  35. </a-list>
  36. </a-card>
  37. <!-- 退出登录 -->
  38. <a-card class="mt-3">
  39. <a-button danger size="large" block @click="handleLogout">
  40. 退出登录
  41. </a-button>
  42. </a-card>
  43. </div>
  44. </WorkerLayout>
  45. </template>
  46. <script setup lang="ts">
  47. import { useRouter } from 'vue-router';
  48. import { message } from 'ant-design-vue';
  49. import { KeyOutlined, RightOutlined, WarningOutlined } from '@ant-design/icons-vue';
  50. import { useAuthStore } from '@/stores/auth';
  51. import WorkerLayout from '@/components/WorkerLayout.vue';
  52. const router = useRouter();
  53. const authStore = useAuthStore();
  54. async function handleLogout() {
  55. await authStore.logout();
  56. message.success('已退出登录');
  57. router.push({
  58. name: 'Login',
  59. query: { factory: authStore.currentFactoryId || '' }
  60. });
  61. }
  62. </script>
  63. <style scoped lang="postcss">
  64. .profile-view { padding: 0; }
  65. .user-info {
  66. display: flex;
  67. align-items: center;
  68. gap: 16px;
  69. }
  70. .user-avatar {
  71. background-color: #1e3a5f;
  72. font-size: 24px;
  73. }
  74. .user-detail h3 {
  75. margin: 0;
  76. font-size: 18px;
  77. }
  78. .user-detail p {
  79. margin: 4px 0;
  80. color: #666;
  81. font-size: 14px;
  82. }
  83. .mt-3 {
  84. margin-top: 12px;
  85. }
  86. </style>