mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-02 11:08:13 -05:00
Finished: custom picbed setting for displaying visible or none
This commit is contained in:
parent
d99e45a021
commit
282b0dc25c
@ -3,29 +3,39 @@ import qiniuUpload from '../main/utils/qiniuUpload'
|
|||||||
import tcYunUpload from '../main/utils/tcYunUpload'
|
import tcYunUpload from '../main/utils/tcYunUpload'
|
||||||
import upYunUpload from '../main/utils/upYunUpload'
|
import upYunUpload from '../main/utils/upYunUpload'
|
||||||
import githubUpload from '../main/utils/githubUpload'
|
import githubUpload from '../main/utils/githubUpload'
|
||||||
|
import db from './index'
|
||||||
|
|
||||||
const picBed = [
|
let picBed = db.read().get('picBed.list').value()
|
||||||
{
|
|
||||||
type: 'weibo',
|
if (!picBed) {
|
||||||
name: '微博图床'
|
picBed = [
|
||||||
},
|
{
|
||||||
{
|
type: 'weibo',
|
||||||
type: 'qiniu',
|
name: '微博图床',
|
||||||
name: '七牛图床'
|
visible: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'tcyun',
|
type: 'qiniu',
|
||||||
name: '腾讯云COS'
|
name: '七牛图床',
|
||||||
},
|
visible: true
|
||||||
{
|
},
|
||||||
type: 'upyun',
|
{
|
||||||
name: '又拍云图床'
|
type: 'tcyun',
|
||||||
},
|
name: '腾讯云COS',
|
||||||
{
|
visible: true
|
||||||
type: 'github',
|
},
|
||||||
name: 'GitHub图床'
|
{
|
||||||
}
|
type: 'upyun',
|
||||||
]
|
name: '又拍云图床',
|
||||||
|
visible: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'github',
|
||||||
|
name: 'GitHub图床',
|
||||||
|
visible: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
const picBedHandler = {
|
const picBedHandler = {
|
||||||
weibo: weiboUpload,
|
weibo: weiboUpload,
|
||||||
|
@ -30,14 +30,18 @@
|
|||||||
<i class="el-icon-menu"></i>
|
<i class="el-icon-menu"></i>
|
||||||
<span>图床设置</span>
|
<span>图床设置</span>
|
||||||
</template>
|
</template>
|
||||||
<el-menu-item
|
<template
|
||||||
v-for="item in picBed"
|
v-for="item in picBed"
|
||||||
:index="item.type"
|
|
||||||
:key="item.type"
|
|
||||||
>
|
>
|
||||||
<i :class="`el-icon-ui-${item.type}`"></i>
|
<el-menu-item
|
||||||
<span slot="title">{{ item.name }}</span>
|
v-if="item.visible"
|
||||||
</el-menu-item>
|
:index="item.type"
|
||||||
|
:key="item.type"
|
||||||
|
>
|
||||||
|
<i :class="`el-icon-ui-${item.type}`"></i>
|
||||||
|
<span slot="title">{{ item.name }}</span>
|
||||||
|
</el-menu-item>
|
||||||
|
</template>
|
||||||
</el-submenu>
|
</el-submenu>
|
||||||
<el-menu-item index="setting">
|
<el-menu-item index="setting">
|
||||||
<i class="el-icon-setting"></i>
|
<i class="el-icon-setting"></i>
|
||||||
@ -91,29 +95,6 @@
|
|||||||
<el-button type="primary" @click="confirmKeyBinding">确定</el-button>
|
<el-button type="primary" @click="confirmKeyBinding">确定</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<el-dialog
|
|
||||||
title="修改快捷键"
|
|
||||||
:visible.sync="keyBindingVisible"
|
|
||||||
>
|
|
||||||
<el-form
|
|
||||||
label-width="80px"
|
|
||||||
>
|
|
||||||
<el-form-item
|
|
||||||
label="快捷上传"
|
|
||||||
>
|
|
||||||
<el-input
|
|
||||||
class="align-center"
|
|
||||||
@keydown.native.prevent="keyDetect('upload', $event)"
|
|
||||||
v-model="shortKey.upload"
|
|
||||||
:autofocus="true"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<span slot="footer">
|
|
||||||
<el-button @click="cancelKeyBinding">取消</el-button>
|
|
||||||
<el-button type="primary" @click="confirmKeyBinding">确定</el-button>
|
|
||||||
</span>
|
|
||||||
</el-dialog>
|
|
||||||
<el-dialog
|
<el-dialog
|
||||||
title="自定义链接格式"
|
title="自定义链接格式"
|
||||||
:visible.sync="customLinkVisible"
|
:visible.sync="customLinkVisible"
|
||||||
@ -219,27 +200,6 @@ export default {
|
|||||||
click () {
|
click () {
|
||||||
_this.visible = true
|
_this.visible = true
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '修改快捷键',
|
|
||||||
click () {
|
|
||||||
_this.keyBindingVisible = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '自定义链接格式',
|
|
||||||
click () {
|
|
||||||
_this.customLinkVisible = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '打开更新助手',
|
|
||||||
type: 'checkbox',
|
|
||||||
checked: _this.$db.get('picBed.showUpdateTip').value(),
|
|
||||||
click () {
|
|
||||||
const value = _this.$db.read().get('picBed.showUpdateTip').value()
|
|
||||||
_this.$db.read().set('picBed.showUpdateTip', !value).write()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
this.menu = Menu.buildFromTemplate(template)
|
this.menu = Menu.buildFromTemplate(template)
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
<div id="picgo-setting">
|
<div id="picgo-setting">
|
||||||
<div class="view-title">
|
<div class="view-title">
|
||||||
PicGo设置
|
PicGo设置
|
||||||
<div class="sub-title">
|
|
||||||
注意保存设置
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<el-row class="setting-list">
|
<el-row class="setting-list">
|
||||||
<el-col :span="15" :offset="4">
|
<el-col :span="15" :offset="4">
|
||||||
@ -17,12 +14,12 @@
|
|||||||
<el-form-item
|
<el-form-item
|
||||||
label="修改快捷键"
|
label="修改快捷键"
|
||||||
>
|
>
|
||||||
<el-button type="primary" round size="mini">点击设置</el-button>
|
<el-button type="primary" round size="mini" @click="keyBindingVisible = true">点击设置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="自定义链接格式"
|
label="自定义链接格式"
|
||||||
>
|
>
|
||||||
<el-button type="primary" round size="mini">点击设置</el-button>
|
<el-button type="primary" round size="mini" @click="customLinkVisible = true">点击设置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="打开更新助手"
|
label="打开更新助手"
|
||||||
@ -31,6 +28,7 @@
|
|||||||
v-model="form.updateHelper"
|
v-model="form.updateHelper"
|
||||||
active-text="开"
|
active-text="开"
|
||||||
inactive-text="关"
|
inactive-text="关"
|
||||||
|
@change="updateHelperChange"
|
||||||
></el-switch>
|
></el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
@ -54,34 +52,162 @@
|
|||||||
<el-form-item
|
<el-form-item
|
||||||
label="选择显示的图床"
|
label="选择显示的图床"
|
||||||
>
|
>
|
||||||
<el-checkbox-group v-model="form.showPicBedList">
|
<el-checkbox-group
|
||||||
|
v-model="form.showPicBedList"
|
||||||
|
@change="handleShowPicBedListChange"
|
||||||
|
>
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-for="(item, index) in picBed"
|
v-for="(item, index) in picBed"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
></el-checkbox>
|
></el-checkbox>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="" round class="confirm-button">保存设置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-dialog
|
||||||
|
title="修改快捷键"
|
||||||
|
:visible.sync="keyBindingVisible"
|
||||||
|
:modal-append-to-body="false"
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
label-width="80px"
|
||||||
|
>
|
||||||
|
<el-form-item
|
||||||
|
label="快捷上传"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
class="align-center"
|
||||||
|
@keydown.native.prevent="keyDetect('upload', $event)"
|
||||||
|
v-model="shortKey.upload"
|
||||||
|
:autofocus="true"
|
||||||
|
></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<span slot="footer">
|
||||||
|
<el-button @click="cancelKeyBinding">取消</el-button>
|
||||||
|
<el-button type="primary" @click="confirmKeyBinding">确定</el-button>
|
||||||
|
</span>
|
||||||
|
</el-dialog>
|
||||||
|
<el-dialog
|
||||||
|
title="自定义链接格式"
|
||||||
|
:visible.sync="customLinkVisible"
|
||||||
|
:modal-append-to-body="false"
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
label-position="top"
|
||||||
|
:model="customLink"
|
||||||
|
ref="customLink"
|
||||||
|
:rules="rules"
|
||||||
|
>
|
||||||
|
<el-form-item
|
||||||
|
label="用占位符$url来表示url的位置"
|
||||||
|
prop="value"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
class="align-center"
|
||||||
|
v-model="customLink.value"
|
||||||
|
:autofocus="true"
|
||||||
|
></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div>
|
||||||
|
如[]($url)
|
||||||
|
</div>
|
||||||
|
<span slot="footer">
|
||||||
|
<el-button @click="cancelCustomLink">取消</el-button>
|
||||||
|
<el-button type="primary" @click="confirmCustomLink">确定</el-button>
|
||||||
|
</span>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import db from '../../../datastore'
|
||||||
|
import keyDetect from 'utils/key-binding'
|
||||||
export default {
|
export default {
|
||||||
name: 'picgo-setting',
|
name: 'picgo-setting',
|
||||||
data () {
|
data () {
|
||||||
|
const customLinkRule = (rule, value, callback) => {
|
||||||
|
if (!/\$url/.test(value)) {
|
||||||
|
return callback(new Error('必须含有$url'))
|
||||||
|
} else {
|
||||||
|
return callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
updateHelper: false,
|
updateHelper: this.$db.get('picBed.showUpdateTip').value(),
|
||||||
showPicBedList: [],
|
showPicBedList: [],
|
||||||
autoStart: false,
|
autoStart: this.$db.get('picBed.autoStart').value() || false,
|
||||||
rename: false
|
rename: this.$db.get('picBed.rename').value() || false
|
||||||
},
|
},
|
||||||
picBed: this.$picBed
|
picBed: this.$picBed,
|
||||||
|
keyBindingVisible: false,
|
||||||
|
customLinkVisible: false,
|
||||||
|
customLink: {
|
||||||
|
value: db.read().get('customLink').value() || '$url'
|
||||||
|
},
|
||||||
|
shortKey: {
|
||||||
|
upload: db.read().get('shortKey.upload').value()
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
value: [
|
||||||
|
{ validator: customLinkRule, trigger: 'blur' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
this.form.showPicBedList = this.picBed.map(item => {
|
||||||
|
if (item.visible) {
|
||||||
|
return item.name
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.log(this.picBed)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
keyDetect (type, event) {
|
||||||
|
this.shortKey[type] = keyDetect(event).join('+')
|
||||||
|
},
|
||||||
|
cancelKeyBinding () {
|
||||||
|
this.keyBindingVisible = false
|
||||||
|
this.shortKey = db.read().get('shortKey').value()
|
||||||
|
},
|
||||||
|
confirmKeyBinding () {
|
||||||
|
const oldKey = db.read().get('shortKey').value()
|
||||||
|
db.read().set('shortKey', this.shortKey).write()
|
||||||
|
this.keyBindingVisible = false
|
||||||
|
this.$electron.ipcRenderer.send('updateShortKey', oldKey)
|
||||||
|
},
|
||||||
|
cancelCustomLink () {
|
||||||
|
this.customLinkVisible = false
|
||||||
|
this.customLink.value = db.read().get('customLink').value() || '$url'
|
||||||
|
},
|
||||||
|
confirmCustomLink () {
|
||||||
|
this.$refs.customLink.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
db.read().set('customLink', this.customLink.value).write()
|
||||||
|
this.customLinkVisible = false
|
||||||
|
this.$electron.ipcRenderer.send('updateCustomLink')
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
updateHelperChange (val) {
|
||||||
|
this.$db.read().set('picBed.showUpdateTip', val).write()
|
||||||
|
},
|
||||||
|
handleShowPicBedListChange (val) {
|
||||||
|
const list = this.picBed.map(item => {
|
||||||
|
if (!val.includes(item.name)) {
|
||||||
|
item.visible = false
|
||||||
|
} else {
|
||||||
|
item.visible = true
|
||||||
|
}
|
||||||
|
return item
|
||||||
|
})
|
||||||
|
this.$db.read().set('picBed.list', list).write()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,43 +224,44 @@ export default {
|
|||||||
.sub-title
|
.sub-title
|
||||||
font-size 14px
|
font-size 14px
|
||||||
.setting-list
|
.setting-list
|
||||||
height 340px
|
height 360px
|
||||||
box-sizing border-box
|
box-sizing border-box
|
||||||
overflow-y auto
|
overflow-y auto
|
||||||
overflow-x hidden
|
overflow-x hidden
|
||||||
.el-form
|
.setting-list
|
||||||
label
|
.el-form
|
||||||
line-height 32px
|
|
||||||
padding-bottom 0
|
|
||||||
color #eee
|
|
||||||
.el-button-group
|
|
||||||
width 100%
|
|
||||||
.el-button
|
|
||||||
width 50%
|
|
||||||
.el-input__inner
|
|
||||||
border-radius 19px
|
|
||||||
.el-radio-group
|
|
||||||
margin-left 25px
|
|
||||||
.el-switch__label
|
|
||||||
color #eee
|
|
||||||
&.is-active
|
|
||||||
color #409EFF
|
|
||||||
.el-icon-question
|
|
||||||
font-size 20px
|
|
||||||
float right
|
|
||||||
margin-top 9px
|
|
||||||
color #eee
|
|
||||||
cursor pointer
|
|
||||||
transition .2s color ease-in-out
|
|
||||||
&:hover
|
|
||||||
color #409EFF
|
|
||||||
.el-checkbox-group
|
|
||||||
label
|
label
|
||||||
|
line-height 32px
|
||||||
|
padding-bottom 0
|
||||||
|
color #eee
|
||||||
|
.el-button-group
|
||||||
|
width 100%
|
||||||
|
.el-button
|
||||||
|
width 50%
|
||||||
|
.el-input__inner
|
||||||
|
border-radius 19px
|
||||||
|
.el-radio-group
|
||||||
|
margin-left 25px
|
||||||
|
.el-switch__label
|
||||||
|
color #eee
|
||||||
|
&.is-active
|
||||||
|
color #409EFF
|
||||||
|
.el-icon-question
|
||||||
|
font-size 20px
|
||||||
|
float right
|
||||||
|
margin-top 9px
|
||||||
|
color #eee
|
||||||
|
cursor pointer
|
||||||
|
transition .2s color ease-in-out
|
||||||
|
&:hover
|
||||||
|
color #409EFF
|
||||||
|
.el-checkbox-group
|
||||||
|
label
|
||||||
|
margin-right 30px
|
||||||
|
width 100px
|
||||||
|
.el-checkbox+.el-checkbox
|
||||||
margin-right 30px
|
margin-right 30px
|
||||||
width 100px
|
margin-left 0
|
||||||
.el-checkbox+.el-checkbox
|
.confirm-button
|
||||||
margin-right 30px
|
width 100%
|
||||||
margin-left 0
|
|
||||||
.confirm-button
|
|
||||||
width 100%
|
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue
Block a user