Permalink
Browse files

Added: custom url rules

  • Loading branch information...
Molunerfinn committed Mar 9, 2018
1 parent f6536b1 commit 4010a09fe48d8109456c3c1b37695f177336f2e4
Showing with 38 additions and 6 deletions.
  1. +30 −6 src/renderer/components/SettingPage.vue
  2. +8 −0 src/renderer/components/SettingView/Gallery.vue
@@ -115,13 +115,17 @@
>
<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"
v-model="customLink.value"
:autofocus="true"
></el-input>
</el-form-item>
@@ -145,14 +149,28 @@ const { Menu, dialog, BrowserWindow } = remote
export default {
name: 'setting-page',
data () {
const customLinkRule = (rule, value, callback) => {
if (!/\$url/.test(value)) {
return callback(new Error('必须含有$url'))
} else {
return callback()
}
}
return {
version: process.env.NODE_ENV === 'production' ? pkg.version : 'Dev',
defaultActive: 'upload',
menu: null,
visible: false,
keyBindingVisible: false,
customLinkVisible: false,
customLink: db.read().get('customLink').value() || '$url',
customLink: {
value: db.read().get('customLink').value() || '$url'
},
rules: {
value: [
{ validator: customLinkRule, trigger: 'blur' }
]
},
os: '',
shortKey: {
upload: db.read().get('shortKey.upload').value()
@@ -238,12 +256,18 @@ export default {
},
cancelCustomLink () {
this.customLinkVisible = false
this.customLink = db.read().get('customLink').value() || '$url'
this.customLink.value = db.read().get('customLink').value() || '$url'
},
confirmCustomLink () {
db.read().set('customLink', this.customLink).write()
this.customLinkVisible = false
this.$electron.ipcRenderer.send('updateCustomLink')
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
}
})
}
},
beforeRouteEnter: (to, from, next) => {
@@ -111,6 +111,14 @@ export default {
padding 8px 0
overflow-y auto
overflow-x hidden
&::-webkit-scrollbar
width 8px
height 8px
&::-webkit-scrollbar-thumb
border-radius 4px
background #6f6f6f
&::&::-webkit-scrollbar-track
background-color transparent
.el-col
height 150px
position relative

0 comments on commit 4010a09

Please sign in to comment.