Merge remote-tracking branch 'upstream/feature/refactor' into feature/refactor

This commit is contained in:
2025-09-14 23:24:53 +08:00
13 changed files with 2833 additions and 1369 deletions

View File

@@ -62,9 +62,9 @@ const mainMenuItems = [
{ key: '/plans', label: '计划管理', icon: icon(CalendarOutlined) },
{ key: '/queue', label: '调度队列', icon: icon(UnorderedListOutlined) },
{ key: '/scheduler', label: '调度中心', icon: icon(ControlOutlined) },
{ key: '/history', label: '历史记录', icon: icon(HistoryOutlined) },
]
const bottomMenuItems = [
{ key: '/history', label: '历史记录', icon: icon(HistoryOutlined) },
{ key: '/settings', label: '设置', icon: icon(SettingOutlined) },
]

View File

@@ -37,24 +37,24 @@
type="primary"
ghost
size="middle"
@click="handleMAAConfig(script)"
@click="handleStartMAAConfig(script)"
>
<template #icon>
<SettingOutlined />
</template>
置MAA全局配置
置MAA
</a-button>
<a-button
v-if="script.type === 'MAA' && props.activeConnections.has(script.id)"
type="primary"
danger
size="middle"
@click="handleDisconnectMAA(script)"
style="background: #52c41a; border-color: #52c41a;"
@click="handleSaveMAAConfig(script)"
>
<template #icon>
<StopOutlined />
<SaveOutlined />
</template>
断开配置连接
保存配置
</a-button>
<a-button type="default" size="middle" @click="handleEdit(script)">
<template #icon>
@@ -291,8 +291,8 @@ import type { Script, User } from '../types/script'
import {
DeleteOutlined,
EditOutlined,
SaveOutlined,
SettingOutlined,
StopOutlined,
UserAddOutlined,
} from '@ant-design/icons-vue'
@@ -312,9 +312,9 @@ interface Emits {
(e: 'deleteUser', user: User): void
(e: 'maaConfig', script: Script): void
(e: 'startMaaConfig', script: Script): void
(e: 'disconnectMaa', script: Script): void
(e: 'saveMaaConfig', script: Script): void
(e: 'toggleUserStatus', user: User): void
}
@@ -350,12 +350,12 @@ const handleDeleteUser = (user: User) => {
emit('deleteUser', user)
}
const handleMAAConfig = (script: Script) => {
emit('maaConfig', script)
const handleStartMAAConfig = (script: Script) => {
emit('startMaaConfig', script)
}
const handleDisconnectMAA = (script: Script) => {
emit('disconnectMaa', script)
const handleSaveMAAConfig = (script: Script) => {
emit('saveMaaConfig', script)
}
const handleToggleUserStatus = (user: User) => {

File diff suppressed because it is too large Load Diff

View File

@@ -135,7 +135,7 @@
:placeholder="getPlaceholder(record.taskName)" class="config-input-number"
:controls="false" :disabled="isColumnDisabled(column.key)" />
</template>
<template v-else-if="['关卡选择', '备选关卡-1', '备选关卡-2', '备选关卡-3', '剩余理智'].includes(record.taskName)">
<template v-else-if="['关卡选择', '备选关卡-1', '备选关卡-2', '备选关卡-3', '剩余理智关卡'].includes(record.taskName)">
<a-select
v-model:value="record[column.key]"
size="small"
@@ -436,14 +436,14 @@ const tableData = ref([
{
key: 'SeriesNumb',
taskName: '连战次数',
ALL: '-1',
Monday: '-1',
Tuesday: '-1',
Wednesday: '-1',
Thursday: '-1',
Friday: '-1',
Saturday: '-1',
Sunday: '-1',
ALL: '0',
Monday: '0',
Tuesday: '0',
Wednesday: '0',
Thursday: '0',
Friday: '0',
Saturday: '0',
Sunday: '0',
},
{
key: 'Stage',
@@ -495,7 +495,7 @@ const tableData = ref([
},
{
key: 'Stage_Remain',
taskName: '剩余理智',
taskName: '剩余理智关卡',
ALL: '-',
Monday: '-',
Tuesday: '-',
@@ -535,10 +535,10 @@ const STAGE_DAILY_INFO = [
{ value: '1-7', text: '1-7', days: [1, 2, 3, 4, 5, 6, 7] },
{ value: 'R8-11', text: 'R8-11', days: [1, 2, 3, 4, 5, 6, 7] },
{ value: '12-17-HARD', text: '12-17-HARD', days: [1, 2, 3, 4, 5, 6, 7] },
{ value: 'LS-6', text: '经验-6/5', days: [1, 2, 3, 4, 5, 6, 7] },
{ value: 'CE-6', text: '龙门币-6/5', days: [2, 4, 6, 7] },
{ value: 'AP-5', text: '红票-5', days: [1, 4, 6, 7] },
{ value: 'CA-5', text: '技能-5', days: [2, 3, 5, 7] },
{ value: 'LS-6', text: '经验-6/5', days: [1, 2, 3, 4, 5, 6, 7] },
{ value: 'SK-5', text: '碳-5', days: [1, 3, 5, 6] },
{ value: 'PR-A-1', text: '奶/盾芯片', days: [1, 4, 5, 7] },
{ value: 'PR-A-2', text: '奶/盾芯片组', days: [1, 4, 5, 7] },
@@ -590,20 +590,20 @@ const getSelectOptions = (columnKey: string, taskName: string, currentValue?: st
switch (taskName) {
case '连战次数':
return [
{ label: '不选择', value: '0' },
{ label: 'AUTO', value: '0' },
{ label: '1', value: '1' },
{ label: '2', value: '2' },
{ label: '3', value: '3' },
{ label: '4', value: '4' },
{ label: '5', value: '5' },
{ label: '6', value: '6' },
{ label: 'AUTO', value: '-1' },
{ label: '不切换', value: '-1' },
]
case '关卡选择':
case '备选关卡-1':
case '备选关卡-2':
case '备选关卡-3':
case '剩余理智': {
case '剩余理智关卡': {
const dayNumber = getDayNumber(columnKey)
// 基础关卡选项
@@ -611,14 +611,14 @@ const getSelectOptions = (columnKey: string, taskName: string, currentValue?: st
if (dayNumber === 0) {
// 如果是全局列,显示所有选项
baseOptions = STAGE_DAILY_INFO.map(stage => ({
label: stage.text,
label: taskName === '剩余理智关卡' && stage.value === '-' ? '不选择' : stage.text,
value: stage.value,
isCustom: false
}))
} else {
// 根据星期过滤可用的关卡
baseOptions = STAGE_DAILY_INFO.filter(stage => stage.days.includes(dayNumber)).map(stage => ({
label: stage.text,
label: taskName === '剩余理智关卡' && stage.value === '-' ? '不选择' : stage.text,
value: stage.value,
isCustom: false
}))
@@ -670,8 +670,8 @@ const getPlaceholder = (taskName: string) => {
case '备选关卡-2':
case '备选关卡-3':
return '1-7'
case '剩余理智':
return '-'
case '剩余理智关卡':
return '不选择'
default:
return '请选择'
}
@@ -1561,52 +1561,78 @@ const disableAllStages = (stageValue: string) => {
/* 任务名称单元格背景色 */
.config-table :deep(.task-row-MedicineNumb td:first-child) {
background: rgba(59, 130, 246, 0.1);
background: #EBF4FF !important; /* 不透明的蓝色背景 */
color: #3B82F6;
font-weight: 500;
}
.config-table :deep(.ant-table-tbody > tr.task-row-MedicineNumb:hover > td:first-child) {
background: rgba(59, 130, 246, 0.2);
background: #DBEAFE !important; /* 悬停时稍深的蓝色 */
}
.config-table :deep(.task-row-SeriesNumb td:first-child) {
background: rgba(34, 197, 94, 0.1);
background: #ECFDF5 !important; /* 不透明的绿色背景 */
color: #22C55E;
font-weight: 500;
}
.config-table :deep(.ant-table-tbody > tr.task-row-SeriesNumb:hover > td:first-child) {
background: rgba(34, 197, 94, 0.2);
background: #D1FAE5 !important; /* 悬停时稍深的绿色 */
}
.config-table :deep(.task-row-Stage td:first-child) {
background: rgba(249, 115, 22, 0.1);
background: #FFF7ED !important; /* 不透明的橙色背景 */
color: #F97316;
font-weight: 500;
}
.config-table :deep(.ant-table-tbody > tr.task-row-Stage:hover > td:first-child) {
background: rgba(249, 115, 22, 0.2);
background: #FED7AA !important; /* 悬停时稍深的橙色 */
}
.config-table :deep(.task-row-Stage_1 td:first-child),
.config-table :deep(.task-row-Stage_2 td:first-child),
.config-table :deep(.task-row-Stage_3 td:first-child) {
background: rgba(168, 85, 247, 0.1);
background: #FAF5FF !important; /* 不透明的紫色背景 */
color: #A855F7;
font-weight: 500;
}
.config-table :deep(.ant-table-tbody > tr.task-row-Stage_1:hover > td:first-child),
.config-table :deep(.ant-table-tbody > tr.task-row-Stage_2:hover > td:first-child),
.config-table :deep(.ant-table-tbody > tr.task-row-Stage_3:hover > td:first-child) {
background: rgba(168, 85, 247, 0.2);
background: #F3E8FF !important; /* 悬停时稍深的紫色 */
}
.config-table :deep(.task-row-Stage_Remain td:first-child) {
background: rgba(14, 165, 233, 0.1);
background: #F0F9FF !important; /* 不透明的天蓝色背景 */
color: #0EA5E9;
font-weight: 500;
}
.config-table :deep(.ant-table-tbody > tr.task-row-Stage_Remain:hover > td:first-child) {
background: rgba(14, 165, 233, 0.2);
background: #E0F2FE !important; /* 悬停时稍深的天蓝色 */
}
/* 确保固定列在滚动时背景不透明 */
.config-table :deep(.ant-table-fixed-left) {
background: var(--ant-color-bg-container) !important;
}
.config-table :deep(.ant-table-thead > tr > th.ant-table-fixed-left) {
background: var(--ant-color-bg-container) !important;
border-right: 1px solid var(--ant-color-border);
box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}
/* 专门处理"配置项"表头单元格 */
.config-table :deep(.ant-table-thead > tr > th:first-child) {
background: var(--ant-color-bg-container) !important;
border-right: 1px solid var(--ant-color-border);
box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
position: relative;
z-index: 2;
}
.config-table :deep(.ant-table-tbody > tr > td.ant-table-fixed-left) {
background: inherit !important;
border-right: 1px solid var(--ant-color-border-secondary);
box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}
/* 禁用列标题样式 */

File diff suppressed because it is too large Load Diff

View File

@@ -40,8 +40,8 @@
@add-user="handleAddUser"
@edit-user="handleEditUser"
@delete-user="handleDeleteUser"
@maa-config="handleMAAConfig"
@disconnect-maa="handleDisconnectMAA"
@start-maa-config="handleStartMAAConfig"
@save-maa-config="handleSaveMAAConfig"
@toggle-user-status="handleToggleUserStatus"
/>
@@ -232,6 +232,8 @@ import { useScriptApi } from '@/composables/useScriptApi'
import { useUserApi } from '@/composables/useUserApi'
import { useWebSocket } from '@/composables/useWebSocket'
import { useTemplateApi, type WebConfigTemplate } from '@/composables/useTemplateApi'
import { Service } from '@/api/services/Service'
import { TaskCreateIn } from '@/api/models/TaskCreateIn'
import MarkdownIt from 'markdown-it'
const router = useRouter()
@@ -494,51 +496,89 @@ const handleDeleteUser = async (user: User) => {
}
}
const handleMAAConfig = async (script: Script) => {
const handleStartMAAConfig = async (script: Script) => {
try {
// 检查是否已有连接
const existingConnection = activeConnections.value.get(script.id)
if (existingConnection) {
message.warning('该脚本已在配置中,请先断开连接')
message.warning('该脚本已在配置中,请先保存配置')
return
}
// 新订阅
subscribe(script.id, {
onError: error => {
console.error(`脚本 ${script.name} 连接错误:`, error)
message.error(`MAA配置连接失败: ${error}`)
activeConnections.value.delete(script.id)
},
// 调用启动配置任务API
const response = await Service.addTaskApiDispatchStartPost({
taskId: script.id,
mode: TaskCreateIn.mode.SettingScriptMode
})
// 记录连接
activeConnections.value.set(script.id, script.id)
message.success(`已开始配置 ${script.name}`)
// 可选设置自动断开连接的定时器比如30分钟后
setTimeout(
() => {
if (activeConnections.value.has(script.id)) {
unsubscribe(script.id)
if (response.code === 200) {
// 订阅WebSocket消息
subscribe(response.websocketId, {
onError: error => {
console.error(`脚本 ${script.name} 连接错误:`, error)
message.error(`MAA配置连接失败: ${error}`)
activeConnections.value.delete(script.id)
message.info(`${script.name} 配置会话已超时断开`)
},
onResult: (data: any) => {
// 处理配置完成消息(兼容任何结构)
if (data.Accomplish) {
message.success(`${script.name} 配置已完成`)
activeConnections.value.delete(script.id)
}
}
},
30 * 60 * 1000
) // 30分钟
})
// 记录连接和websocketId
activeConnections.value.set(script.id, response.websocketId)
message.success(`已启动 ${script.name} 的MAA配置`)
// 设置自动断开连接的定时器30分钟后
setTimeout(
() => {
if (activeConnections.value.has(script.id)) {
const wsId = activeConnections.value.get(script.id)
if (wsId) {
unsubscribe(wsId)
}
activeConnections.value.delete(script.id)
message.info(`${script.name} 配置会话已超时断开`)
}
},
30 * 60 * 1000
) // 30分钟
} else {
message.error(response.message || '启动MAA配置失败')
}
} catch (error) {
console.error('MAA配置失败:', error)
message.error('MAA配置失败')
console.error('启动MAA配置失败:', error)
message.error('启动MAA配置失败')
}
}
const handleDisconnectMAA = (script: Script) => {
const connectionId = activeConnections.value.get(script.id)
if (connectionId) {
unsubscribe(script.id)
activeConnections.value.delete(script.id)
message.success(`已断开 ${script.name} 的配置连接`)
const handleSaveMAAConfig = async (script: Script) => {
try {
const websocketId = activeConnections.value.get(script.id)
if (!websocketId) {
message.error('未找到活动的配置会话')
return
}
// 调用停止配置任务API
const response = await Service.stopTaskApiDispatchStopPost({
taskId: websocketId
})
if (response.code === 200) {
// 取消订阅
unsubscribe(websocketId)
activeConnections.value.delete(script.id)
message.success(`${script.name} 的配置已保存`)
} else {
message.error(response.message || '保存配置失败')
}
} catch (error) {
console.error('保存MAA配置失败:', error)
message.error('保存MAA配置失败')
}
}

View File

@@ -11,8 +11,6 @@ import { useUpdateChecker } from '@/composables/useUpdateChecker'
import { Service, type VersionOut } from '@/api'
import UpdateModal from '@/components/UpdateModal.vue'
import { mirrorManager } from '@/utils/mirrorManager'
import { request } from '@/api/core/request'
import { OpenAPI } from '@/api'
// 引入拆分后的 Tab 组件
import TabBasic from './TabBasic.vue'
@@ -243,7 +241,7 @@ const testingNotify = ref(false)
const testNotify = async () => {
testingNotify.value = true
try {
const res: any = await request<any>(OpenAPI, { method: 'POST', url: '/api/setting/test_notify' })
const res = await Service.testNotifyApiSettingTestNotifyPost()
if (res?.code && res.code !== 200) message.warning(res?.message || '测试通知发送结果未知')
else message.success('测试通知已发送')
} catch (e) {