Browse Source

fix: 替换图片为cdn资源

周玉环 1 day ago
parent
commit
2401c02709

+ 7 - 3
xinkeaboard-promotion-portal/src/App.vue

@@ -1,13 +1,17 @@
 <template>
-  <router-view v-slot="{ Component }">
+  <router-view v-slot="{ Component }" v-if="!clearCache">
     <keep-alive include="Home,Record">
-      <component :is="Component" />
+      <component :is="Component"/>
     </keep-alive>
   </router-view>
 </template>
 
 <script setup lang="ts">
-import { onMounted, onBeforeUnmount } from 'vue';
+import { onMounted, onBeforeUnmount, computed } from 'vue';
+import { useMainStore } from './store';
+
+const mainStore = useMainStore();
+const clearCache = computed(() => mainStore.getClearCache);
 
 const handleLinkClick = (e: MouseEvent) => {
   const target = (e.target as HTMLElement).closest("a") as HTMLAnchorElement | null;

BIN
xinkeaboard-promotion-portal/src/assets/images/record-top.png


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

@@ -25,7 +25,7 @@ const getQualitativeInfo = () => {
   return mainStore
     .getQualitative()
     .then((res) => {
-      rawText.value = res.msg.replace(/^```[a-zA-Z]*\n?/, "").replace(/```$/, "");;
+      rawText.value = res.msg.replace(/^```[a-zA-Z]*\n?/, '').replace(/```$/, '');
       autoFinish.value = true;
       setTimeout(() => {
         loading.value = false;
@@ -64,5 +64,11 @@ getQualitativeInfo();
     font-size: 20px;
     color: #282e30;
   }
+
+  :deep(pre) {
+    white-space: pre-wrap !important; /* 保留换行,允许长行折行 */
+    word-wrap: break-word !important; /* IE/Edge 兼容 */
+    word-break: break-all !important;
+  }
 }
 </style>

+ 16 - 3
xinkeaboard-promotion-portal/src/components/TopContent.vue

@@ -25,14 +25,16 @@
         ></CompetitorWebsite>
         <el-button v-if="currentStep !== 1" @click="prevStep">上一步</el-button>
         <el-button v-if="currentStep !== 3" @click="nextStep">下一步</el-button>
-        <el-button v-if="currentStep === 3" @click="acceptRecod">获取报告</el-button>
+        <el-button v-if="currentStep === 3" :loading="btnLoading" @click="acceptRecod"
+          >获取报告</el-button
+        >
       </div>
     </div>
   </div>
 </template>
 
 <script lang="ts" setup>
-import { ref, computed } from 'vue';
+import { ref, computed, nextTick } from 'vue';
 import { useMainStore } from '../store';
 import { checkLimit, incrementCount } from '@/utils/limit';
 
@@ -52,6 +54,8 @@ const CountrySelctRef = ref();
 const ProductDescriptionRef = ref();
 const CompetitorWebsiteRef = ref();
 
+const btnLoading = ref<boolean>(false);
+
 const validate = () => {
   const { locationName, productName, description } = getFormData();
   let message: string = '';
@@ -109,12 +113,15 @@ const getFormData = () => {
 };
 
 const acceptRecod = async () => {
+    btnLoading.value = true;
+
   const { allowed, remaining } = await checkLimit();
   if (!allowed) {
     showMessage({
       type: 'warning',
       message: `本月次数已用完`
     });
+    btnLoading.value = false;
     return;
   }
   const formData = getFormData();
@@ -126,7 +133,13 @@ const acceptRecod = async () => {
   //   });
   // }
   mainStore.setFormData(formData);
-  router.push('/record');
+  mainStore.setClearCache(true);
+
+  nextTick(() => {
+    mainStore.setClearCache(false);
+    router.push('/record');
+    // btnLoading.value = false;
+  });
 };
 </script>
 

+ 12 - 25
xinkeaboard-promotion-portal/src/main.ts

@@ -1,26 +1,13 @@
-import { createApp } from 'vue'
-import ElementPlus from 'element-plus'
-import 'element-plus/dist/index.css'
-import './assets/styles/theme.scss'
-import App from './App.vue'
-import router from './router'
-import { createPinia } from 'pinia'
+import { createApp } from 'vue';
+import ElementPlus from 'element-plus';
+import 'element-plus/dist/index.css';
+import './assets/styles/theme.scss';
+import App from './App.vue';
+import router from './router';
+import { createPinia } from 'pinia';
 
-const app = createApp(App)
-app.use(createPinia())
-app.use(router)
-app.use(ElementPlus)
-app.mount('#app')
-
-// window.addEventListener('popstate', () => {
-//   console.log('浏览器前进或后退触发 popstate');
-//   window.location.reload();
-// });
-
-// // 监听 bfcache 恢复
-// window.addEventListener('pageshow', (event) => {
-//   if (event.persisted) {
-//     console.log('页面从 bfcache 恢复');
-//     window.location.reload();
-//   }
-// });
+const app = createApp(App);
+app.use(createPinia());
+app.use(router);
+app.use(ElementPlus);
+app.mount('#app');

+ 11 - 2
xinkeaboard-promotion-portal/src/store/index.ts

@@ -12,6 +12,7 @@ import type { FormDataInfo, KeywordInfo, RelatedInfoBOItem, CompetitorBOSItem }
 export const useMainStore = defineStore('main', {
   state: () => ({
     currentStep: 1,
+    clearCache: false,
     formData: {} as FormDataInfo,
     keywordInfo: {
       loading: true,
@@ -27,6 +28,9 @@ export const useMainStore = defineStore('main', {
     isLoadOver: false
   }),
   actions: {
+    setClearCache(val: boolean) {
+      this.clearCache = val;  
+    },
     setIsLoadOver(val: boolean) {
       this.isLoadOver = val;
     },
@@ -42,7 +46,7 @@ export const useMainStore = defineStore('main', {
     },
     // 获取定性分析
     getQualitative(): Promise<any> {
-      const { productName, description } = this.getFormData;
+      const { productName, description = '' } = this.getFormData;
       return analysisQualitative(encodeURIComponent(productName + description));
     },
     // 获取竞品
@@ -52,6 +56,7 @@ export const useMainStore = defineStore('main', {
     },
     // 获取推荐
     async getSuggestions() {
+      this.suggestionsInfo.loading = true;
       const { productName, locationName } = this.getFormData;
       return analysisSuggestions({ productName, locationName })
         .then((res) => {
@@ -65,6 +70,7 @@ export const useMainStore = defineStore('main', {
     },
     // 获取关键词
     async getKeywordData() {
+      this.keywordInfo.loading = true;
       const { productName, locationName } = this.getFormData;
       return analysisKeyword({ productName, locationName })
         .then((res) => {
@@ -82,6 +88,9 @@ export const useMainStore = defineStore('main', {
     }
   },
   getters: {
+    getClearCache(): boolean {
+      return this.clearCache;
+    },
     getExpanded(): boolean {
       return this.expanded;
     },
@@ -89,7 +98,7 @@ export const useMainStore = defineStore('main', {
       return this.currentStep;
     },
     getFormData(): FormDataInfo {
-      if (sessionStorage.getItem('formData')) {
+      if (Object.keys(this.formData).length === 0) {
         const data = sessionStorage.getItem('formData') ?? '';
         return safeJsonParse(data);
       }

+ 12 - 6
xinkeaboard-promotion-portal/src/views/Home.vue

@@ -14,14 +14,20 @@
 import { computed, onMounted, onUnmounted } from 'vue';
 import TopContent from '@/components/TopContent.vue';
 import { useMainStore } from '../store';
-import AiBgImage from '@/assets/images/ai-bg.png';
-import Tab2Image from '@/assets/images/cando.png';
-import Record1 from '@/assets/images/record-1.png';
-import Record2 from '@/assets/images/record-2.png';
-import Record3 from '@/assets/images/record-3.png';
+// import AiBgImage from '@/assets/images/ai-bg.png';
+// import Tab2Image from '@/assets/images/cando.png';
+// import Record1 from '@/assets/images/record-1.png';
+// import Record2 from '@/assets/images/record-2.png';
+// import Record3 from '@/assets/images/record-3.png';
 
 const mainStore = useMainStore();
 
+const AiBgImage = 'https://assets.njnaexport.com//images/lookeen/ai-bg.png';
+const Tab2Image = 'https://assets.njnaexport.com//images/lookeen/cando.png';
+const Record1 = 'https://assets.njnaexport.com//images/lookeen/record-1.png';
+const Record2 = 'https://assets.njnaexport.com//images/lookeen/record-2.png';
+const Record3 = 'https://assets.njnaexport.com//images/lookeen/record-3.png';
+
 const currentStep = computed(() => mainStore.getCurrentStep);
 
 const Tab1 = computed(() => {
@@ -36,7 +42,7 @@ const Tab1 = computed(() => {
   }
 });
 onMounted(() => {
-  sessionStorage.removeItem('formData')
+  // sessionStorage.removeItem('formData')
 });
 
 onUnmounted(() => {});

+ 6 - 2
xinkeaboard-promotion-portal/src/views/Record.vue

@@ -46,7 +46,7 @@
 </template>
 
 <script lang="ts" setup>
-import { ref, computed } from 'vue';
+import { ref, computed, onMounted } from 'vue';
 
 import { useMainStore } from '../store';
 import KeywordSearch from '../components/keyword/search.vue';
@@ -77,6 +77,10 @@ const competitorWebsiteList = computed(() => {
 const download = () => {
   downloadPDF(pdfContent.value!);
 };
+
+onMounted(() => {
+  mainStore.setCurrentStep(1);
+});
 </script>
 
 <style lang="scss" scoped>
@@ -89,7 +93,7 @@ const download = () => {
 
   &-head {
     height: 1330px;
-    background-image: url('../assets/images/record-top.svg');
+    background-image: url('https://assets.njnaexport.com//images/lookeen/record-top.svg');
     background-repeat: no-repeat; /* 不重复 */
     background-position: center center; /* 居中显示 */
     background-size: cover;