|
@@ -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);
|
|
|
}
|