Просмотр исходного кода

```
feat: 添加全局loading功能并更新API基础URL

- 在多个页面组件中添加loading显示,包括学习笔记、学习系统、搜索平台、米币商城、工作流交易等
- 新增openFullScreenLoading工具函数用于统一管理全屏加载状态
- 更新开发环境API基础URL配置,将原来的IP地址注释并设置新地址
- 在utils工具文件中引入ElLoading并封装全局loading服务
```

zhangningning недель назад: 4
Родитель
Сommit
1b92f23f8b

+ 2 - 1
.env.development

@@ -1,6 +1,7 @@
 # 乔功
-VITE_API_BASE_URL=http://192.168.100.134:8080/api
+# VITE_API_BASE_URL=http://192.168.100.134:8080/api
 # 高运甲
 # VITE_API_BASE_URL=http://192.168.100.89:8080/api
+VITE_API_BASE_URL=http://192.168.101.12:8080/api
 
 

+ 6 - 2
src/pages/LearnNote/LearnNote.vue

@@ -32,7 +32,7 @@
 <script setup>
 import Xuxibiji from '@/pages/LearningSystem/components/xuxibiji.vue'
 import { getCourseWithNotesList } from '@/api/course.js'
-import { isLogin } from '@/utils/util.js'
+import { isLogin,openFullScreenLoading } from '@/utils/util.js'
 
 import { useI18n } from 'vue-i18n' 
 const { t } = useI18n() 
@@ -55,7 +55,11 @@ onMounted(() => {
   getList();
 });
 const getList = async () => {
-   getCourseWithNotesList().then(res => {
+  // 打开loading
+  const loading = openFullScreenLoading();
+  getCourseWithNotesList().then(res => {
+    // 关闭loading
+    loading.close();
     if(res.code === 200){
       console.log(res)
       list.value = res.rows || [];

+ 5 - 1
src/pages/LearningSystem/LearningSystem.vue

@@ -151,7 +151,7 @@
   import { getCourseList } from '@/api/course.js'
   import { getDictType } from '@/api/common.js'
 
-  import { isLogin } from '@/utils/util.js'
+  import { isLogin,openFullScreenLoading } from '@/utils/util.js'
   import { useI18n } from 'vue-i18n' 
   const { t } = useI18n() 
 
@@ -221,7 +221,11 @@
     if(type === 'init'){
       searchFom.pageNum = 1
     }
+    // 打开loading
+    const loading = openFullScreenLoading();
     const res = await getCourseList(searchFom)
+    // 关闭loading
+    loading.close();
     if(res.code === 200){
       list.value = res.rows || [];
       listTotal.value = res.total || 0;

+ 6 - 0
src/pages/LearningSystem/components/xuxibiji.vue

@@ -43,6 +43,8 @@ import addIcon from '@/assets/imgs/add.png'
 import BlockNoteEditorDialog from '@/components/BlockNoteEditorDialog.vue'
 import Pagination from '@/components/Pagination.vue'
 import { getnoteList,noteAdd,noteEdit,noteDel, getnoteDetail } from '@/api/note.js'
+import { openFullScreenLoading } from '@/utils/util.js'
+
 import { ref, onMounted,reactive,watch,onActivated } from 'vue'
 import DGTMessage from '@/utils/message'
 import { ElMessageBox } from 'element-plus'
@@ -95,7 +97,11 @@ const getList = async (type) => {
   if(type === 'init'){
     searchFom.pageNum = 1
   }
+  // 打开loading
+  const loading = openFullScreenLoading();
   const res = await getnoteList(searchFom)
+  // 关闭loading
+  loading.close();
   if(res.code === 200){
     listTotal.value = res.total
     list.value = res.rows

+ 5 - 1
src/pages/SearchPlatform.vue

@@ -89,7 +89,7 @@
 
   import { getCategoryListTree } from '@/api/category.js'
   import { getPublishList } from '@/api/publish.js'
-  import { isLogin } from '@/utils/util.js'
+  import { isLogin,openFullScreenLoading } from '@/utils/util.js'
   import { useI18n } from 'vue-i18n' 
   const { t } = useI18n() 
 
@@ -138,7 +138,11 @@
     if(type === 'init'){
       searchFom.pageNum = 1
     }
+    // 打开loading
+    const loading = openFullScreenLoading();
     const res = await getPublishList(searchFom)
+    // 关闭loading
+    loading.close();
     if(res.code === 200){
       list.value = res.rows || [];
       listTotal.value = res.total || 0;

+ 5 - 1
src/pages/mibiShop/mibiShop.vue

@@ -51,7 +51,7 @@ import { ref, onMounted,reactive, inject } from 'vue'
 import { useRouter } from 'vue-router'
 import { useAppStore } from '@/pinia/appStore'
 import { getMallList } from '@/api/mall.js'
-import { confirmBuy,isLogin } from '@/utils/util.js'
+import { confirmBuy,isLogin,openFullScreenLoading } from '@/utils/util.js'
 import { useI18n } from 'vue-i18n' 
 const { t } = useI18n() 
 const appStore = useAppStore()
@@ -84,7 +84,11 @@ const getList = async (type) => {
   if(type === 'init'){
     searchFom.pageNum = 1
   }
+  // 打开loading
+  const loading = openFullScreenLoading();
   const res = await getMallList(searchFom)
+  // 关闭loading
+  loading.close();
   if(res.code === 200){
     listTotal.value = res.total || 0;
     list.value = res.rows || [];

+ 7 - 3
src/pages/workflowTrade/workflowTrade.vue

@@ -143,7 +143,7 @@
   import yunIcon from '@/assets/imgs/yun.png'
   import biaoqianIcon from '@/assets/imgs/biaoqian.png'
   import zaixianbaomingIcon from '@/assets/imgs/zaixianbaoming.png'
-  import { submitSignUp,isLogin } from '@/utils/util.js'
+  import { submitSignUp,isLogin,openFullScreenLoading } from '@/utils/util.js'
 
   import Pagination from '@/components/Pagination.vue'
   import { getQuestList } from '@/api/workflowTrade.js'
@@ -219,9 +219,13 @@
     if(type === 'init'){
       searchFom.pageNum = 1
     }
-    searchFom.publishTimeBegin = publishTime.value && publishTime.value[0] ? publishTime.value[0] : ''
-    searchFom.publishTimeEnd = publishTime.value && publishTime.value[1] ? publishTime.value[1] : ''
+    searchFom.publishTimeBegin = publishTime.value && publishTime.value[0] ? publishTime.value[0] : '';
+    searchFom.publishTimeEnd = publishTime.value && publishTime.value[1] ? publishTime.value[1] : '';
+    // 打开loading
+    const loading = openFullScreenLoading();
     const res = await getQuestList(searchFom)
+    // 关闭loading
+    loading.close();
     if(res.code === 200){
       listTotal.value = res.total
       list.value = res.rows

+ 10 - 1
src/utils/util.js

@@ -1,6 +1,6 @@
 import DGTMessage from '@/utils/message'
 import { signUp } from '@/api/apply.js'
-import { ElMessageBox } from 'element-plus'
+import { ElMessageBox,ElLoading } from 'element-plus'
 import { createOrder } from '@/api/order.js'
 export function downloadFile({url, fileName='download',t}) {
   if (!url) {
@@ -154,3 +154,12 @@ export function paySuccess({t,callback}){
     },
   })
 };
+//全局loading封装
+export function openFullScreenLoading() {
+  const loading = ElLoading.service({
+    lock: true,
+    // text: 'Loading',
+    // background: 'rgba(0, 0, 0, 0.7)',
+  })
+  return loading;
+}