“恢复默认”按钮,添加loading效果。

pull/287/head
王良 2024-04-02 12:38:02 +08:00
parent e40bf546d0
commit 1d6c9d0fd4
12 changed files with 57 additions and 66 deletions

View File

@ -24,11 +24,8 @@
<span class="nav-text">{{ item.title }}</span>
</a-menu-item>
</template>
</a-menu>
</div>
</a-layout-sider>
<a-layout>
<!-- <a-layout-header>Header</a-layout-header>-->

View File

@ -17,7 +17,7 @@
:style="{ height: '100%' }"
>
<a-tab-pane tab="拦截设置" key="1" >
<vue-json-editor style="height:100%;" ref="editor" v-model="targetConfig.intercepts" mode="code" :show-btns="false" :expandedOnStart="true" @json-change="onJsonChange"></vue-json-editor>
<vue-json-editor style="height:100%;" ref="editor" v-model="targetConfig.intercepts" mode="code" :show-btns="false" :expandedOnStart="true"></vue-json-editor>
</a-tab-pane>
<a-tab-pane tab="DNS设置" key="2">
<div>
@ -42,7 +42,6 @@
<a-button v-if="item.value === false" style="margin-left:10px" type="primary" icon="checked" @click="restoreDefDnsMapping(item,index)" ></a-button>
</a-col>
</a-row>
</div>
</a-tab-pane>
<a-tab-pane tab="环境变量" key="3">
@ -144,8 +143,6 @@ export default {
this.npmVariables = ret
})
},
onJsonChange (config) {
},
afterVisibleChange (val) {
console.log('visible', val)
if (val === true) {
@ -200,7 +197,7 @@ export default {
},
addDnsMapping () {
this.dnsMappings.unshift({ key: '', value: 'usa' })
this.dnsMappings.unshift({ key: '', value: 'quad9' })
},
doSetNpmVariablesNow () {
this.syncTargetConfig()
@ -211,7 +208,7 @@ export default {
this.npmVariables = ret
})
}).then(() => {
this.$message.info('设置成功')
this.$message.success('设置成功')
})
},
addNpmVariable () {

View File

@ -12,6 +12,7 @@ export default {
status: {},
labelCol: { span: 4 },
wrapperCol: { span: 20 },
resetDefaultLoading: false,
applyLoading: false,
systemPlatform: ''
}
@ -43,7 +44,7 @@ export default {
},
async apply () {
if (this.applyLoading === true) {
return
return // 防重复提交
}
this.applyLoading = true
await this.applyBefore()
@ -65,20 +66,22 @@ export default {
cancelText: '取消',
okText: '确定',
onOk: async () => {
this.resetDefaultLoading = true
this.config = await this.$api.config.resetDefault(key)
if (this.ready) {
await this.ready(this.config)
}
await this.apply()
this.resetDefaultLoading = false
},
onCancel () {}
})
},
saveConfig () {
return this.$api.config.save(this.config).then((ret) => {
this.$message.info('设置已保存')
this.$message.success('设置已保存')
this.setConfig(ret.allConfig)
this.printConfig('after saveConfig(), ')
this.printConfig('After saveConfig(), ')
return ret
})
},

View File

