Dashboard.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <script setup lang="ts">
  2. import { computed } from "vue";
  3. import { useMainStore } from "@/stores/main";
  4. import { storeToRefs } from "pinia";
  5. import { useI18n } from "vue-i18n";
  6. const { t } = useI18n();
  7. const mainStore = useMainStore();
  8. const mainStoreRef = storeToRefs(mainStore);
  9. const userProfile = mainStoreRef.readUserProfile;
  10. const greetedUser = computed(() => {
  11. const userProfile = mainStoreRef.readUserProfile;
  12. if (userProfile.value) {
  13. if (userProfile.value!.full_name) {
  14. return userProfile.value!.full_name;
  15. } else {
  16. return userProfile.value.email;
  17. }
  18. }
  19. });
  20. </script>
  21. <template>
  22. <v-container fluid>
  23. <v-row dense>
  24. <v-col cols="12">
  25. <v-card class="ma-3 pa-3">
  26. <v-card-title primary-title>
  27. <h3>Welcome {{ greetedUser }}</h3>
  28. </v-card-title>
  29. <v-card-text class="my-3">
  30. <h4 class="">
  31. {{ t("userName") }}
  32. </h4>
  33. <span v-if="userProfile && userProfile.full_name">
  34. {{ userProfile.full_name }}
  35. </span>
  36. <div v-else>-</div>
  37. <h4 class="mt-3">
  38. {{ t("emailAddress") }}
  39. </h4>
  40. <span v-if="userProfile && userProfile.email">
  41. {{ userProfile.email }}
  42. </span>
  43. <div v-else>-</div>
  44. </v-card-text>
  45. <v-card-actions>
  46. <v-btn to="/main/profile/edit" variant="outlined" color="primary">{{
  47. t("edit")
  48. }}</v-btn>
  49. <v-btn
  50. to="/main/profile/password"
  51. variant="flat"
  52. color="primary"
  53. class="ms-3"
  54. >{{ t("changePassword") }}</v-btn
  55. >
  56. </v-card-actions>
  57. <!-- <v-card-actions>
  58. <v-btn to="/main/profile/view">View Profile</v-btn>
  59. <v-btn to="/main/profile/edit">Edit Profile</v-btn>
  60. <v-btn to="/main/profile/password">Change Password</v-btn>
  61. </v-card-actions> -->
  62. </v-card>
  63. </v-col>
  64. <v-col cols="6">
  65. <v-card class="ma-3 pa-3 second-item">
  66. <v-card-title primary-title>
  67. <h3>已使用秒數</h3>
  68. </v-card-title>
  69. <v-card-text class="mt-3">
  70. <strong>0</strong><small>秒</small>
  71. </v-card-text>
  72. <v-divider></v-divider>
  73. <v-card-actions>
  74. <v-btn
  75. prepend-icon="format_list_bulleted"
  76. to="/main/progress"
  77. variant="outlined"
  78. class="mt-3"
  79. color="primary"
  80. >
  81. 查看詳情
  82. </v-btn>
  83. <!-- <v-btn
  84. to="/main/profile/password"
  85. variant="flat"
  86. color="primary"
  87. style="padding: 0 15px"
  88. >{{ t("changePassword") }}</v-btn
  89. > -->
  90. </v-card-actions>
  91. </v-card>
  92. </v-col>
  93. <v-col cols="6">
  94. <v-card class="ma-3 pa-3 second-item">
  95. <v-card-title primary-title>
  96. <h3>可使用秒數</h3>
  97. </v-card-title>
  98. <v-card-text
  99. v-if="userProfile"
  100. class="mt-3"
  101. >
  102. <strong>{{ userProfile.available_time }}</strong
  103. ><small>秒</small>
  104. </v-card-text>
  105. <v-divider></v-divider>
  106. <v-card-actions>
  107. <v-btn
  108. variant="flat"
  109. color="primary"
  110. class="mt-3"
  111. prepend-icon="add"
  112. >我要加值</v-btn
  113. >
  114. </v-card-actions>
  115. </v-card>
  116. </v-col>
  117. </v-row>
  118. </v-container>
  119. </template>
  120. <style lang="scss" scoped>
  121. .v-toolbar__content {
  122. background-image: linear-gradient(
  123. -225deg,
  124. rgb(234, 84, 19) 35%,
  125. rgb(178, 69, 146) 100%
  126. );
  127. }
  128. .v-btn {
  129. padding: 0 15px;
  130. }
  131. h4 {
  132. font-size: 16px;
  133. }
  134. .second-item {
  135. strong {
  136. font-size: 30px;
  137. font-weight: 500;
  138. }
  139. small {
  140. font-size: 16px;
  141. margin-left: 5px;
  142. }
  143. }
  144. </style>