mirror of
https://github.com/xfgryujk/blivechat.git
synced 2025-03-23 08:10:56 +08:00
添加导出导入配置
This commit is contained in:
parent
4d5a38bf7d
commit
290b09f49a
@ -10,6 +10,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.19.0",
|
"axios": "^0.19.0",
|
||||||
"core-js": "^2.6.5",
|
"core-js": "^2.6.5",
|
||||||
|
"downloadjs": "^1.4.7",
|
||||||
"element-ui": "^2.9.1",
|
"element-ui": "^2.9.1",
|
||||||
"lodash": "^4.17.11",
|
"lodash": "^4.17.11",
|
||||||
"vue": "^2.6.10",
|
"vue": "^2.6.10",
|
||||||
|
@ -66,11 +66,16 @@
|
|||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="saveConfig">保存配置</el-button>
|
<el-button type="primary" @click="saveConfig">保存配置</el-button>
|
||||||
<el-button type="primary" :disabled="!roomUrl" @click="enterRoom">进入房间</el-button>
|
<el-button type="primary" :disabled="!roomUrl" @click="enterRoom">进入房间</el-button>
|
||||||
|
<el-button type="primary" @click="exportConfig">导出配置</el-button>
|
||||||
|
<el-button type="primary" @click="importConfig">导入配置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import download from 'downloadjs'
|
||||||
|
|
||||||
|
import {mergeConfig} from '@/utils'
|
||||||
import config from '@/api/config'
|
import config from '@/api/config'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -120,6 +125,31 @@ export default {
|
|||||||
copyUrl() {
|
copyUrl() {
|
||||||
this.$refs.roomUrlInput.select()
|
this.$refs.roomUrlInput.select()
|
||||||
document.execCommand('Copy')
|
document.execCommand('Copy')
|
||||||
|
},
|
||||||
|
exportConfig() {
|
||||||
|
let cfg = mergeConfig(this.form, config.DEFAULT_CONFIG)
|
||||||
|
download(JSON.stringify(cfg, null, 2), 'blivechat.json', 'application/json')
|
||||||
|
},
|
||||||
|
importConfig() {
|
||||||
|
let input = document.createElement('input')
|
||||||
|
input.type = 'file'
|
||||||
|
input.accept = 'application/json'
|
||||||
|
input.onchange = () => {
|
||||||
|
let reader = new window.FileReader()
|
||||||
|
reader.onload = () => {
|
||||||
|
let cfg
|
||||||
|
try {
|
||||||
|
cfg = JSON.parse(reader.result)
|
||||||
|
} catch (e) {
|
||||||
|
this.$message.error('配置解析失败:' + e)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cfg = mergeConfig(cfg, config.DEFAULT_CONFIG)
|
||||||
|
this.form = {roomId: this.form.roomId, ...cfg}
|
||||||
|
}
|
||||||
|
reader.readAsText(input.files[0])
|
||||||
|
}
|
||||||
|
input.click()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 138 KiB |
Loading…
Reference in New Issue
Block a user