feat: 支持自定义功能按钮

This commit is contained in:
ZiuChen 2022-09-18 16:04:31 +08:00
parent b071a9eb58
commit 1d3c6c7fe8
3 changed files with 16 additions and 9 deletions

View File

@ -5,28 +5,24 @@
"operation.shown": ["copy", "view", "collect", "remove"],
"operation.custom": [
{
"id": "custom.1663468392",
"title": "讯飞OCR识别",
"icon": "⚡",
"match": ["image"],
"match": ["image", { "type": "file", "regex": ".(?:jpg|jpeg|png)$" }],
"command": "redirect:讯飞ocr"
},
{
"id": "custom.1663468466",
"title": "百度搜索",
"icon": "🔍",
"match": ["text"],
"command": "redirect:百度一下"
},
{
"id": "custom.1663468466",
"title": "上传到图床",
"icon": "🚀",
"match": ["image", { "type": "file", "regex": ".(?:jpg|jpeg|png)$" }],
"command": "redirect:上传到图床"
},
{
"id": "custom.1663476961",
"title": "翻译",
"icon": "🌎",
"match": ["text"],

View File

@ -15,6 +15,9 @@
width: 400px;
}
}
.el-textarea {
width: 70%;
}
.path {
width: 65%;
}

View File

@ -46,6 +46,10 @@
/>
</el-select>
</div>
<div class="setting-card-content-item">
<span>自定义功能</span>
<el-input v-model="stringCustom" :rows="5" type="textarea" placeholder="Please input" />
</div>
</div>
<div class="setting-card-footer">
<el-button @click="handleRestoreBtnClick">重置</el-button>
@ -72,6 +76,7 @@ const maxage = ref(database.maxage)
const shown = ref(operation.shown)
const custom = ref(operation.custom)
const stringCustom = ref(JSON.stringify(operation.custom))
const handleLinkClick = (index) => {
const links = [
@ -106,6 +111,12 @@ const handleSaveBtnClick = () => {
ElMessage.error('数据库路径不正确')
return
}
try {
custom.value = JSON.parse(stringCustom.value)
} catch (error) {
custom.value = operation.custom
ElMessage.error('格式错误')
}
utools.dbStorage.setItem(
'setting',
JSON.parse(
@ -122,10 +133,7 @@ const handleSaveBtnClick = () => {
})
)
)
ElMessage({
message: '保存成功 重启插件生效',
type: 'success'
})
ElMessage.success('保存成功 重启插件生效')
}
const handleRestoreBtnClick = () => {