ai助手投递偏好设置修复
This commit is contained in:
@@ -389,8 +389,11 @@ const showMessageDialog = ref(false)
|
|||||||
const showFeedbackDialog = ref(false)
|
const showFeedbackDialog = ref(false)
|
||||||
/** 当前hover的菜单索引,-1表示无hover */
|
/** 当前hover的菜单索引,-1表示无hover */
|
||||||
const hoverIndex = ref(-1)
|
const hoverIndex = ref(-1)
|
||||||
/** 会员权限拦截弹窗 */
|
/** 会员权限拦截弹窗 — 读写 store 全局状态(路由守卫也可触发) */
|
||||||
const showMemberAccessDialog = ref(false)
|
const showMemberAccessDialog = computed({
|
||||||
|
get: () => store.state.showMemberAccessDialog,
|
||||||
|
set: (val: boolean) => store.commit('SET_SHOW_MEMBER_ACCESS_DIALOG', val),
|
||||||
|
})
|
||||||
/** 会员购买弹窗 */
|
/** 会员购买弹窗 */
|
||||||
const showMemberDialog = ref(false)
|
const showMemberDialog = ref(false)
|
||||||
const showSettingsDialog = computed({
|
const showSettingsDialog = computed({
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router'
|
|||||||
import type { RouteRecordRaw } from 'vue-router'
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
import store from '@/stores'
|
import store from '@/stores'
|
||||||
import { checkLogin } from '@/api/auth'
|
import { checkLogin } from '@/api/auth'
|
||||||
|
import { fetchMemberStatus } from '@/api/member'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 静态路由 — 不需要权限,应用启动就注册
|
* 静态路由 — 不需要权限,应用启动就注册
|
||||||
@@ -125,6 +126,33 @@ router.beforeEach(async (to, _from, next) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Agent 页面需要会员权限 — 等待会员信息加载后判断
|
||||||
|
if (to.name === 'Agent') {
|
||||||
|
try {
|
||||||
|
// 确保会员信息已加载到 store
|
||||||
|
if (!store.state.memberStatus) {
|
||||||
|
const res = await fetchMemberStatus()
|
||||||
|
if (res.code === '0' && res.data) {
|
||||||
|
store.commit('SET_MEMBER_STATUS', res.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const status = store.state.memberStatus
|
||||||
|
// 试用会员(memberType=2)或正式会员(memberType=1)才能进入
|
||||||
|
if (status && status.isMember && (status.memberType === 1 || status.memberType === 2)) {
|
||||||
|
next()
|
||||||
|
} else {
|
||||||
|
// 免费用户 — 弹出会员权限拦截弹窗,阻止跳转
|
||||||
|
store.commit('SET_SHOW_MEMBER_ACCESS_DIALOG', true)
|
||||||
|
next(false)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// 接口异常时弹窗提示,不放行
|
||||||
|
store.commit('SET_SHOW_MEMBER_ACCESS_DIALOG', true)
|
||||||
|
next(false)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 非鉴权路由 — 静默同步登录状态(节流:5 分钟内不重复请求)
|
// 非鉴权路由 — 静默同步登录状态(节流:5 分钟内不重复请求)
|
||||||
if (Date.now() - lastCheckTime > CHECK_INTERVAL) {
|
if (Date.now() - lastCheckTime > CHECK_INTERVAL) {
|
||||||
checkLogin()
|
checkLogin()
|
||||||
|
|||||||
@@ -159,6 +159,11 @@ export interface RootState {
|
|||||||
* 登录成功后自动清空,避免重复发送
|
* 登录成功后自动清空,避免重复发送
|
||||||
*/
|
*/
|
||||||
inviteCode: string
|
inviteCode: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局会员权限拦截弹窗 — 路由守卫或页面检测到免费用户时触发
|
||||||
|
*/
|
||||||
|
showMemberAccessDialog: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createStore<RootState>({
|
export default createStore<RootState>({
|
||||||
@@ -189,6 +194,7 @@ export default createStore<RootState>({
|
|||||||
showSettings: false,
|
showSettings: false,
|
||||||
settingsTab: 'account',
|
settingsTab: 'account',
|
||||||
inviteCode: '',
|
inviteCode: '',
|
||||||
|
showMemberAccessDialog: false,
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
getAppName: (state) => state.appName,
|
getAppName: (state) => state.appName,
|
||||||
@@ -261,6 +267,9 @@ export default createStore<RootState>({
|
|||||||
SET_INVITE_CODE(state, code: string) {
|
SET_INVITE_CODE(state, code: string) {
|
||||||
state.inviteCode = code
|
state.inviteCode = code
|
||||||
},
|
},
|
||||||
|
SET_SHOW_MEMBER_ACCESS_DIALOG(state, show: boolean) {
|
||||||
|
state.showMemberAccessDialog = show
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
updateAppName({ commit }, name: string) {
|
updateAppName({ commit }, name: string) {
|
||||||
|
|||||||
@@ -242,6 +242,8 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, nextTick } from 'vue'
|
import { ref, onMounted, nextTick } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import { useStore } from 'vuex'
|
||||||
import SideNav from '@/components/SideNav.vue'
|
import SideNav from '@/components/SideNav.vue'
|
||||||
import AgentSetupWizard from '@/components/AgentSetupWizard.vue'
|
import AgentSetupWizard from '@/components/AgentSetupWizard.vue'
|
||||||
import AgentChatJobList from '@/components/AgentChatJobList.vue'
|
import AgentChatJobList from '@/components/AgentChatJobList.vue'
|
||||||
@@ -256,8 +258,13 @@ import type { AgentConfig, AgentRecommendJob } from '@/api/agent'
|
|||||||
import { fetchAgentTaskList, fetchJobList, fetchJobIntention, fetchCustomizeResume } from '@/api/jobs'
|
import { fetchAgentTaskList, fetchJobList, fetchJobIntention, fetchCustomizeResume } from '@/api/jobs'
|
||||||
import type { JobListItem, JobListParams } from '@/api/jobs'
|
import type { JobListItem, JobListParams } from '@/api/jobs'
|
||||||
import { fetchResumeList } from '@/api/resume'
|
import { fetchResumeList } from '@/api/resume'
|
||||||
|
import { fetchMemberStatus } from '@/api/member'
|
||||||
import JobGoalDialog from '@/components/JobGoalDialog.vue'
|
import JobGoalDialog from '@/components/JobGoalDialog.vue'
|
||||||
|
|
||||||
|
// ==================== 路由 & Store ====================
|
||||||
|
const router = useRouter()
|
||||||
|
const store = useStore()
|
||||||
|
|
||||||
// ==================== sessionStorage 缓存 key ====================
|
// ==================== sessionStorage 缓存 key ====================
|
||||||
const STORAGE_KEY = 'agent_apply_progress_list'
|
const STORAGE_KEY = 'agent_apply_progress_list'
|
||||||
const COMPLETED_STORAGE_KEY = 'agent_completed_apply_list'
|
const COMPLETED_STORAGE_KEY = 'agent_completed_apply_list'
|
||||||
@@ -390,6 +397,23 @@ function loadCompletedFromStorage() {
|
|||||||
|
|
||||||
/** 页面挂载时查询配置 */
|
/** 页面挂载时查询配置 */
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
// 检查会员权限:确保会员信息已加载,免费用户弹窗并跳回
|
||||||
|
if (!store.state.memberStatus) {
|
||||||
|
try {
|
||||||
|
const res = await fetchMemberStatus()
|
||||||
|
if (res.code === '0' && res.data) {
|
||||||
|
store.commit('SET_MEMBER_STATUS', res.data)
|
||||||
|
}
|
||||||
|
} catch { /* 异常时继续检查 */ }
|
||||||
|
}
|
||||||
|
const status = store.state.memberStatus
|
||||||
|
if (!status || !status.isMember) {
|
||||||
|
// 免费用户 — 弹出会员权限拦截弹窗,跳回上一页
|
||||||
|
store.commit('SET_SHOW_MEMBER_ACCESS_DIALOG', true)
|
||||||
|
router.back()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
loadProgressFromStorage()
|
loadProgressFromStorage()
|
||||||
loadCompletedFromStorage()
|
loadCompletedFromStorage()
|
||||||
await loadAgentConfig()
|
await loadAgentConfig()
|
||||||
|
|||||||
Reference in New Issue
Block a user