mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-02 11:08:13 -05:00
Finished: log level setting
This commit is contained in:
parent
f65d2d2df4
commit
17302fe3e4
@ -82,7 +82,7 @@
|
||||
"lowdb": "^1.0.0",
|
||||
"md5": "^2.2.1",
|
||||
"melody.css": "^1.0.2",
|
||||
"picgo": "^1.2.8",
|
||||
"picgo": "^1.3.2",
|
||||
"qiniu": "^7.1.1",
|
||||
"vue": "^2.3.3",
|
||||
"vue-electron": "^1.0.6",
|
||||
|
@ -14,7 +14,12 @@
|
||||
<el-form-item
|
||||
label="打开配置文件"
|
||||
>
|
||||
<el-button type="primary" round size="mini" @click="openConfigFile">点击打开</el-button>
|
||||
<el-button type="primary" round size="mini" @click="openFile('data.json')">点击打开</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="设置日志文件"
|
||||
>
|
||||
<el-button type="primary" round size="mini" @click="openLogSetting">点击设置</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="修改上传快捷键"
|
||||
@ -215,6 +220,44 @@
|
||||
<el-button type="primary" @click="confirmCheckVersion" round>确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
title="设置日志文件"
|
||||
:visible.sync="logFileVisible"
|
||||
:modal-append-to-body="false"
|
||||
>
|
||||
<el-form
|
||||
label-position="right"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item
|
||||
label="日志文件"
|
||||
>
|
||||
<el-button type="primary" round size="mini" @click="openFile('picgo.log')">点击打开</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="日志记录等级"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.logLevel"
|
||||
multiple
|
||||
collapse-tags
|
||||
@change="handleLogLevelChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="(value, key) of logLevel"
|
||||
:key="key"
|
||||
:label="value"
|
||||
:value="key"
|
||||
:disabled="handleLevelDisabled(key)"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer">
|
||||
<el-button @click="cancelLogLevelSetting" round>取消</el-button>
|
||||
<el-button type="primary" @click="confirmLogLevelSetting" round>确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@ -250,9 +293,11 @@ export default {
|
||||
rename: this.$db.read().get('settings.rename').value() || false,
|
||||
autoRename: this.$db.read().get('settings.autoRename').value() || false,
|
||||
uploadNotification: this.$db.read().get('settings.uploadNotification').value() || false,
|
||||
miniWindowOntop: this.$db.read().get('settings.miniWindowOntop').value() || false
|
||||
miniWindowOntop: this.$db.read().get('settings.miniWindowOntop').value() || false,
|
||||
logLevel: this.$db.read().get('settings.logLevel').value() || ['all']
|
||||
},
|
||||
picBed: [],
|
||||
logFileVisible: false,
|
||||
keyBindingVisible: false,
|
||||
customLinkVisible: false,
|
||||
checkUpdateVisible: false,
|
||||
@ -269,6 +314,14 @@ export default {
|
||||
{ validator: customLinkRule, trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
logLevel: {
|
||||
all: '全部-All',
|
||||
success: '成功-Success',
|
||||
error: '错误-Error',
|
||||
info: '普通-Info',
|
||||
warn: '提醒-Warn',
|
||||
none: '不记录日志-None'
|
||||
},
|
||||
version: pkg.version,
|
||||
latestVersion: '',
|
||||
os: ''
|
||||
@ -288,11 +341,14 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
openConfigFile () {
|
||||
openFile (file) {
|
||||
const { app, shell } = this.$electron.remote
|
||||
const STORE_PATH = app.getPath('userData')
|
||||
const CONFIG_FILE = path.join(STORE_PATH, '/data.json')
|
||||
shell.openItem(CONFIG_FILE)
|
||||
const FILE = path.join(STORE_PATH, `/${file}`)
|
||||
shell.openItem(FILE)
|
||||
},
|
||||
openLogSetting () {
|
||||
this.logFileVisible = true
|
||||
},
|
||||
keyDetect (type, event) {
|
||||
this.shortKey[type] = keyDetect(event).join('+')
|
||||
@ -399,6 +455,43 @@ export default {
|
||||
handleMiniWindowOntop (val) {
|
||||
this.$db.read().set('settings.miniWindowOntop', val).write()
|
||||
this.$message('需要重启生效')
|
||||
},
|
||||
confirmLogLevelSetting () {
|
||||
if (this.form.logLevel.length === 0) {
|
||||
return this.$message.error('请选择日志记录等级')
|
||||
}
|
||||
this.$db.read().set('settings.logLevel', this.form.logLevel).write()
|
||||
const successNotification = new window.Notification('设置日志', {
|
||||
body: '设置成功'
|
||||
})
|
||||
successNotification.onclick = () => {
|
||||
return true
|
||||
}
|
||||
this.logFileVisible = false
|
||||
},
|
||||
cancelLogLevelSetting () {
|
||||
this.logFileVisible = false
|
||||
this.form.logLevel = this.$db.read().get('settings.logLevel').value() || 'all'
|
||||
},
|
||||
handleLevelDisabled (val) {
|
||||
let currentLevel = val
|
||||
let flagLevel
|
||||
let result = this.form.logLevel.some(item => {
|
||||
if (item === 'all' || item === 'none') {
|
||||
flagLevel = item
|
||||
}
|
||||
return (item === 'all' || item === 'none')
|
||||
})
|
||||
if (result) {
|
||||
if (currentLevel !== flagLevel) {
|
||||
return true
|
||||
}
|
||||
} else if (this.form.logLevel.length > 0) {
|
||||
if (val === 'all' || val === 'none') {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
24
yarn.lock
24
yarn.lock
@ -2239,6 +2239,13 @@ commander@^2.15.1, commander@^2.17.0, commander@^2.19.0:
|
||||
version "2.19.0"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
|
||||
|
||||
comment-json@^1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/comment-json/-/comment-json-1.1.3.tgz#6986c3330fee0c4c9e00c2398cd61afa5d8f239e"
|
||||
integrity sha1-aYbDMw/uDEyeAMI5jNYa+l2PI54=
|
||||
dependencies:
|
||||
json-parser "^1.0.0"
|
||||
|
||||
commondir@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
|
||||
@ -3560,7 +3567,7 @@ espree@^3.5.4:
|
||||
acorn "^5.5.0"
|
||||
acorn-jsx "^3.0.0"
|
||||
|
||||
esprima@2.7.x, esprima@^2.6.0, esprima@^2.7.1:
|
||||
esprima@2.7.x, esprima@^2.6.0, esprima@^2.7.0, esprima@^2.7.1:
|
||||
version "2.7.3"
|
||||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581"
|
||||
|
||||
@ -5291,6 +5298,13 @@ json-parse-better-errors@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"
|
||||
|
||||
json-parser@^1.0.0:
|
||||
version "1.1.5"
|
||||
resolved "https://registry.yarnpkg.com/json-parser/-/json-parser-1.1.5.tgz#e62ec5261d1a6a5fc20e812a320740c6d9005677"
|
||||
integrity sha1-5i7FJh0aal/CDoEqMgdAxtkAVnc=
|
||||
dependencies:
|
||||
esprima "^2.7.0"
|
||||
|
||||
json-schema-traverse@^0.3.0:
|
||||
version "0.3.1"
|
||||
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340"
|
||||
@ -6801,12 +6815,14 @@ performance-now@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
||||
|
||||
picgo@^1.2.8:
|
||||
version "1.2.8"
|
||||
resolved "https://registry.yarnpkg.com/picgo/-/picgo-1.2.8.tgz#c65a2f680820cd1d5382a37b5522e0bb1004b765"
|
||||
picgo@^1.3.2:
|
||||
version "1.3.2"
|
||||
resolved "https://registry.yarnpkg.com/picgo/-/picgo-1.3.2.tgz#e8692d684b6a30f018034c48cf0c0e72821e5c4e"
|
||||
integrity sha512-o11ukM4Yjh9UlAkq6v+Th4kFVTPatDsAZlS0bMwKtAQO2APE1+gLypGIM2yRvZ6TnbFEacIZ9w2F2f+SOVCvcA==
|
||||
dependencies:
|
||||
chalk "^2.4.1"
|
||||
commander "^2.17.0"
|
||||
comment-json "^1.1.3"
|
||||
cross-spawn "^6.0.5"
|
||||
dayjs "^1.7.4"
|
||||
download-git-repo "^1.1.0"
|
||||
|
Loading…
Reference in New Issue
Block a user