application-management.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <script setup lang="ts">
  2. import { computed, ref, watch } from 'vue';
  3. import { useRouter } from 'vue-router';
  4. import { useUserStore } from '@vben/stores';
  5. import { $t } from '@/locales';
  6. import { getMyApplicationListApi, type UserApi } from '#/api';
  7. import { useLoginModalStore } from '#/store';
  8. const router = useRouter();
  9. const userStore = useUserStore();
  10. const isLogin = computed(() => !!userStore.userInfo);
  11. const loginModalStore = useLoginModalStore();
  12. const applicationList = ref<UserApi.ApplicationModel[]>([]);
  13. const loading = ref(false);
  14. async function fetchApplicationList() {
  15. if (!isLogin.value) {
  16. return;
  17. }
  18. try {
  19. loading.value = true;
  20. const result = await getMyApplicationListApi({
  21. currentPage: 1,
  22. pageSize: 16,
  23. orderByProperty: 'name',
  24. Ascending: true,
  25. totalPage: 1,
  26. totalCount: 1,
  27. filters: [
  28. {
  29. name: 'isEnable',
  30. value: 1,
  31. },
  32. ],
  33. });
  34. if (result?.result?.model) {
  35. applicationList.value = result.result.model;
  36. }
  37. } catch (error) {
  38. console.error('获取应用列表失败:', error);
  39. } finally {
  40. loading.value = false;
  41. }
  42. }
  43. function handleMore() {
  44. if (!isLogin.value) {
  45. loginModalStore.open();
  46. return;
  47. }
  48. router.push('/application-management');
  49. }
  50. watch(
  51. () => isLogin.value,
  52. (newValue) => {
  53. if (newValue) {
  54. fetchApplicationList();
  55. }
  56. },
  57. { immediate: true },
  58. );
  59. </script>
  60. <template>
  61. <div class="info-card border-box h-[217px] w-full rounded-lg p-5 shadow-md">
  62. <div class="items-flex-start flex justify-between">
  63. <div>
  64. <h2 class="text-lg font-bold">
  65. {{ $t('homeModule.applicationManagement') }}
  66. </h2>
  67. <div class="text-xs text-[#9A9BA3]">Application Management</div>
  68. </div>
  69. <img
  70. alt="more"
  71. class="h-[29px] w-[29px] cursor-pointer"
  72. src="@/assets/image/home-more.png"
  73. @click="handleMore"
  74. />
  75. </div>
  76. <p
  77. v-if="!isLogin"
  78. class="mt-4 w-[714px] text-sm text-xs leading-relaxed text-[#9A9BA3]"
  79. >
  80. {{ $t('homeModule.applicationManagementIntroduction') }}
  81. </p>
  82. <div v-if="isLogin" class="mt-[38px] flex flex-wrap gap-[18px]">
  83. <div
  84. v-for="(item, index) in applicationList"
  85. :key="index"
  86. class="flex h-[37px] cursor-pointer items-center rounded-[11px] bg-[#fff] p-[6px_10px] shadow-md"
  87. >
  88. <img
  89. :src="`/File/Download?fileId=${item.imgPhotoFileId}`"
  90. alt=""
  91. class="h-[24px] w-auto object-contain"
  92. />
  93. </div>
  94. </div>
  95. </div>
  96. </template>
  97. <style scoped>
  98. .info-card {
  99. overflow: hidden;
  100. background: url('@/assets/image/ApplicationManagement.png') no-repeat center
  101. center;
  102. background-size: cover;
  103. border-radius: 26px;
  104. }
  105. </style>