소스 검색

```
feat(components): 为课程卡片组件添加登录验证功能

- 在课程卡片组件中添加了登录状态检查,确保用户在点击开始使用按钮前已登录
- 注入openLoginDialog依赖以支持登录弹窗功能
- 引入vue-i18n用于国际化处理

feat(pages): 为首页和搜索平台页面添加登录验证

- 在Home.vue和SearchPlatform.vue中添加登录验证逻辑
- 确保用户在进行相关操作前已完成登录
- 使用统一的isLogin工具函数进行登录状态检查

feat(workflow): 为工作流交易页面添加登录保护

- 在workflowTrade.vue中为报名按钮和添加工作流功能添加登录验证
- 使用短路运算符优化登录检查逻辑
- 统一使用注入的登录对话框服务
```

zhangningning 1 개월 전
부모
커밋
b02037fe5c
4개의 변경된 파일38개의 추가작업 그리고 10개의 파일을 삭제
  1. 13 1
      src/components/course-card.vue
  2. 7 2
      src/pages/Home.vue
  3. 9 2
      src/pages/SearchPlatform.vue
  4. 9 5
      src/pages/workflowTrade/workflowTrade.vue

+ 13 - 1
src/components/course-card.vue

@@ -32,7 +32,7 @@
           <el-icon class="mr10"><Document /></el-icon>
           {{$t('common.viewDetails')}}
         </el-button>
-        <el-button type="primary" class="flex_1 gradient" size="large">
+        <el-button type="primary" class="flex_1 gradient" size="large" @click.stop.prevent="startUsing">
           <el-icon class="mr10"><VideoPlay /></el-icon>
           {{$t('common.startUsing')}}
         </el-button>
@@ -70,6 +70,11 @@ import n8Icon from '@/assets/imgs/8n8.png'
 import yunIcon from '@/assets/imgs/yun.png'
 import riliIcon from '@/assets/imgs/rili.png'
 import { useAppStore } from '@/pinia/appStore'
+import { inject } from 'vue'
+import { isLogin } from '@/utils/util.js'
+import { useI18n } from 'vue-i18n' 
+const { t } = useI18n()
+
 const appStore = useAppStore();
 import { useRouter } from 'vue-router'
 const router = useRouter()
@@ -99,6 +104,13 @@ const goWorkflowDetail = () => {
     }
   })
 };
+const openLoginDialog = inject('openLoginDialog')
+const startUsing = () => {
+  //判断是否登录
+  if(!isLogin({callback: openLoginDialog,t})){
+    return;
+  }
+};
 </script>
 
 <style scoped lang="scss">

+ 7 - 2
src/pages/Home.vue

@@ -90,12 +90,13 @@ import difyIcon from '@/assets/imgs/dify.png'
 import fastgptIcon from '@/assets/imgs/FastGPT.png'
 import detailIcon from '@/assets/imgs/detail.png'
 import CourseCard from '@/components/course-card.vue'
+import { isLogin } from '@/utils/util.js'
 
 import { getCategoryListTree } from '@/api/category.js'
 import { getPublishList } from '@/api/publish.js'
 
 
-import { onMounted,ref } from 'vue'
+import { onMounted,ref, inject } from 'vue'
 import { useRouter } from 'vue-router'
 import { useI18n } from 'vue-i18n' 
 const { t } = useI18n() // 获取t函数// 导入useI18n
@@ -139,8 +140,12 @@ const goSearchPlatform = () => {
     }
   })
 };
-
+const openLoginDialog = inject('openLoginDialog')
 const goWorkflowAdd = () => {
+   //判断是否登录
+  if(!isLogin({callback: openLoginDialog,t})){
+    return;
+  }
   //增加参数名称
   router.push({
     path: `workflow-add`,

+ 9 - 2
src/pages/SearchPlatform.vue

@@ -89,12 +89,15 @@
 
   import { getCategoryListTree } from '@/api/category.js'
   import { getPublishList } from '@/api/publish.js'
+  import { isLogin } from '@/utils/util.js'
+  import { useI18n } from 'vue-i18n' 
+  const { t } = useI18n() 
 
 
   import { useRouter, useRoute } from 'vue-router'
   const router = useRouter();
   const route = useRoute();
-  import { ref, computed, reactive, onMounted } from 'vue'
+  import { ref, computed, reactive, onMounted, inject } from 'vue'
   //获取参数
   const query = route.query
   const categoryId = ref(query.categoryId || '');
@@ -145,8 +148,12 @@
     console.log('当前页:', page)
     getList();
   }
-
+  const openLoginDialog = inject('openLoginDialog')
   const goWorkflowAdd = () => {
+    //判断是否登录
+  if(!isLogin({callback: openLoginDialog,t})){
+    return;
+  }
     //增加参数名称
     router.push({
       path: `/search-platform/workflow-add`,

+ 9 - 5
src/pages/workflowTrade/workflowTrade.vue

@@ -112,7 +112,8 @@
                 <div class="font_size16 bold">{{item.nickName}}</div>
                 <div class="font_size14 gray mt2">{{item.createTime}} {{$t('common.publish')}}</div>
               </div>
-              <el-button type="primary" size="large" @click="submitSignUp({questId: item.questId,questUserId: item.questUserId},t)">
+              <el-button type="primary" size="large" 
+              @click="isLogin({callback: openLoginDialog,t}) && submitSignUp({questId: item.questId,questUserId: item.questUserId},t)">
                 <img :src="zaixianbaomingIcon" alt="" class="mr10" style="width: 16px; height: 16px;">
                 <span class="font_size14">{{$t('common.zaixianbaoming')}}</span>
               </el-button>
@@ -142,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 } from '@/utils/util.js'
+  import { submitSignUp,isLogin } from '@/utils/util.js'
 
   import Pagination from '@/components/Pagination.vue'
   import { getQuestList } from '@/api/workflowTrade.js'
@@ -156,10 +157,10 @@
   const router = useRouter()
   const route = useRoute()
   console.log(router,route)
-  import { ref, computed, reactive, onMounted } from 'vue'
+  import { ref, computed, reactive, onMounted, inject } from 'vue'
   import { useAppStore } from '@/pinia/appStore'
   const appStore = useAppStore();
-
+  const openLoginDialog = inject('openLoginDialog')
   //获取参数
   const query = route.query;
   //获取当前路由路径
@@ -222,6 +223,9 @@
     })
   };
   const goWorkflowAdd = () => {
+    if(!isLogin({callback: openLoginDialog,t})){
+      return
+    }
     //增加参数名称
     router.push({
       path: `/workflow-trade/workflow-trade-add`,
@@ -236,7 +240,7 @@
       console.log('一级分类列表',res.data)
       CategoryList.value = res.rows || []
     }
-  }
+  };
 </script>
 
 <style scoped lang="scss">