mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-05-07 06:03:28 +08:00
Simple favorites export import
This commit is contained in:
@@ -44,6 +44,17 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='site'>
|
||||
<div class="title">收藏管理</div>
|
||||
<div class="site-box">
|
||||
<div class="zy-select">
|
||||
<div class="vs-placeholder vs-noAfter" @click="exportFavorites">导出</div>
|
||||
</div>
|
||||
<div class="zy-select">
|
||||
<div class="vs-placeholder vs-noAfter" @click="importFavorites">导入</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='search'>
|
||||
<div class="title">搜索</div>
|
||||
<div class="zy-checkbox">
|
||||
@@ -121,7 +132,7 @@
|
||||
<script>
|
||||
import { mapMutations } from 'vuex'
|
||||
import pkg from '../../package.json'
|
||||
import { setting, sites, shortcut } from '../lib/dexie'
|
||||
import { setting, sites, shortcut, star } from '../lib/dexie'
|
||||
import { shell, clipboard, remote } from 'electron'
|
||||
import db from '../lib/dexie/dexie'
|
||||
export default {
|
||||
@@ -131,6 +142,7 @@ export default {
|
||||
pkg: pkg,
|
||||
sitesList: [],
|
||||
shortcutList: [],
|
||||
favoritesList: [],
|
||||
show: {
|
||||
site: false,
|
||||
shortcut: false,
|
||||
@@ -184,6 +196,11 @@ export default {
|
||||
this.shortcutList = res
|
||||
})
|
||||
},
|
||||
getFavorites () {
|
||||
star.all().then(res => {
|
||||
this.favoritesList = res
|
||||
})
|
||||
},
|
||||
changeView (e) {
|
||||
this.d.view = e
|
||||
setting.update(this.d).then(res => {
|
||||
@@ -206,6 +223,20 @@ export default {
|
||||
this.setting = this.d
|
||||
})
|
||||
},
|
||||
exportFavorites () {
|
||||
const arr = [...this.favoritesList]
|
||||
const str = JSON.stringify(arr)
|
||||
clipboard.writeText(str)
|
||||
this.$message.success('已复制到剪贴板')
|
||||
},
|
||||
importFavorites () {
|
||||
const str = clipboard.readText()
|
||||
const json = JSON.parse(str)
|
||||
star.bulkAdd(json).then(e => {
|
||||
this.$message.success('已添加成功')
|
||||
this.getFavorites()
|
||||
})
|
||||
},
|
||||
expSites () {
|
||||
const arr = [...this.sitesList]
|
||||
const str = JSON.stringify(arr)
|
||||
@@ -280,6 +311,7 @@ export default {
|
||||
this.getSetting()
|
||||
this.getSites()
|
||||
this.getShortcut()
|
||||
this.getFavorites()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -4,6 +4,9 @@ export default {
|
||||
async add (doc) {
|
||||
return await star.add(doc)
|
||||
},
|
||||
async bulkAdd (doc) {
|
||||
return await star.bulkAdd(doc)
|
||||
},
|
||||
async find (doc) {
|
||||
return await star.get(doc)
|
||||
},
|
||||
@@ -15,5 +18,8 @@ export default {
|
||||
},
|
||||
async remove (id) {
|
||||
return await star.delete(id)
|
||||
},
|
||||
async clear () {
|
||||
return await star.clear()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user