Dashboard.vue 4.0 KB

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