소스 검색

fix: 调整限制逻辑

周玉环 2 일 전
부모
커밋
91bc90c3cb

+ 1 - 1
xinkeaboard-promotion-portal/src/components/AiAnalysis.vue

@@ -74,7 +74,7 @@ getQualitativeInfo();
   &-text {
     width: 100%;
     word-break: break-all;
-    white-space: pre-wrap;
+    // white-space: pre-wrap;
     overflow: hidden;
     font-weight: 400;
     font-size: 20px;

+ 1 - 1
xinkeaboard-promotion-portal/src/components/competitor/RankTable.vue

@@ -85,7 +85,7 @@
           CPC(每次点击费用)
         </template>
         <template #default="scope">
-          {{ '$ ' + scope.row.cpc }}
+          {{ scope.row.cpc ? '$ ' + scope.row.cpc : '-' }}
         </template>
       </el-table-column>
       <!-- <el-table-column prop="searchVolume" align="center" label="桌面搜索"> </el-table-column> -->

+ 1 - 1
xinkeaboard-promotion-portal/src/components/competitor/RecommendTable.vue

@@ -53,7 +53,7 @@
           价格
         </template>
         <template #default="scope">
-          {{ '$ ' + scope.row.price }}
+          {{ scope.row.price ? '$ ' + scope.row.price : '-' }}
         </template>
       </el-table-column>
     </el-table>

+ 3 - 1
xinkeaboard-promotion-portal/src/store/index.ts

@@ -6,6 +6,7 @@ import {
   analysisRival,
   analysisQualitative
 } from '../utils/api';
+import { incrementCount } from '@/utils/limit';
 import type { FormDataInfo, KeywordInfo, RelatedInfoBOItem, CompetitorBOSItem } from '@/types';
 
 export const useMainStore = defineStore('main', {
@@ -69,8 +70,9 @@ export const useMainStore = defineStore('main', {
         .then((res) => {
           this.keywordInfo.data = res.data;
         })
-        .finally(() => {
+        .finally(async() => {
           this.keywordInfo.loading = false;
+          await incrementCount()
         });
     },
     initData() {

+ 8 - 3
xinkeaboard-promotion-portal/src/utils/http.ts

@@ -1,6 +1,7 @@
 import axios from 'axios';
 import router from '@/router'; // 如果需要跳转登录页
 import { generateSign } from '@/utils/hmac';
+import { checkLimit } from './limit';
 import { showMessage } from '@/utils/common';
 
 // 创建 axios 实例
@@ -11,7 +12,11 @@ const http = axios.create({
 
 // 请求拦截器
 http.interceptors.request.use(
-  (config) => {
+  async (config) => {
+    const { allowed } = await checkLimit();
+    if (!allowed) {
+      return Promise.reject(new Error('本月次数已用完'));
+    }
     const { url } = config;
     const extendParams = {
       msgId: '730d7bbaf1914e8ba60e9c922d58a8c8',
@@ -58,10 +63,10 @@ http.interceptors.response.use(
           message = error.message;
       }
     } else {
-      message = '网络错误';
+      message = '本月次数已用完';
     }
     showMessage({
-      type: 'error',
+      type: 'warning',
       message
     });
     return Promise.reject(error);