diff --git a/src/composables/useLoading.ts b/src/composables/useLoading.ts new file mode 100644 index 0000000..29a6c5b --- /dev/null +++ b/src/composables/useLoading.ts @@ -0,0 +1,44 @@ +import { ref } from 'vue' + +/** + * 页面级加载状态管理 + * @param initialLoading 初始 loading 状态,默认 false + */ +export function usePageLoading(initialLoading = false) { + const loading = ref(initialLoading) + + const startLoading = () => { + loading.value = true + } + + const stopLoading = () => { + loading.value = false + } + + return { + loading, + startLoading, + stopLoading, + } +} + +/** + * 按钮级别加载状态管理 + */ +export function useButtonLoading() { + const buttonLoading = ref(false) + + const startButtonLoading = () => { + buttonLoading.value = true + } + + const stopButtonLoading = () => { + buttonLoading.value = false + } + + return { + buttonLoading, + startButtonLoading, + stopButtonLoading, + } +} \ No newline at end of file diff --git a/src/views/agent/user/index.vue b/src/views/agent/user/index.vue index 859fd72..a9e305c 100644 --- a/src/views/agent/user/index.vue +++ b/src/views/agent/user/index.vue @@ -6,7 +6,7 @@ + :default-sort="{ prop: 'createTime', order: 'descending' }" :loading="loading" @expand-change="handleGetSubList"> - + { + startLoading() const params = { page: currentPage.value, page_size: pageSize.value, @@ -84,6 +87,7 @@ const getFundDetailList = async () => { } // 调用接口获取数据 const data: any = await getFundDetailListApi(params) + stopLoading() console.log(data) tableTree.value = data.data.map((item: any) => ({ ...item, diff --git a/src/views/capital/rechange/index.vue b/src/views/capital/rechange/index.vue index a8ba747..1b4e5a2 100644 --- a/src/views/capital/rechange/index.vue +++ b/src/views/capital/rechange/index.vue @@ -4,7 +4,7 @@
存款
- +