From d8b7faedc78d277ff6be57ff76d54e96a7e37b86 Mon Sep 17 00:00:00 2001 From: mather Date: Fri, 9 Oct 2020 00:29:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20config=20=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B2=A1=E6=9C=89=E4=BF=9D=E5=AD=98=E5=9C=A8=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20#Closes=20#19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/Config.js | 20 ++++++++++++++++++-- src/pages/init/app.js | 22 +++++++++++----------- src/router-components/admin/Settings.vue | 14 ++++++-------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/models/Config.js b/src/models/Config.js index e79dfc3..c5906eb 100644 --- a/src/models/Config.js +++ b/src/models/Config.js @@ -8,6 +8,7 @@ import { bucketName, qiniuBucketDomainName, qiniuAccessKey, qiniuSecretKey, qini // 本地存在 核心配置数据 filmy:config 吗? // 存在 则获取本地数据 // 不存在 则通过七牛云下载 config.json 然后保存在本地 filmy:config +let _temp_config; const Config = { load (silent = false) { @@ -17,7 +18,7 @@ const Config = { // 从数据库中获取核心配置数据 return min.hgetall(`${bucketName}:config`) } else { - return filmyBucket.getFile(`config.json`) + return filmyBucket.getFile(`config.json?${new Date().getTime()}`) .then(body => { return Promise.resolve(JSON.parse(body)) }) @@ -68,7 +69,6 @@ const Config = { for (const key of Object.keys(update)) { config[key] = update[key] } - const fileData = new Blob([JSON.stringify(config)], {type: 'application/json'}) fileData.name = 'config.json' @@ -80,6 +80,22 @@ const Config = { } ) }) + .then(({hash, key, config})=>{ + config = config || {} + + for (const key of Object.keys(update)) { + config[key] = update[key] + } + + if(hash && key) { + try { + min.hmset(`${bucketName}:config`, config) + } catch (err) { + console.error(err) + } + } + return config + }) } } diff --git a/src/pages/init/app.js b/src/pages/init/app.js index 6b77212..f0ff9b2 100644 --- a/src/pages/init/app.js +++ b/src/pages/init/app.js @@ -26,19 +26,19 @@ new Vue({ }, mounted () { - Config.load(true) - .then(config => { - if (!config) return - const url = `${ location.protocol }//${ location.host }` + // Config.load(true) + // .then(config => { + // if (!config) return + // const url = `${ location.protocol }//${ location.host }` - openSimpleModal( - 'Warning', - 'This Filmy is already inited.', - `OK` - ) + // openSimpleModal( + // 'Warning', + // 'This Filmy is already inited.', + // `OK` + // ) - this.$el.remove() - }) + // this.$el.remove() + // }) }, methods: { diff --git a/src/router-components/admin/Settings.vue b/src/router-components/admin/Settings.vue index c992021..cb0062c 100644 --- a/src/router-components/admin/Settings.vue +++ b/src/router-components/admin/Settings.vue @@ -51,9 +51,10 @@