@ -3,7 +3,6 @@
<template slot="header">
给开发者的辅助工具
<span>
<a-button style="margin-right:10px" @click="openSetupCa">
<a-badge :count="_rootCaSetuped?0:1" dot>安装根证书</a-badge>
</a-button>
@ -14,7 +13,6 @@
<span v-if="update.downloading">{{ update.progress }}%</span>{{ update.downloading ? '' : '' }}
</a-badge>
</a-button>
</span>
</template>
@ -108,7 +106,6 @@
</div>
</a-modal>
</div>
</ds-container>
</template>
@ -205,7 +202,7 @@ export default {
this.config.plugin.overwall.enabled = true
}
this.$api.config.save(this.config).then(() => {
this.$message.info('设置已保存')
this.$message.success('设置已保存')
})
if (this.status.server.enabled) {
return this.$api.server.restart()
@ -231,7 +228,7 @@ export default {
this.$confirm({
title: '第一次使用请先安装CA根证书',
content: '本应用正常使用必须安装和信任CA根证书',
cancelText: '下次',
cancelText: '下次安装',
okText: '去安装',
onOk: () => {
this.openSetupCa()
@ -252,6 +249,8 @@ export default {
await this.$api.shell.setupCa({ certPath: this.config.server.setting.rootCaFile.certPath })
this.setting.rootCa = this.setting.rootCa || {}
const rootCa = this.setting.rootCa
//
rootCa.setuped = true
this.$set(this, 'setting', this.setting)
this.$api.setting.save(this.setting)

View File

@ -30,7 +30,7 @@
</div>
<template slot="footer">
<div class="footer-bar">
<a-button class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="resetDefaultLoading" class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="applyLoading" icon="check" type="primary" @click="apply()"></a-button>
</div>
</template>

View File

@ -73,7 +73,7 @@
</div>
<template slot="footer">
<div class="footer-bar">
<a-button class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="resetDefaultLoading" class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="applyLoading" icon="check" type="primary" @click="apply()"></a-button>
</div>
</template>

View File

@ -78,7 +78,7 @@
</div>
<template slot="footer">
<div class="footer-bar">
<a-button class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="resetDefaultLoading" class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="applyLoading" icon="check" type="primary" @click="apply()"></a-button>
</div>
</template>

View File

@ -43,7 +43,7 @@
</div>
<template slot="footer">
<div class="footer-bar">
<a-button class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="resetDefaultLoading" class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="applyLoading" icon="check" type="primary" @click="apply()"></a-button>
</div>
</template>

View File

@ -55,7 +55,7 @@
</div>
<template slot="footer">
<div class="footer-bar">
<a-button class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="resetDefaultLoading" class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="applyLoading" icon="check" type="primary" @click="apply()"></a-button>
</div>
</template>

View File

@ -69,7 +69,7 @@
</a-tab-pane>
<a-tab-pane tab="拦截设置" key="2">
<vue-json-editor style="height:100%;" ref="editor" v-model="config.server.intercepts" mode="code"
:show-btns="false" :expandedOnStart="true" @json-change="onJsonChange"></vue-json-editor>
:show-btns="false" :expandedOnStart="true"></vue-json-editor>
</a-tab-pane>
<a-tab-pane tab="域名白名单" key="3">
<a-row style="margin-top:10px">
@ -206,12 +206,11 @@
</div>
<template slot="footer">
<div class="footer-bar">
<a-button class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="resetDefaultLoading" class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="applyLoading" icon="check" type="primary" @click="apply()"></a-button>
</div>
</template>
</ds-container>
</template>
<script>
@ -228,8 +227,6 @@ export default {
data () {
return {
key: 'server',
labelCol: { span: 4 },
wrapperCol: { span: 20 },
dnsMappings: [],
speedTestList: [],
whiteList: [],
@ -269,8 +266,6 @@ export default {
this.config.server.setting.rootCaFile.keyPath = value[0]
}
},
onJsonChange (json) {
},
ready () {
this.initDnsMapping()
this.initWhiteList()
@ -315,7 +310,7 @@ export default {
},
addDnsMapping () {
this.dnsMappings.unshift({ key: '', value: 'usa' })
this.dnsMappings.unshift({ key: '', value: 'quad9' })
},
// whiteList

View File

@ -76,7 +76,7 @@
</div>
<template slot="footer">
<div class="footer-bar">
<a-button class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="resetDefaultLoading" class="md-mr-10" icon="sync" @click="resetDefault()"></a-button>
<a-button :loading="applyLoading" icon="check" type="primary" @click="apply()"></a-button>
</div>
</template>
@ -143,9 +143,9 @@ export default {
if (remoteConfig.old === remoteConfig.new) {
this.$message.info('远程配置没有变化,不做任何处理。')
this.$message.info('如果您确实修改了远程配置,请稍等片刻再重试!')
this.$message.warn('如果您确实修改了远程配置,请稍等片刻再重试!')
} else {
this.$message.info('获取到了最新的远程配置,开始重启代理服务和系统代理')
this.$message.success('获取到了最新的远程配置,开始重启代理服务和系统代理')
await this.reloadAndRestart()
}