From e516d1d8666aa01ad6eade3b3ed060a862714b7b Mon Sep 17 00:00:00 2001 From: Zrief Date: Fri, 3 Oct 2025 00:03:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=84=9A=E6=9C=AC=E7=AE=A1=E7=90=86=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E8=AE=A1=E5=88=92=E8=A1=A8=E4=B8=AD=E7=9A=84=E5=85=B3?= =?UTF-8?q?=E5=8D=A1=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新了 ScriptTable.vue,能按计划配置显示关卡信息(支持周模式和全局模式),还加了获取展示计划中已配置关卡的逻辑,Scripts.vue 也整合了计划数据加载,让用计划表设置关卡的用户看得更清楚。 --- frontend/src/components/ScriptTable.vue | 146 +++++++++++++++++++++++- frontend/src/views/Scripts.vue | 21 ++++ 2 files changed, 163 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/ScriptTable.vue b/frontend/src/components/ScriptTable.vue index 6a830cf..61d4f42 100644 --- a/frontend/src/components/ScriptTable.vue +++ b/frontend/src/components/ScriptTable.vue @@ -171,10 +171,45 @@ 基建: {{ user.Info.InfrastMode === 'Normal' ? '普通' : '自定义' }} - - - 关卡: {{ user.Info.Stage === '-' ? '未选择' : user.Info.Stage }} - + + + + + + currentPlanData?: Record | null } interface Emits { @@ -419,6 +455,12 @@ const getRemainingDayColor = (remainedDay: number): string => { return 'green' } +// 获取关卡标签颜色 +const getStageTagColor = (stage: string): string => { + if (stage === '1-7') return 'green' // 使用计划表配置用绿色 + return 'blue' // 自定义关卡用蓝色 +} + // 获取剩余天数的显示文本 const getRemainingDayText = (remainedDay: number): string => { if (remainedDay === -1) return '剩余天数: 长期有效' @@ -426,6 +468,102 @@ const getRemainingDayText = (remainedDay: number): string => { return `剩余天数: ${remainedDay}天` } +// 获取关卡的显示文本 +const getDisplayStage = (stage: string): string => { + if (stage === '-') return '未选择' + + // 如果是默认值且有计划表数据,显示计划表中的实际关卡 + if (stage === '1-7' && props.currentPlanData) { + const planStage = getCurrentPlanStage() + if (planStage && planStage !== '-') { + return planStage + } + return '使用计划表配置' + } + + return stage +} + +// 从计划表获取当前关卡 +const getCurrentPlanStage = (): string => { + if (!props.currentPlanData) return '' + + // 根据当前时间确定使用哪个时间段的配置 + const planMode = props.currentPlanData.Info?.Mode || 'ALL' + let timeKey = 'ALL' + + if (planMode === 'Weekly') { + // 如果是周模式,根据当前星期几获取对应配置 + const today = new Date().getDay() // 0=Sunday, 1=Monday, ... + const dayMap = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] + timeKey = dayMap[today] + } + + // 从计划表获取关卡配置 + const timeConfig = props.currentPlanData[timeKey] + if (!timeConfig) return '' + + // 获取主要关卡 + if (timeConfig.Stage && timeConfig.Stage !== '-') { + return timeConfig.Stage + } + + // 如果主要关卡为空,尝试获取第一个备选关卡 + const backupStages = [timeConfig.Stage_1, timeConfig.Stage_2, timeConfig.Stage_3] + for (const stage of backupStages) { + if (stage && stage !== '-') { + return stage + } + } + + return '' +} + +// 从计划表获取所有配置的关卡 +const getAllPlanStages = (): Array<{ label: string; value: string }> => { + if (!props.currentPlanData) return [] + + // 根据当前时间确定使用哪个时间段的配置 + const planMode = props.currentPlanData.Info?.Mode || 'ALL' + let timeKey = 'ALL' + + if (planMode === 'Weekly') { + // 如果是周模式,根据当前星期几获取对应配置 + const today = new Date().getDay() // 0=Sunday, 1=Monday, ... + const dayMap = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] + timeKey = dayMap[today] + } + + // 从计划表获取关卡配置 + const timeConfig = props.currentPlanData[timeKey] + if (!timeConfig) return [] + + const stages: Array<{ label: string; value: string }> = [] + + // 主关卡 + if (timeConfig.Stage && timeConfig.Stage !== '-') { + stages.push({ label: '关卡', value: timeConfig.Stage }) + } + + // 备选关卡 + if (timeConfig.Stage_1 && timeConfig.Stage_1 !== '-') { + stages.push({ label: '关卡1', value: timeConfig.Stage_1 }) + } + if (timeConfig.Stage_2 && timeConfig.Stage_2 !== '-') { + stages.push({ label: '关卡2', value: timeConfig.Stage_2 }) + } + if (timeConfig.Stage_3 && timeConfig.Stage_3 !== '-') { + stages.push({ label: '关卡3', value: timeConfig.Stage_3 }) + } + + // 剩余关卡 + if (timeConfig.Stage_Remain && timeConfig.Stage_Remain !== '-') { + stages.push({ label: '剩余关卡', value: timeConfig.Stage_Remain }) + } + + return stages +} + // 处理脚本拖拽结束 const onScriptDragEnd = async () => { try { diff --git a/frontend/src/views/Scripts.vue b/frontend/src/views/Scripts.vue index d677de8..04b0375 100644 --- a/frontend/src/views/Scripts.vue +++ b/frontend/src/views/Scripts.vue @@ -56,6 +56,7 @@ ([]) // 增加:标记是否已经完成过一次脚本列表加载(成功或失败都算一次) const loadedOnce = ref(false) +// 当前计划表数据 +const currentPlanData = ref | null>(null) const typeSelectVisible = ref(false) const generalModeSelectVisible = ref(false) const templateSelectVisible = ref(false) @@ -312,6 +317,7 @@ const filteredTemplates = computed(() => { onMounted(() => { loadScripts() + loadCurrentPlan() }) const loadScripts = async () => { @@ -336,6 +342,21 @@ const loadScripts = async () => { } } +// 加载当前计划表数据 +const loadCurrentPlan = async () => { + try { + const response = await getPlans() + if (response.data && response.index && response.index.length > 0) { + // 获取第一个计划表的数据 + const firstPlanId = response.index[0].uid + currentPlanData.value = response.data[firstPlanId] || null + } + } catch (error) { + console.error('加载计划表数据失败:', error) + // 不显示错误消息,因为计划表数据是可选的 + } +} + const handleAddScript = () => { selectedType.value = 'MAA' typeSelectVisible.value = true