1
1
<script lang="ts" setup>
2
- import type { FormInstance , FormRules } from ' element-plus' ;
3
- import { ElMessage } from ' element-plus' ;
4
2
import ProgramItem from ' ./components/ProgramItem.vue' ;
5
3
import DownloaderItem from ' ./components/DownloaderItem.vue' ;
6
4
import RssParserItem from ' ./components/RssParserItem.vue' ;
@@ -10,33 +8,11 @@ import ProxyItem from './components/ProxyItem.vue';
10
8
import NotificationItem from ' ./components/NotificationItem.vue' ;
11
9
12
10
import { form } from ' ./form-data' ;
13
- import { useConfigCheck } from ' ./useConfigCheck' ;
14
11
15
12
const store = configStore ();
16
- const { validtePort, validteHost, validteFormProxy } = useConfigCheck ();
17
- const ruleFormRef = ref <FormInstance >();
18
13
19
- const rules = reactive <FormRules >({
20
- ' program.webui_port' : [{ validator: validtePort , trigger: ' blur' }],
21
- ' downloader.host' : [{ validator: validteHost , trigger: ' blur' }],
22
-
23
- ' proxy.host' : [{ validator: validteFormProxy .ip , trigger: ' blur' }],
24
- ' proxy.port' : [{ validator: validteFormProxy .port , trigger: ' blur' }],
25
- });
26
-
27
- function submit(formEl : FormInstance | undefined ) {
28
- if (! formEl ) return false ;
29
- formEl .validate ((valid ) => {
30
- if (valid ) {
31
- store .set (form );
32
- } else {
33
- ElMessage ({
34
- message: ' 配置验证失败! 请检查你的配置' ,
35
- type: ' error' ,
36
- });
37
- return false ;
38
- }
39
- });
14
+ function submit() {
15
+ store .set (form );
40
16
}
41
17
42
18
function formSync() {
@@ -59,12 +35,7 @@ onActivated(async () => {
59
35
<section class =" settings" pb30 >
60
36
<el-row :gutter =" 20" >
61
37
<el-col :xs =" 24" :sm =" 24" >
62
- <el-form
63
- ref =" ruleFormRef"
64
- :model =" form"
65
- :rules =" rules"
66
- label-position =" right"
67
- >
38
+ <el-form :model =" form" label-position =" right" >
68
39
<el-collapse >
69
40
<ProgramItem />
70
41
<DownloaderItem />
@@ -79,7 +50,7 @@ onActivated(async () => {
79
50
</el-row >
80
51
81
52
<div flex =" ~ items-center justify-center" mt20 >
82
- <el-button type =" primary" @click =" submit(ruleFormRef) " >保存</el-button >
53
+ <el-button type =" primary" @click =" submit" >保存</el-button >
83
54
<el-button @click =" formSync" >还原</el-button >
84
55
</div >
85
56
</section >
0 commit comments