![]()
-
From c454a16f04654178ff468e2a33f1f2f0ebaafec8 Mon Sep 17 00:00:00 2001
From: X1627315083 <1627315083@qq.com>
Date: Thu, 23 Oct 2025 14:05:42 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=85=A8=E5=B1=80loding?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/App.vue | 22 +++++++++++++++++++++-
src/main.ts | 2 ++
src/stores/index.ts | 3 ++-
src/stores/modules/overall.ts | 19 +++++++++++++++++++
4 files changed, 44 insertions(+), 2 deletions(-)
create mode 100644 src/stores/modules/overall.ts
diff --git a/src/App.vue b/src/App.vue
index 687d2ec..8afecc9 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,9 +1,17 @@
-
+
+
+
+
diff --git a/src/main.ts b/src/main.ts
index d212212..266529a 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -13,6 +13,7 @@ import 'vant/lib/index.css'
import { Locale } from 'vant';
import enUS from 'vant/es/locale/lang/en-US';
Locale.use('en-US', enUS);
+import { Loading } from 'vant';
import flexible from "./utils/flexible.js";
@@ -32,6 +33,7 @@ document.addEventListener('touchend', function(event) {
const app = createApp(App)
app.use(router)
.use(store)
+.use(Loading)
.component("SvgIcon", SvgIcon)
.mount('#app')
diff --git a/src/stores/index.ts b/src/stores/index.ts
index ca31d10..e8fe839 100644
--- a/src/stores/index.ts
+++ b/src/stores/index.ts
@@ -5,4 +5,5 @@ const store = createPinia()
// 使用持久化插件(全局持久化)
store.use(createPersistedState())
export default store
-export * from './modules/generate'
\ No newline at end of file
+export * from './modules/generate'
+export * from './modules/overall'
diff --git a/src/stores/modules/overall.ts b/src/stores/modules/overall.ts
new file mode 100644
index 0000000..7689f34
--- /dev/null
+++ b/src/stores/modules/overall.ts
@@ -0,0 +1,19 @@
+// 每一个存储的模块,命名规则use开头,store结尾
+import { defineStore } from 'pinia'
+export const useOverallStore = defineStore({
+ id: 'overall', // 必须指明唯一的pinia仓库的id
+ state: () => {
+ return {
+ loading:false,
+ }
+ },
+ getters: {
+ // doubleCount: (state) => state.num * 2
+ },
+ actions: {
+ // 全局loading
+ setLoading(data:boolean){
+ this.loading = data
+ }
+ }
+})
From 02ae02acbf9c41ea7f578cdcc0da919e0222023e Mon Sep 17 00:00:00 2001
From: X1627315083 <1627315083@qq.com>
Date: Thu, 23 Oct 2025 14:06:09 +0800
Subject: [PATCH 3/4] fix
---
src/App.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/App.vue b/src/App.vue
index 8afecc9..bd9617a 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,6 +1,6 @@
-
+
From 2d4096c46651ea14b6c9a637bcd2f8952499fbe2 Mon Sep 17 00:00:00 2001
From: X1627315083 <1627315083@qq.com>
Date: Thu, 23 Oct 2025 14:14:25 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E5=85=A8=E5=B1=80loding?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/utils/request.ts | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/utils/request.ts b/src/utils/request.ts
index cd59ec6..99aae49 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -4,6 +4,7 @@ import { useUserInfoStore } from '@/stores/modules/userInfo'
const store = useUserInfoStore()
import { getLocal } from '@/utils/local'
import router from '@/router/index'
+import { useOverallStore } from '@/stores'
// 创建axios实例
@@ -152,22 +153,18 @@ function removePending(config: any) {
}
}
// ----------------------------------loading的函数-------------------------------
-const LoadingInstance: { _target: any; _count: number } = {
- _target: null, // 保存Loading实例
+const LoadingInstance: { _count: number } = {
_count: 0
}
function openLoading(loadingDom: any) {
- LoadingInstance._target = showNotify({
- message: '数据正在加载中',
- background: 'rgba(25, 32, 53, 1)'
- })
+ useOverallStore().setLoading(true)
}
function closeLoading() {
if (LoadingInstance._count > 0) LoadingInstance._count--
if (LoadingInstance._count === 0) {
- LoadingInstance._target?.close()
- LoadingInstance._target = null
+ useOverallStore().setLoading(false)
}
+
}
export default service