Sanakey
5 天以前 2af71bcf522c485ea005184c977986374a7dcc4a
提交 | 用户 | age
00fe0e 1 <template>
67287b 2   <div>
63d608 3     <a-spin :spinning="loading" class="p-1" style="height: 100%;">
H 4       <PageIndex :pageList="pageList" :mailType="1" :pageData="pageData" > </PageIndex>
74a35f 5     </a-spin>
00fe0e 6   </div>
H 7 </template>
8
9 <script lang="ts" setup>
10   name: 'Inbox';
12f730 11   import { ref, onMounted, computed, provide } from 'vue';
2c1249 12   import PageIndex from '@/views/email/components/ListPage/list.vue';
67287b 13   import { useRoute } from 'vue-router';
H 14
15   const route = useRoute();
16   // 获取当前完整 URL
17   const routerId = computed(() => {
18     try {
19       const url = window.location.href;
20       if (!url) {
21         throw new Error('Invalid URL');
22       }
23       const basePart = url.split('?')[1];
2c1249 24       console.log(basePart, 'basePart');
67287b 25       return basePart;
H 26     } catch (error) {
27       console.error('Error processing URL:', error);
28       // 返回默认值或空字符串
29       return '';
30     }
31   });
ccfd07 32   import { getMailListApi } from '@/api/email/userList';
12f730 33   const pageList = ref([]);
74a35f 34   const loading = ref(false);
63d608 35   const pageData = ref({
H 36     page: 1,
37     limit: 20,
38     total: 0,
39   });
40   function getDataList(page:1) {
74a35f 41     loading.value = true;
63d608 42     getMailListApi({ mail: routerId.value, mailType: 1,page })
74a35f 43       .then((res) => {
H 44         loading.value = false;
45         if (res.code == 0) {
63d608 46           pageList.value = res.data.list;
H 47           pageData.value.total = res.data.total;
74a35f 48         }
H 49       })
50       .catch(() => {
51         loading.value = false;
52       });
67287b 53   }
63d608 54
H 55   
74a35f 56   provide('getDataList', getDataList);
67287b 57   onMounted(() => {
H 58     getDataList();
59   });
00fe0e 60 </script>
H 61 <style scoped lang="less"></style>