feat(script): 添加脚本删除功能并优化脚本编辑界面

- 在 ScriptEdit.vue 中添加删除脚本 API 响应类型
- 在 Scripts.vue 和 ScriptTable.vue 中移除冗余样式
- 在 tsconfig.json 中添加路径别名配置
- 重构 useScriptApi.ts 中的 deleteScript 函数,实现真正的脚本删除
This commit is contained in:
2025-08-04 15:49:00 +08:00
parent 19aab99398
commit 5531f6e87a
7 changed files with 189 additions and 239 deletions

View File

@@ -292,7 +292,6 @@ const handleDeleteUser = (user: User) => {
</script> </script>
<style scoped> <style scoped>
/* 现代化表格样式 */
.modern-table :deep(.ant-table) { .modern-table :deep(.ant-table) {
background: var(--ant-color-bg-container); background: var(--ant-color-bg-container);
border-radius: 12px; border-radius: 12px;

View File

@@ -6,8 +6,9 @@ import type {
GeneralScriptConfig, GeneralScriptConfig,
GetScriptsResponse, GetScriptsResponse,
ScriptDetail, ScriptDetail,
ScriptIndexItem ScriptIndexItem,
} from '@/types/script' DeleteScriptResponse
} from '../types/script.ts'
const API_BASE_URL = 'http://localhost:8000/api' const API_BASE_URL = 'http://localhost:8000/api'
@@ -173,24 +174,35 @@ export function useScriptApi() {
} }
} }
// 删除脚本(暂时模拟) // 删除脚本
const deleteScript = async (scriptId: string) => { const deleteScript = async (scriptId: string): Promise<boolean> => {
loading.value = true loading.value = true
error.value = null error.value = null
try { try {
const response = await fetch(`${API_BASE_URL}/delete/scripts/${scriptId}`, { const response = await fetch(`${API_BASE_URL}/delete/scripts`, {
method: 'DELETE', method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ scriptId }),
}) })
if (!response.ok) { if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`) throw new Error(`HTTP error! status: ${response.status}`)
} }
return await response.json() const apiResponse: DeleteScriptResponse = await response.json()
// 根据code判断是否成功非200就是不成功
if (apiResponse.code !== 200) {
throw new Error(apiResponse.message || '删除脚本失败')
}
return true
} catch (err) { } catch (err) {
error.value = err instanceof Error ? err.message : '删除脚本失败' error.value = err instanceof Error ? err.message : '删除脚本失败'
return null return false
} finally { } finally {
loading.value = false loading.value = false
} }

View File

@@ -3,7 +3,9 @@ export {}
declare global { declare global {
interface Window { interface Window {
electronAPI: { electronAPI: {
openDevTools: () => void openDevTools: () => void,
selectFolder: () => Promise<string | null>
selectFile: (filters?: Array<{ name: string; extensions: string[] }>) => Promise<string | null>
} }
} }
} }

View File

@@ -168,4 +168,11 @@ export interface ScriptDetail {
name: string name: string
config: MAAScriptConfig | GeneralScriptConfig config: MAAScriptConfig | GeneralScriptConfig
createTime?: string createTime?: string
}
// 删除脚本API响应
export interface DeleteScriptResponse {
code: number
status: string
message: string
} }

View File

@@ -4,45 +4,34 @@
<div class="header-nav"> <div class="header-nav">
<a-breadcrumb class="breadcrumb"> <a-breadcrumb class="breadcrumb">
<a-breadcrumb-item> <a-breadcrumb-item>
<router-link to="/scripts" class="breadcrumb-link"> <router-link to="/scripts" class="breadcrumb-link"> 脚本管理</router-link>
脚本管理
</router-link>
</a-breadcrumb-item> </a-breadcrumb-item>
<a-breadcrumb-item> <a-breadcrumb-item>
<div class="breadcrumb-current"> <div class="breadcrumb-current">
<img <img
v-if="formData.type === 'MAA'" v-if="formData.type === 'MAA'"
src="@/assets/MAA.png" src="@/assets/MAA.png"
alt="MAA" alt="MAA"
class="breadcrumb-logo" class="breadcrumb-logo"
/> />
<img <img v-else src="@/assets/AUTO_MAA.png" alt="AUTO MAA" class="breadcrumb-logo" />
v-else
src="@/assets/AUTO_MAA.png"
alt="AUTO MAA"
class="breadcrumb-logo"
/>
编辑脚本 编辑脚本
</div> </div>
</a-breadcrumb-item> </a-breadcrumb-item>
</a-breadcrumb> </a-breadcrumb>
</div> </div>
<a-space size="middle"> <a-space size="middle">
<a-button <a-button size="large" @click="handleCancel" class="cancel-button">
size="large"
@click="handleCancel"
class="cancel-button"
>
<template #icon> <template #icon>
<CloseOutlined /> <CloseOutlined />
</template> </template>
取消 取消
</a-button> </a-button>
<a-button <a-button
type="primary" type="primary"
size="large" size="large"
:loading="loading" :loading="loading"
@click="handleSave" @click="handleSave"
class="save-button" class="save-button"
> >
@@ -55,16 +44,9 @@
</div> </div>
<div class="script-edit-content"> <div class="script-edit-content">
<a-card <a-card :title="getCardTitle()" :loading="pageLoading" class="config-card">
:title="getCardTitle()"
:loading="pageLoading"
class="config-card"
>
<template #extra> <template #extra>
<a-tag <a-tag :color="formData.type === 'MAA' ? 'blue' : 'green'" class="type-tag">
:color="formData.type === 'MAA' ? 'blue' : 'green'"
class="type-tag"
>
{{ formData.type }} {{ formData.type }}
</a-tag> </a-tag>
</template> </template>
@@ -92,8 +74,8 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input <a-input
v-model:value="formData.name" v-model:value="formData.name"
placeholder="请输入脚本名称" placeholder="请输入脚本名称"
size="large" size="large"
class="modern-input" class="modern-input"
@@ -110,8 +92,8 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-select <a-select
v-model:value="formData.type" v-model:value="formData.type"
disabled disabled
size="large" size="large"
class="modern-select" class="modern-select"
@@ -143,18 +125,14 @@
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-group compact class="path-input-group"> <a-input-group compact class="path-input-group">
<a-input <a-input
v-model:value="maaConfig.Info.Path" v-model:value="maaConfig.Info.Path"
placeholder="请选择MAA.exe所在的文件夹" placeholder="请选择MAA.exe所在的文件夹"
size="large" size="large"
class="path-input" class="path-input"
readonly readonly
/> />
<a-button <a-button size="large" @click="selectMAAPath" class="path-button">
size="large"
@click="selectMAAPath"
class="path-button"
>
<template #icon> <template #icon>
<FolderOpenOutlined /> <FolderOpenOutlined />
</template> </template>
@@ -165,7 +143,7 @@
</a-col> </a-col>
</a-row> </a-row>
</div> </div>
<!-- 运行配置 --> <!-- 运行配置 -->
<div class="form-section"> <div class="form-section">
<div class="section-header"> <div class="section-header">
@@ -182,13 +160,13 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-number <a-input-number
v-model:value="maaConfig.Run.ADBSearchRange" v-model:value="maaConfig.Run.ADBSearchRange"
:min="0" :min="0"
:max="10" :max="10"
size="large" size="large"
class="modern-number-input" class="modern-number-input"
style="width: 100%" style="width: 100%"
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
@@ -202,13 +180,13 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-number <a-input-number
v-model:value="maaConfig.Run.AnnihilationTimeLimit" v-model:value="maaConfig.Run.AnnihilationTimeLimit"
:min="1" :min="1"
:max="120" :max="120"
size="large" size="large"
class="modern-number-input" class="modern-number-input"
style="width: 100%" style="width: 100%"
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
@@ -222,18 +200,18 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-number <a-input-number
v-model:value="maaConfig.Run.ProxyTimesLimit" v-model:value="maaConfig.Run.ProxyTimesLimit"
:min="0" :min="0"
:max="999" :max="999"
size="large" size="large"
class="modern-number-input" class="modern-number-input"
style="width: 100%" style="width: 100%"
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="8"> <a-col :span="8">
<a-form-item> <a-form-item>
@@ -245,13 +223,13 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-number <a-input-number
v-model:value="maaConfig.Run.RoutineTimeLimit" v-model:value="maaConfig.Run.RoutineTimeLimit"
:min="1" :min="1"
:max="180" :max="180"
size="large" size="large"
class="modern-number-input" class="modern-number-input"
style="width: 100%" style="width: 100%"
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
@@ -265,13 +243,13 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-number <a-input-number
v-model:value="maaConfig.Run.RunTimesLimit" v-model:value="maaConfig.Run.RunTimesLimit"
:min="1" :min="1"
:max="10" :max="10"
size="large" size="large"
class="modern-number-input" class="modern-number-input"
style="width: 100%" style="width: 100%"
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
@@ -285,7 +263,7 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-select <a-select
v-model:value="maaConfig.Run.TaskTransitionMethod" v-model:value="maaConfig.Run.TaskTransitionMethod"
size="large" size="large"
class="modern-select" class="modern-select"
@@ -296,7 +274,7 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="12"> <a-col :span="12">
<a-form-item> <a-form-item>
@@ -308,7 +286,7 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-switch <a-switch
v-model:checked="maaConfig.Run.AnnihilationWeeklyLimit" v-model:checked="maaConfig.Run.AnnihilationWeeklyLimit"
size="default" size="default"
class="modern-switch" class="modern-switch"
@@ -338,18 +316,14 @@
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-group compact class="path-input-group"> <a-input-group compact class="path-input-group">
<a-input <a-input
v-model:value="generalConfig.Info.RootPath" v-model:value="generalConfig.Info.RootPath"
placeholder="请选择脚本根目录" placeholder="请选择脚本根目录"
size="large" size="large"
class="path-input" class="path-input"
readonly readonly
/> />
<a-button <a-button size="large" @click="selectRootPath" class="path-button">
size="large"
@click="selectRootPath"
class="path-button"
>
<template #icon> <template #icon>
<FolderOpenOutlined /> <FolderOpenOutlined />
</template> </template>
@@ -360,7 +334,7 @@
</a-col> </a-col>
</a-row> </a-row>
</div> </div>
<!-- 游戏配置 --> <!-- 游戏配置 -->
<div class="form-section"> <div class="form-section">
<div class="section-header"> <div class="section-header">
@@ -378,18 +352,14 @@
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-group compact class="path-input-group"> <a-input-group compact class="path-input-group">
<a-input <a-input
v-model:value="generalConfig.Game.Path" v-model:value="generalConfig.Game.Path"
placeholder="请选择游戏可执行文件" placeholder="请选择游戏可执行文件"
size="large" size="large"
class="path-input" class="path-input"
readonly readonly
/> />
<a-button <a-button size="large" @click="selectGamePath" class="path-button">
size="large"
@click="selectGamePath"
class="path-button"
>
<template #icon> <template #icon>
<FileOutlined /> <FileOutlined />
</template> </template>
@@ -408,8 +378,8 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input <a-input
v-model:value="generalConfig.Game.Arguments" v-model:value="generalConfig.Game.Arguments"
placeholder="请输入启动参数" placeholder="请输入启动参数"
size="large" size="large"
class="modern-input" class="modern-input"
@@ -417,7 +387,7 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="8"> <a-col :span="8">
<a-form-item> <a-form-item>
@@ -429,7 +399,7 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-select <a-select
v-model:value="generalConfig.Game.Style" v-model:value="generalConfig.Game.Style"
size="large" size="large"
class="modern-select" class="modern-select"
@@ -449,13 +419,13 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-number <a-input-number
v-model:value="generalConfig.Game.WaitTime" v-model:value="generalConfig.Game.WaitTime"
:min="0" :min="0"
:max="300" :max="300"
size="large" size="large"
class="modern-number-input" class="modern-number-input"
style="width: 100%" style="width: 100%"
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
@@ -469,7 +439,7 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-switch <a-switch
v-model:checked="generalConfig.Game.Enabled" v-model:checked="generalConfig.Game.Enabled"
size="default" size="default"
class="modern-switch" class="modern-switch"
@@ -477,7 +447,7 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="12"> <a-col :span="12">
<a-form-item> <a-form-item>
@@ -489,7 +459,7 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-switch <a-switch
v-model:checked="generalConfig.Game.IfForceClose" v-model:checked="generalConfig.Game.IfForceClose"
size="default" size="default"
class="modern-switch" class="modern-switch"
@@ -498,7 +468,7 @@
</a-col> </a-col>
</a-row> </a-row>
</div> </div>
<!-- 运行配置 --> <!-- 运行配置 -->
<div class="form-section"> <div class="form-section">
<div class="section-header"> <div class="section-header">
@@ -515,13 +485,13 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-number <a-input-number
v-model:value="generalConfig.Run.ProxyTimesLimit" v-model:value="generalConfig.Run.ProxyTimesLimit"
:min="0" :min="0"
:max="999" :max="999"
size="large" size="large"
class="modern-number-input" class="modern-number-input"
style="width: 100%" style="width: 100%"
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
@@ -535,13 +505,13 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-number <a-input-number
v-model:value="generalConfig.Run.RunTimeLimit" v-model:value="generalConfig.Run.RunTimeLimit"
:min="1" :min="1"
:max="300" :max="300"
size="large" size="large"
class="modern-number-input" class="modern-number-input"
style="width: 100%" style="width: 100%"
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
@@ -555,19 +525,19 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-number <a-input-number
v-model:value="generalConfig.Run.RunTimesLimit" v-model:value="generalConfig.Run.RunTimesLimit"
:min="1" :min="1"
:max="10" :max="10"
size="large" size="large"
class="modern-number-input" class="modern-number-input"
style="width: 100%" style="width: 100%"
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
</div> </div>
<!-- 脚本配置 --> <!-- 脚本配置 -->
<div class="form-section"> <div class="form-section">
<div class="section-header"> <div class="section-header">
@@ -585,18 +555,14 @@
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-group compact class="path-input-group"> <a-input-group compact class="path-input-group">
<a-input <a-input
v-model:value="generalConfig.Script.ScriptPath" v-model:value="generalConfig.Script.ScriptPath"
placeholder="请选择脚本文件" placeholder="请选择脚本文件"
size="large" size="large"
class="path-input" class="path-input"
readonly readonly
/> />
<a-button <a-button size="large" @click="selectScriptPath" class="path-button">
size="large"
@click="selectScriptPath"
class="path-button"
>
<template #icon> <template #icon>
<FileOutlined /> <FileOutlined />
</template> </template>
@@ -616,18 +582,14 @@
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-group compact class="path-input-group"> <a-input-group compact class="path-input-group">
<a-input <a-input
v-model:value="generalConfig.Script.ConfigPath" v-model:value="generalConfig.Script.ConfigPath"
placeholder="请选择配置文件" placeholder="请选择配置文件"
size="large" size="large"
class="path-input" class="path-input"
readonly readonly
/> />
<a-button <a-button size="large" @click="selectConfigPath" class="path-button">
size="large"
@click="selectConfigPath"
class="path-button"
>
<template #icon> <template #icon>
<FileOutlined /> <FileOutlined />
</template> </template>
@@ -637,7 +599,7 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="12"> <a-col :span="12">
<a-form-item> <a-form-item>
@@ -649,8 +611,8 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input <a-input
v-model:value="generalConfig.Script.Arguments" v-model:value="generalConfig.Script.Arguments"
placeholder="请输入脚本参数" placeholder="请输入脚本参数"
size="large" size="large"
class="modern-input" class="modern-input"
@@ -667,8 +629,8 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input <a-input
v-model:value="generalConfig.Script.ConfigPathMode" v-model:value="generalConfig.Script.ConfigPathMode"
placeholder="配置路径模式" placeholder="配置路径模式"
size="large" size="large"
class="modern-input" class="modern-input"
@@ -676,7 +638,7 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="12"> <a-col :span="12">
<a-form-item> <a-form-item>
@@ -689,18 +651,14 @@
</a-tooltip> </a-tooltip>
</template> </template>
<a-input-group compact class="path-input-group"> <a-input-group compact class="path-input-group">
<a-input <a-input
v-model:value="generalConfig.Script.LogPath" v-model:value="generalConfig.Script.LogPath"
placeholder="请选择日志目录" placeholder="请选择日志目录"
size="large" size="large"
class="path-input" class="path-input"
readonly readonly
/> />
<a-button <a-button size="large" @click="selectLogPath" class="path-button">
size="large"
@click="selectLogPath"
class="path-button"
>
<template #icon> <template #icon>
<FolderOpenOutlined /> <FolderOpenOutlined />
</template> </template>
@@ -719,8 +677,8 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-input <a-input
v-model:value="generalConfig.Script.LogPathFormat" v-model:value="generalConfig.Script.LogPathFormat"
placeholder="日志格式" placeholder="日志格式"
size="large" size="large"
class="modern-input" class="modern-input"
@@ -728,7 +686,7 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="12"> <a-col :span="12">
<a-form-item> <a-form-item>
@@ -740,7 +698,7 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-switch <a-switch
v-model:checked="generalConfig.Script.IfTrackProcess" v-model:checked="generalConfig.Script.IfTrackProcess"
size="default" size="default"
class="modern-switch" class="modern-switch"
@@ -757,7 +715,7 @@
</span> </span>
</a-tooltip> </a-tooltip>
</template> </template>
<a-select <a-select
v-model:value="generalConfig.Script.UpdateConfigMode" v-model:value="generalConfig.Script.UpdateConfigMode"
size="large" size="large"
class="modern-select" class="modern-select"
@@ -778,19 +736,18 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, onMounted } from 'vue' import { onMounted, reactive, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { message } from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue' import type { FormInstance } from 'ant-design-vue'
import type { ScriptType, MAAScriptConfig, GeneralScriptConfig } from '@/types/script' import { message } from 'ant-design-vue'
import { useScriptApi } from '@/composables/useScriptApi' import type { GeneralScriptConfig, MAAScriptConfig, ScriptType } from '../types/script'
import { import { useScriptApi } from '../composables/useScriptApi'
SaveOutlined, import {
CloseOutlined, CloseOutlined,
FolderOpenOutlined,
FileOutlined, FileOutlined,
SettingOutlined, FolderOpenOutlined,
QuestionCircleOutlined QuestionCircleOutlined,
SaveOutlined,
} from '@ant-design/icons-vue' } from '@ant-design/icons-vue'
const route = useRoute() const route = useRoute()
@@ -803,14 +760,14 @@ const scriptId = route.params.id as string
const formData = reactive({ const formData = reactive({
name: '', name: '',
type: 'MAA' as ScriptType type: 'MAA' as ScriptType,
}) })
// MAA配置 // MAA配置
const maaConfig = reactive<MAAScriptConfig>({ const maaConfig = reactive<MAAScriptConfig>({
Info: { Info: {
Name: '', Name: '',
Path: '.' Path: '.',
}, },
Run: { Run: {
ADBSearchRange: 0, ADBSearchRange: 0,
@@ -819,13 +776,13 @@ const maaConfig = reactive<MAAScriptConfig>({
ProxyTimesLimit: 0, ProxyTimesLimit: 0,
RoutineTimeLimit: 10, RoutineTimeLimit: 10,
RunTimesLimit: 3, RunTimesLimit: 3,
TaskTransitionMethod: 'ExitEmulator' TaskTransitionMethod: 'ExitEmulator',
}, },
SubConfigsInfo: { SubConfigsInfo: {
UserData: { UserData: {
instances: [] instances: [],
} },
} },
}) })
// General配置 // General配置
@@ -836,16 +793,16 @@ const generalConfig = reactive<GeneralScriptConfig>({
IfForceClose: false, IfForceClose: false,
Path: '.', Path: '.',
Style: 'Emulator', Style: 'Emulator',
WaitTime: 0 WaitTime: 0,
}, },
Info: { Info: {
Name: '', Name: '',
RootPath: '.' RootPath: '.',
}, },
Run: { Run: {
ProxyTimesLimit: 0, ProxyTimesLimit: 0,
RunTimeLimit: 10, RunTimeLimit: 10,
RunTimesLimit: 3 RunTimesLimit: 3,
}, },
Script: { Script: {
Arguments: '', Arguments: '',
@@ -860,18 +817,18 @@ const generalConfig = reactive<GeneralScriptConfig>({
LogTimeFormat: '%Y-%m-%d %H:%M:%S', LogTimeFormat: '%Y-%m-%d %H:%M:%S',
ScriptPath: '.', ScriptPath: '.',
SuccessLog: '', SuccessLog: '',
UpdateConfigMode: 'Never' UpdateConfigMode: 'Never',
}, },
SubConfigsInfo: { SubConfigsInfo: {
UserData: { UserData: {
instances: [] instances: [],
} },
} },
}) })
const rules = { const rules = {
name: [{ required: true, message: '请输入脚本名称', trigger: 'blur' }], name: [{ required: true, message: '请输入脚本名称', trigger: 'blur' }],
type: [{ required: true, message: '请选择脚本类型', trigger: 'change' }] type: [{ required: true, message: '请选择脚本类型', trigger: 'change' }],
} }
onMounted(async () => { onMounted(async () => {
@@ -887,7 +844,7 @@ const loadScript = async () => {
// 使用API返回的新建脚本数据 // 使用API返回的新建脚本数据
const scriptData = routeState.scriptData const scriptData = routeState.scriptData
formData.type = scriptData.type formData.type = scriptData.type
if (scriptData.type === 'MAA') { if (scriptData.type === 'MAA') {
const config = scriptData.config as MAAScriptConfig const config = scriptData.config as MAAScriptConfig
formData.name = config.Info.Name || '新建MAA脚本' formData.name = config.Info.Name || '新建MAA脚本'
@@ -910,16 +867,16 @@ const loadScript = async () => {
} else { } else {
// 编辑现有脚本时从API获取数据 // 编辑现有脚本时从API获取数据
const scriptDetail = await getScript(scriptId) const scriptDetail = await getScript(scriptId)
if (!scriptDetail) { if (!scriptDetail) {
message.error('脚本不存在或加载失败') message.error('脚本不存在或加载失败')
router.push('/scripts') router.push('/scripts')
return return
} }
formData.type = scriptDetail.type formData.type = scriptDetail.type
formData.name = scriptDetail.name formData.name = scriptDetail.name
if (scriptDetail.type === 'MAA') { if (scriptDetail.type === 'MAA') {
Object.assign(maaConfig, scriptDetail.config as MAAScriptConfig) Object.assign(maaConfig, scriptDetail.config as MAAScriptConfig)
} else { } else {
@@ -938,14 +895,14 @@ const loadScript = async () => {
const handleSave = async () => { const handleSave = async () => {
try { try {
await formRef.value?.validate() await formRef.value?.validate()
const config = formData.type === 'MAA' ? maaConfig : generalConfig const config = formData.type === 'MAA' ? maaConfig : generalConfig
if (formData.type === 'MAA') { if (formData.type === 'MAA') {
maaConfig.Info.Name = formData.name maaConfig.Info.Name = formData.name
} else { } else {
generalConfig.Info.Name = formData.name generalConfig.Info.Name = formData.name
} }
const result = await updateScript(scriptId, config) const result = await updateScript(scriptId, config)
if (result) { if (result) {
message.success('脚本更新成功') message.success('脚本更新成功')
@@ -967,7 +924,7 @@ const selectMAAPath = async () => {
message.error('文件选择功能不可用,请在 Electron 环境中运行') message.error('文件选择功能不可用,请在 Electron 环境中运行')
return return
} }
const path = await window.electronAPI.selectFolder() const path = await window.electronAPI.selectFolder()
if (path) { if (path) {
maaConfig.Info.Path = path maaConfig.Info.Path = path
@@ -985,7 +942,7 @@ const selectRootPath = async () => {
message.error('文件选择功能不可用,请在 Electron 环境中运行') message.error('文件选择功能不可用,请在 Electron 环境中运行')
return return
} }
const path = await window.electronAPI.selectFolder() const path = await window.electronAPI.selectFolder()
if (path) { if (path) {
generalConfig.Info.RootPath = path generalConfig.Info.RootPath = path
@@ -1003,10 +960,10 @@ const selectGamePath = async () => {
message.error('文件选择功能不可用,请在 Electron 环境中运行') message.error('文件选择功能不可用,请在 Electron 环境中运行')
return return
} }
const path = await window.electronAPI.selectFile([ const path = await window.electronAPI.selectFile([
{ name: '可执行文件', extensions: ['exe'] }, { name: '可执行文件', extensions: ['exe'] },
{ name: '所有文件', extensions: ['*'] } { name: '所有文件', extensions: ['*'] },
]) ])
if (path) { if (path) {
generalConfig.Game.Path = path generalConfig.Game.Path = path
@@ -1024,14 +981,14 @@ const selectScriptPath = async () => {
message.error('文件选择功能不可用,请在 Electron 环境中运行') message.error('文件选择功能不可用,请在 Electron 环境中运行')
return return
} }
const path = await window.electronAPI.selectFile([ const path = await window.electronAPI.selectFile([
{ name: '脚本文件', extensions: ['py', 'js', 'bat', 'sh', 'cmd'] }, { name: '脚本文件', extensions: ['py', 'js', 'bat', 'sh', 'cmd'] },
{ name: 'Python 脚本', extensions: ['py'] }, { name: 'Python 脚本', extensions: ['py'] },
{ name: 'JavaScript 脚本', extensions: ['js'] }, { name: 'JavaScript 脚本', extensions: ['js'] },
{ name: '批处理文件', extensions: ['bat', 'cmd'] }, { name: '批处理文件', extensions: ['bat', 'cmd'] },
{ name: 'Shell 脚本', extensions: ['sh'] }, { name: 'Shell 脚本', extensions: ['sh'] },
{ name: '所有文件', extensions: ['*'] } { name: '所有文件', extensions: ['*'] },
]) ])
if (path) { if (path) {
generalConfig.Script.ScriptPath = path generalConfig.Script.ScriptPath = path
@@ -1049,14 +1006,14 @@ const selectConfigPath = async () => {
message.error('文件选择功能不可用,请在 Electron 环境中运行') message.error('文件选择功能不可用,请在 Electron 环境中运行')
return return
} }
const path = await window.electronAPI.selectFile([ const path = await window.electronAPI.selectFile([
{ name: '配置文件', extensions: ['json', 'yaml', 'yml', 'ini', 'conf', 'toml'] }, { name: '配置文件', extensions: ['json', 'yaml', 'yml', 'ini', 'conf', 'toml'] },
{ name: 'JSON 文件', extensions: ['json'] }, { name: 'JSON 文件', extensions: ['json'] },
{ name: 'YAML 文件', extensions: ['yaml', 'yml'] }, { name: 'YAML 文件', extensions: ['yaml', 'yml'] },
{ name: 'INI 文件', extensions: ['ini', 'conf'] }, { name: 'INI 文件', extensions: ['ini', 'conf'] },
{ name: 'TOML 文件', extensions: ['toml'] }, { name: 'TOML 文件', extensions: ['toml'] },
{ name: '所有文件', extensions: ['*'] } { name: '所有文件', extensions: ['*'] },
]) ])
if (path) { if (path) {
generalConfig.Script.ConfigPath = path generalConfig.Script.ConfigPath = path
@@ -1074,7 +1031,7 @@ const selectLogPath = async () => {
message.error('文件选择功能不可用,请在 Electron 环境中运行') message.error('文件选择功能不可用,请在 Electron 环境中运行')
return return
} }
const path = await window.electronAPI.selectFolder() const path = await window.electronAPI.selectFolder()
if (path) { if (path) {
generalConfig.Script.LogPath = path generalConfig.Script.LogPath = path
@@ -1145,9 +1102,6 @@ const getCardTitle = () => {
transition: all 0.3s ease; transition: all 0.3s ease;
} }
/* 按钮样式 */ /* 按钮样式 */
.cancel-button { .cancel-button {
padding: 0 12px; padding: 0 12px;
@@ -1188,7 +1142,7 @@ const getCardTitle = () => {
.config-card { .config-card {
border-radius: 16px; border-radius: 16px;
box-shadow: box-shadow:
0 4px 20px rgba(0, 0, 0, 0.08), 0 4px 20px rgba(0, 0, 0, 0.08),
0 1px 3px rgba(0, 0, 0, 0.1); 0 1px 3px rgba(0, 0, 0, 0.1);
border: 1px solid var(--ant-color-border-secondary); border: 1px solid var(--ant-color-border-secondary);
@@ -1278,7 +1232,6 @@ const getCardTitle = () => {
color: var(--ant-color-primary); color: var(--ant-color-primary);
} }
/* 现代化输入框 */
.modern-input { .modern-input {
border-radius: 8px; border-radius: 8px;
border: 2px solid var(--ant-color-border); border: 2px solid var(--ant-color-border);
@@ -1407,36 +1360,36 @@ const getCardTitle = () => {
/* 深色模式适配 */ /* 深色模式适配 */
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
.config-card { .config-card {
box-shadow: box-shadow:
0 4px 20px rgba(0, 0, 0, 0.3), 0 4px 20px rgba(0, 0, 0, 0.3),
0 1px 3px rgba(0, 0, 0, 0.4); 0 1px 3px rgba(0, 0, 0, 0.4);
} }
.save-button { .save-button {
box-shadow: 0 4px 12px rgba(24, 144, 255, 0.4); box-shadow: 0 4px 12px rgba(24, 144, 255, 0.4);
} }
.save-button:hover { .save-button:hover {
box-shadow: 0 6px 16px rgba(24, 144, 255, 0.5); box-shadow: 0 6px 16px rgba(24, 144, 255, 0.5);
} }
.cancel-button:hover { .cancel-button:hover {
box-shadow: 0 4px 12px rgba(255, 77, 79, 0.3); box-shadow: 0 4px 12px rgba(255, 77, 79, 0.3);
} }
.path-input-group:focus-within { .path-input-group:focus-within {
box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.2); box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.2);
} }
.modern-input:focus, .modern-input:focus,
.modern-input.ant-input-focused { .modern-input.ant-input-focused {
box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.2); box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.2);
} }
.modern-select.ant-select-focused :deep(.ant-select-selector) { .modern-select.ant-select-focused :deep(.ant-select-selector) {
box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.2) !important; box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.2) !important;
} }
.modern-number-input :deep(.ant-input-number-focused) { .modern-number-input :deep(.ant-input-number-focused) {
box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.2); box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.2);
} }
@@ -1447,11 +1400,11 @@ const getCardTitle = () => {
.script-edit-container { .script-edit-container {
padding: 24px; padding: 24px;
} }
.config-card :deep(.ant-card-body) { .config-card :deep(.ant-card-body) {
padding: 24px; padding: 24px;
} }
.form-section { .form-section {
margin-bottom: 12px; margin-bottom: 12px;
} }
@@ -1461,38 +1414,38 @@ const getCardTitle = () => {
.script-edit-container { .script-edit-container {
padding: 16px; padding: 16px;
} }
.script-edit-header { .script-edit-header {
flex-direction: column; flex-direction: column;
gap: 16px; gap: 16px;
align-items: stretch; align-items: stretch;
} }
.config-card :deep(.ant-card-head) { .config-card :deep(.ant-card-head) {
padding: 16px 20px; padding: 16px 20px;
} }
.config-card :deep(.ant-card-head-title) { .config-card :deep(.ant-card-head-title) {
font-size: 20px; font-size: 20px;
} }
.config-card :deep(.ant-card-body) { .config-card :deep(.ant-card-body) {
padding: 20px; padding: 20px;
} }
.section-header h3 { .section-header h3 {
font-size: 18px; font-size: 18px;
} }
.form-section { .form-section {
margin-bottom: 12px; margin-bottom: 12px;
} }
.path-button { .path-button {
padding: 0 16px; padding: 0 16px;
font-size: 14px; font-size: 14px;
} }
.cancel-button, .cancel-button,
.save-button { .save-button {
height: 44px; height: 44px;
@@ -1546,4 +1499,4 @@ const getCardTitle = () => {
background: var(--ant-color-bg-elevated); background: var(--ant-color-bg-elevated);
border: 1px solid var(--ant-color-border); border: 1px solid var(--ant-color-border);
} }
</style> </style>

View File

@@ -216,33 +216,6 @@ const handleRefresh = () => {
background-clip: text; background-clip: text;
} }
.add-button {
height: 48px;
padding: 0 24px;
font-size: 16px;
font-weight: 600;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
transition: all 0.3s ease;
}
.add-button:hover {
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(24, 144, 255, 0.4);
}
.refresh-button {
height: 48px;
padding: 0 24px;
font-size: 16px;
font-weight: 500;
border-radius: 12px;
border: 2px solid var(--ant-color-border);
background: var(--ant-color-bg-container);
color: var(--ant-color-text);
transition: all 0.3s ease;
}
/* 脚本类型选择弹窗样式 */ /* 脚本类型选择弹窗样式 */
.type-select-modal :deep(.ant-modal-content) { .type-select-modal :deep(.ant-modal-content) {
border-radius: 16px; border-radius: 16px;

View File

@@ -6,7 +6,11 @@
"outDir": "dist-electron", "outDir": "dist-electron",
"rootDir": "electron", "rootDir": "electron",
"esModuleInterop": true, "esModuleInterop": true,
"types": ["node", "electron"] "types": ["node", "electron"],
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}, },
"include": ["electron"] "include": ["electron"]
} }