2021-02-10 01:31:50 +08:00
|
|
|
|
<template>
|
|
|
|
|
<el-container class="settings">
|
|
|
|
|
<div class="wrapper shadow-2">
|
|
|
|
|
|
|
|
|
|
<el-form label-position="left" label-width="7rem">
|
|
|
|
|
|
2021-06-05 11:08:28 +08:00
|
|
|
|
<el-form-item label="字体大小" class="set-font">
|
|
|
|
|
<el-input-number
|
|
|
|
|
v-model="config.fontSize"
|
|
|
|
|
:min="12"
|
|
|
|
|
:max="32"
|
|
|
|
|
label="字体大小"
|
|
|
|
|
size="small"
|
2021-02-10 01:31:50 +08:00
|
|
|
|
></el-input-number>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label="显示网站标题">
|
|
|
|
|
<el-switch v-model="config.showSiteTitle"></el-switch>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label="折叠侧边菜单">
|
|
|
|
|
<el-switch v-model="config.sideMenuCollapse"></el-switch>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
2021-02-25 20:32:07 +08:00
|
|
|
|
<el-form-item label="清除数据">
|
2021-06-05 11:08:28 +08:00
|
|
|
|
<el-button
|
|
|
|
|
type="danger"
|
|
|
|
|
size="medium"
|
|
|
|
|
@click="resetDatas('settings')"
|
|
|
|
|
>清除设置</el-button>
|
2021-02-25 20:32:07 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item>
|
2021-06-05 11:08:28 +08:00
|
|
|
|
<el-button
|
|
|
|
|
type="danger"
|
|
|
|
|
size="medium"
|
|
|
|
|
@click="resetDatas('cache')"
|
|
|
|
|
>清除缓存</el-button>
|
2021-02-25 20:32:07 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
2021-02-10 01:31:50 +08:00
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</el-container>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
name: 'Settings',
|
2021-05-23 23:35:58 +08:00
|
|
|
|
beforeRouteEnter(to, from, next) {
|
|
|
|
|
next(vm => {
|
|
|
|
|
vm.utils.changeTitle('设置');
|
|
|
|
|
});
|
|
|
|
|
},
|
2021-02-10 01:31:50 +08:00
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
config: this.$root.config.storage,
|
|
|
|
|
utils: this.$root.utils
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-02-25 20:32:07 +08:00
|
|
|
|
methods: {
|
2021-05-04 22:02:57 +08:00
|
|
|
|
|
2021-02-25 20:32:07 +08:00
|
|
|
|
/**
|
|
|
|
|
* 清除数据
|
|
|
|
|
*
|
|
|
|
|
* @param {string} type 清除类型(cache、settings)
|
|
|
|
|
*/
|
|
|
|
|
resetDatas(type) {
|
2021-05-04 22:02:57 +08:00
|
|
|
|
this.$confirm('确定要清除吗?', '', {
|
2021-02-25 20:32:07 +08:00
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
|
|
|
|
if (type == 'cache') {
|
|
|
|
|
localStorage.removeItem('navLinksCache');
|
|
|
|
|
} else if (type == 'settings') {
|
2021-05-03 00:48:06 +08:00
|
|
|
|
localStorage.removeItem('navConfig');
|
2021-02-25 20:32:07 +08:00
|
|
|
|
} else {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-03 00:48:06 +08:00
|
|
|
|
this.$message({
|
|
|
|
|
message: '已清除,2s 后自动刷新',
|
|
|
|
|
type: 'success'
|
2021-02-25 20:32:07 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
location.reload();
|
|
|
|
|
}, 2000);
|
|
|
|
|
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
2021-05-03 00:48:06 +08:00
|
|
|
|
this.$message({
|
|
|
|
|
message: '取消清除',
|
|
|
|
|
type: 'info'
|
2021-02-25 20:32:07 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-05-04 22:02:57 +08:00
|
|
|
|
|
2021-02-10 01:31:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.settings {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 2rem;
|
|
|
|
|
background-color: @colorWhite;
|
2021-05-04 18:44:26 +08:00
|
|
|
|
overflow-y: auto;
|
2021-02-10 01:31:50 +08:00
|
|
|
|
|
|
|
|
|
.wrapper {
|
2021-06-05 11:08:28 +08:00
|
|
|
|
padding: 1.5rem;
|
2021-02-10 01:31:50 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
max-width: 50rem;
|
|
|
|
|
background-color: #FFF;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-05 11:08:28 +08:00
|
|
|
|
|
|
|
|
|
.set-font {
|
|
|
|
|
/deep/ .el-input-number {
|
|
|
|
|
width: 7rem;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-10 01:31:50 +08:00
|
|
|
|
</style>
|