From 9d0881e6d12500ad556857664301bae25cdcdd11 Mon Sep 17 00:00:00 2001 From: danchaotaiyang Date: Wed, 15 Apr 2026 19:22:04 +0800 Subject: [PATCH] =?UTF-8?q?=3D=E3=80=90=E8=81=8C=E4=B8=9A=E5=9B=BE?= =?UTF-8?q?=E8=B0=B1=E3=80=91=E7=94=A8=E6=88=B7=E6=B1=82=E8=81=8C=E5=B2=97?= =?UTF-8?q?=E4=BD=8D=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stores/useCareerPathStore.js | 46 ++++++++++++++---------- stores/useCareerRecommendationStore.js | 48 ++++++++++++++++---------- stores/useSkillDevelopmentStore.js | 46 ++++++++++++++---------- 3 files changed, 85 insertions(+), 55 deletions(-) diff --git a/stores/useCareerPathStore.js b/stores/useCareerPathStore.js index e7478ef..2f4a6dd 100644 --- a/stores/useCareerPathStore.js +++ b/stores/useCareerPathStore.js @@ -1,33 +1,43 @@ import { computed, ref, watch } from 'vue'; -import { defineStore } from 'pinia'; +import { defineStore, storeToRefs } from 'pinia'; +import useUserStore from '@/stores/useUserStore'; import { getCurrentPosition, getPath, getPathDetail } from '@/apiRc/service/careerPath'; export const useCareerPathStore = defineStore('career-path', () => { + const { userInfo: ui } = storeToRefs(useUserStore()); const userInfo = ref({ userName: '', professions: [], skills: [] }); - try { - const data = uni.getStorageSync('userInfo'); + watch(() => ui.value, () => { + if (!ui.value) { + return; + } + try { + const { jobTitle, appSkillsList } = ui.value; - userInfo.value.professions = data.jobTitle.map((d) => { - return { - label: d, - value: d - }; - }); - userInfo.value.skills = data.appSkillsList.map((d) => { - return { - label: d.name, - value: d.name - }; - }); - } catch (e) { - console.warn(e); - } + userInfo.value.professions = jobTitle.map((d) => { + return { + label: d, + value: d + }; + }); + userInfo.value.skills = appSkillsList.map((d) => { + return { + label: d.name, + value: d.name + }; + }); + } catch (e) { + console.warn(e); + } + }, { + immediate: true, + deep: true + }); const professionIndex = ref(0); const profession = ref(''); diff --git a/stores/useCareerRecommendationStore.js b/stores/useCareerRecommendationStore.js index f9b5ae6..519c7dd 100644 --- a/stores/useCareerRecommendationStore.js +++ b/stores/useCareerRecommendationStore.js @@ -1,33 +1,43 @@ import { computed, ref, watch } from 'vue'; -import { defineStore } from 'pinia'; +import { defineStore, storeToRefs } from 'pinia'; +import useUserStore from '@/stores/useUserStore'; import { getProfessions, getRecommend, getSkillTags } from '@/apiRc/service/careerRecommendation'; export const useCareerRecommendationStore = defineStore('career-recommendation', () => { + const { userInfo: ui } = storeToRefs(useUserStore()); const userInfo = ref({ userName: '', professions: [], skills: [] }); - try { - const data = uni.getStorageSync('userInfo'); + watch(() => ui.value, () => { + if (!ui.value) { + return; + } + try { + const { jobTitle, appSkillsList } = ui.value; - userInfo.value.professions = data.jobTitle.map((d) => { - return { - label: d, - value: d - }; - }); - userInfo.value.skills = data.appSkillsList.map((d) => { - return { - label: d.name, - value: d.name - }; - }); - } catch (e) { - console.warn(e); - } + userInfo.value.professions = jobTitle.map((d) => { + return { + label: d, + value: d + }; + }); + userInfo.value.skills = appSkillsList.map((d) => { + return { + label: d.name, + value: d.name + }; + }); + } catch (e) { + console.warn(e); + } + }, { + immediate: true, + deep: true + }); const professionIndex = ref(0); const profession = ref(''); @@ -144,7 +154,7 @@ export const useCareerRecommendationStore = defineStore('career-recommendation', const eventProfession = (e) => { professionIndex.value = Number(e.detail.value); - const item = professionsRef.value[e.detail.value] + const item = professionsRef.value[ e.detail.value ]; profession.value = item.value; professionLabel.value = item.label; }; diff --git a/stores/useSkillDevelopmentStore.js b/stores/useSkillDevelopmentStore.js index ecc6c97..6bda9fe 100644 --- a/stores/useSkillDevelopmentStore.js +++ b/stores/useSkillDevelopmentStore.js @@ -1,34 +1,44 @@ import { computed, ref, watch } from 'vue'; -import { defineStore } from 'pinia'; +import { defineStore, storeToRefs } from 'pinia'; +import useUserStore from '@/stores/useUserStore'; import { getCurrentPosition, getPath } from '@/apiRc/service/careerPath'; import { getCareerPath, getSkillResult } from '@/apiRc/service/skillDevelopment'; export const useSkillDevelopmentStore = defineStore('skill-development', () => { + const { userInfo: ui } = storeToRefs(useUserStore()); const userInfo = ref({ userName: '', professions: [], skills: [] }); - try { - const data = uni.getStorageSync('userInfo'); + watch(() => ui.value, () => { + if (!ui.value) { + return; + } + try { + const { jobTitle, appSkillsList } = ui.value; - userInfo.value.professions = data.jobTitle.map((d) => { - return { - label: d, - value: d - }; - }); - userInfo.value.skills = data.appSkillsList.map((d) => { - return { - label: d.name, - value: d.name - }; - }); - } catch (e) { - console.warn(e); - } + userInfo.value.professions = jobTitle.map((d) => { + return { + label: d, + value: d + }; + }); + userInfo.value.skills = appSkillsList.map((d) => { + return { + label: d.name, + value: d.name + }; + }); + } catch (e) { + console.warn(e); + } + }, { + immediate: true, + deep: true + }); const professionIndex = ref(0); const profession = ref('');