refactor(Scripts, UserEdit): 处理一下IDE的类型报错,然后给脚本管理页面加了个loading~
This commit is contained in:
@@ -1,25 +1,31 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="scripts-header">
|
<!-- 加载状态 -->
|
||||||
<div class="header-title">
|
<div v-if="loading" class="loading-container">
|
||||||
<h1>脚本管理</h1>
|
<a-spin size="large" tip="加载中,请稍候..." />
|
||||||
</div>
|
|
||||||
<a-space size="middle">
|
|
||||||
<a-button type="primary" size="large" @click="handleAddScript" class="link">
|
|
||||||
<template #icon>
|
|
||||||
<PlusOutlined />
|
|
||||||
</template>
|
|
||||||
新建脚本
|
|
||||||
</a-button>
|
|
||||||
<a-button size="large" @click="handleRefresh" class="default">
|
|
||||||
<template #icon>
|
|
||||||
<ReloadOutlined />
|
|
||||||
</template>
|
|
||||||
刷新
|
|
||||||
</a-button>
|
|
||||||
</a-space>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- 如果没有脚本,显示占位符 -->
|
|
||||||
<div v-if="scripts.length === 0" class="placeholder-container">
|
<!-- 主要内容 -->
|
||||||
|
<div class="scripts-header">
|
||||||
|
<div class="header-title">
|
||||||
|
<h1>脚本管理</h1>
|
||||||
|
</div>
|
||||||
|
<a-space size="middle">
|
||||||
|
<a-button type="primary" size="large" @click="handleAddScript" class="link">
|
||||||
|
<template #icon>
|
||||||
|
<PlusOutlined />
|
||||||
|
</template>
|
||||||
|
新建脚本
|
||||||
|
</a-button>
|
||||||
|
<a-button size="large" @click="handleRefresh" class="default">
|
||||||
|
<template #icon>
|
||||||
|
<ReloadOutlined />
|
||||||
|
</template>
|
||||||
|
刷新
|
||||||
|
</a-button>
|
||||||
|
</a-space>
|
||||||
|
</div>
|
||||||
|
<!-- 如果没有脚本,显示占位符 -->
|
||||||
|
<div v-if="scripts.length === 0" class="placeholder-container">
|
||||||
<div class="placeholder-content">
|
<div class="placeholder-content">
|
||||||
<h2>当前没有脚本</h2>
|
<h2>当前没有脚本</h2>
|
||||||
<p>您还没有创建任何脚本,点击下方的“新建脚本”按钮来创建您的第一个脚本。</p>
|
<p>您还没有创建任何脚本,点击下方的“新建脚本”按钮来创建您的第一个脚本。</p>
|
||||||
@@ -595,6 +601,22 @@ const handleToggleUserStatus = async (user: User) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.loading-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scripts-main {
|
||||||
|
padding: 32px;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: var(--ant-color-bg-layout);
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
.scripts-container {
|
.scripts-container {
|
||||||
padding: 32px;
|
padding: 32px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -1011,7 +1033,7 @@ const handleToggleUserStatus = async (user: User) => {
|
|||||||
|
|
||||||
/* 响应式设计 */
|
/* 响应式设计 */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.scripts-container {
|
.scripts-main {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1047,6 +1047,7 @@ const getDefaultMAAUserData = () => ({
|
|||||||
Status: true,
|
Status: true,
|
||||||
Mode: 'MAA',
|
Mode: 'MAA',
|
||||||
InfrastMode: '默认',
|
InfrastMode: '默认',
|
||||||
|
InfrastPath: '',
|
||||||
Routine: true,
|
Routine: true,
|
||||||
Annihilation: '当期',
|
Annihilation: '当期',
|
||||||
Stage: '1-7',
|
Stage: '1-7',
|
||||||
@@ -1057,6 +1058,11 @@ const getDefaultMAAUserData = () => ({
|
|||||||
Stage_Remain: '',
|
Stage_Remain: '',
|
||||||
IfSkland: false,
|
IfSkland: false,
|
||||||
SklandToken: '',
|
SklandToken: '',
|
||||||
|
// 添加 General 脚本的属性以确保兼容性
|
||||||
|
IfScriptBeforeTask: false,
|
||||||
|
IfScriptAfterTask: false,
|
||||||
|
ScriptBeforeTask: '',
|
||||||
|
ScriptAfterTask: '',
|
||||||
},
|
},
|
||||||
Task: {
|
Task: {
|
||||||
IfBase: true,
|
IfBase: true,
|
||||||
@@ -1108,6 +1114,7 @@ const getDefaultGeneralUserData = () => ({
|
|||||||
ToAddress: '',
|
ToAddress: '',
|
||||||
IfSendMail: false,
|
IfSendMail: false,
|
||||||
IfSendStatistic: false,
|
IfSendStatistic: false,
|
||||||
|
IfSendSixStar: false,
|
||||||
IfServerChan: false,
|
IfServerChan: false,
|
||||||
IfCompanyWebHookBot: false,
|
IfCompanyWebHookBot: false,
|
||||||
ServerChanKey: '',
|
ServerChanKey: '',
|
||||||
@@ -1132,7 +1139,7 @@ const formData = reactive({
|
|||||||
userName: '',
|
userName: '',
|
||||||
userId: '',
|
userId: '',
|
||||||
// 嵌套的实际数据
|
// 嵌套的实际数据
|
||||||
...getDefaultUserData(),
|
...getDefaultMAAUserData(),
|
||||||
})
|
})
|
||||||
|
|
||||||
// 表单验证规则
|
// 表单验证规则
|
||||||
@@ -1187,10 +1194,20 @@ const loadScriptInfo = async () => {
|
|||||||
scriptType.value = script.type // 设置脚本类型
|
scriptType.value = script.type // 设置脚本类型
|
||||||
|
|
||||||
// 重新初始化表单数据(根据脚本类型)
|
// 重新初始化表单数据(根据脚本类型)
|
||||||
|
const defaultData =
|
||||||
|
scriptType.value === 'MAA' ? getDefaultMAAUserData() : getDefaultGeneralUserData()
|
||||||
|
|
||||||
|
// 清空现有数据并重新赋值
|
||||||
|
Object.keys(formData).forEach(key => {
|
||||||
|
if (key !== 'userName' && key !== 'userId') {
|
||||||
|
delete formData[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
Object.assign(formData, {
|
Object.assign(formData, {
|
||||||
userName: '',
|
userName: '',
|
||||||
userId: '',
|
userId: '',
|
||||||
...getDefaultUserData(),
|
...defaultData,
|
||||||
})
|
})
|
||||||
|
|
||||||
// 如果是编辑模式,加载用户数据
|
// 如果是编辑模式,加载用户数据
|
||||||
|
|||||||
Reference in New Issue
Block a user