mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-08 14:24:03 +08:00
feat: Setting页支持自定义主界面功能按钮 支持重置设置
This commit is contained in:
parent
dfe3d87ef0
commit
b071a9eb58
@ -31,11 +31,7 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const operation = computed(() =>
|
const operation = computed(() => [...defaultOperation, ...setting.operation.custom])
|
||||||
props.isFullData
|
|
||||||
? [...defaultOperation, ...setting.operation.custom]
|
|
||||||
: [...defaultOperation, ...setting.operation.custom].splice(0, 5)
|
|
||||||
)
|
|
||||||
|
|
||||||
const { handleOperateClick, filterOperate } = useClipOperate({ emit })
|
const { handleOperateClick, filterOperate } = useClipOperate({ emit })
|
||||||
</script>
|
</script>
|
||||||
|
@ -8,8 +8,13 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
.el-select {
|
.el-select {
|
||||||
|
&.number-select {
|
||||||
width: 85px;
|
width: 85px;
|
||||||
}
|
}
|
||||||
|
&.operation-select {
|
||||||
|
width: 400px;
|
||||||
|
}
|
||||||
|
}
|
||||||
.path {
|
.path {
|
||||||
width: 65%;
|
width: 65%;
|
||||||
}
|
}
|
||||||
|
@ -17,20 +17,38 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="setting-card-content-item">
|
<div class="setting-card-content-item">
|
||||||
<span>最大历史条数</span>
|
<span>最大历史条数</span>
|
||||||
<el-select v-model="maxsize" fit-input-width>
|
<el-select class="number-select" v-model="maxsize" fit-input-width>
|
||||||
<el-option v-for="n in [600, 800, 1000, 1200, 1400]" :key="n" :value="n" />
|
<el-option v-for="n in [600, 800, 1000, 1200, 1400]" :key="n" :value="n" />
|
||||||
</el-select>
|
</el-select>
|
||||||
条
|
条
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-card-content-item">
|
<div class="setting-card-content-item">
|
||||||
<span>最长保存时间</span>
|
<span>最长保存时间</span>
|
||||||
<el-select v-model="maxage" fit-input-width>
|
<el-select class="number-select" v-model="maxage" fit-input-width>
|
||||||
<el-option v-for="n in [10, 11, 12, 13, 14]" :key="n" :value="n" />
|
<el-option v-for="n in [10, 11, 12, 13, 14]" :key="n" :value="n" />
|
||||||
</el-select>
|
</el-select>
|
||||||
天
|
天
|
||||||
</div>
|
</div>
|
||||||
|
<div class="setting-card-content-item">
|
||||||
|
<span>展示在主界面的功能按钮</span>
|
||||||
|
<el-select
|
||||||
|
class="operation-select"
|
||||||
|
v-model="shown"
|
||||||
|
multiple
|
||||||
|
:multiple-limit="4"
|
||||||
|
placeholder="请选择"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="{ id, title, icon } in defaultOperation"
|
||||||
|
:key="id"
|
||||||
|
:label="icon + title"
|
||||||
|
:value="id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-card-footer">
|
<div class="setting-card-footer">
|
||||||
|
<el-button @click="handleRestoreBtnClick">重置</el-button>
|
||||||
<el-button @click="emit('back')">返回</el-button>
|
<el-button @click="emit('back')">返回</el-button>
|
||||||
<el-button @click="handleSaveBtnClick" type="primary">保存</el-button>
|
<el-button @click="handleSaveBtnClick" type="primary">保存</el-button>
|
||||||
</div>
|
</div>
|
||||||
@ -40,16 +58,21 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { ElButton, ElInput, ElMessage } from 'element-plus'
|
import { ElButton, ElInput, ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import setting from '../global/readSetting'
|
import setting from '../global/readSetting'
|
||||||
|
import restoreSetting from '../global/restoreSetting'
|
||||||
|
import defaultOperation from '../data/operation.json'
|
||||||
|
|
||||||
const emit = defineEmits(['back'])
|
const emit = defineEmits(['back'])
|
||||||
const { database } = setting
|
const { database, operation } = setting
|
||||||
|
|
||||||
const path = ref(database.path)
|
const path = ref(database.path)
|
||||||
const maxsize = ref(database.maxsize)
|
const maxsize = ref(database.maxsize)
|
||||||
const maxage = ref(database.maxage)
|
const maxage = ref(database.maxage)
|
||||||
|
|
||||||
|
const shown = ref(operation.shown)
|
||||||
|
const custom = ref(operation.custom)
|
||||||
|
|
||||||
const handleLinkClick = (index) => {
|
const handleLinkClick = (index) => {
|
||||||
const links = [
|
const links = [
|
||||||
'https://ziuchen.gitee.io/project/ClipboardManager/',
|
'https://ziuchen.gitee.io/project/ClipboardManager/',
|
||||||
@ -83,19 +106,43 @@ const handleSaveBtnClick = () => {
|
|||||||
ElMessage.error('数据库路径不正确')
|
ElMessage.error('数据库路径不正确')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
utools.dbStorage.setItem('setting', {
|
utools.dbStorage.setItem(
|
||||||
...setting,
|
'setting',
|
||||||
|
JSON.parse(
|
||||||
|
JSON.stringify({
|
||||||
database: {
|
database: {
|
||||||
path: path.value,
|
path: path.value,
|
||||||
maxsize: maxsize.value,
|
maxsize: maxsize.value,
|
||||||
maxage: maxage.value
|
maxage: maxage.value
|
||||||
|
},
|
||||||
|
operation: {
|
||||||
|
shown: shown.value,
|
||||||
|
custom: custom.value
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: '保存成功 重启插件生效',
|
message: '保存成功 重启插件生效',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleRestoreBtnClick = () => {
|
||||||
|
ElMessageBox.confirm('确定要重置设置吗', '警告', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
restoreSetting()
|
||||||
|
ElMessage({
|
||||||
|
message: '重置成功 重启插件生效',
|
||||||
|
type: 'success'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user