mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-05-05 18:34:50 +08:00
记录窗口大小及位置
This commit is contained in:
53
src/App.vue
53
src/App.vue
@@ -22,11 +22,62 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { setting } from './lib/dexie'
|
||||
const { remote } = require('electron')
|
||||
export default {
|
||||
name: 'App',
|
||||
data () {
|
||||
return {
|
||||
appTheme: 'theme-light'
|
||||
appTheme: 'theme-light',
|
||||
winSizePosition: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
// 窗口创建口,检查是否有窗口大小位置的记录,如果有的话,更新窗口位置及大小
|
||||
setting.find().then(res => {
|
||||
if (res.restoreWindowPositionAndSize) {
|
||||
var win = remote.getCurrentWindow()
|
||||
win.setBounds({
|
||||
x: res.windowPositionAndSize.x,
|
||||
y: res.windowPositionAndSize.y,
|
||||
width: res.windowPositionAndSize.width,
|
||||
height: res.windowPositionAndSize.height
|
||||
})
|
||||
this.winSizePosition = {
|
||||
x: win.getPosition()[0],
|
||||
y: win.getPosition()[1],
|
||||
width: win.getSize()[0],
|
||||
height: win.getSize()[1]
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
updated () {
|
||||
// 本来想hook up到beforedestroy, 但不工作
|
||||
// 每当窗口更新时,检查窗口大小及位置,记录到setting数据库中
|
||||
if (this.setting.restoreWindowPositionAndSize) {
|
||||
const win = remote.getCurrentWindow()
|
||||
var newWinSizePosition = {
|
||||
x: win.getPosition()[0],
|
||||
y: win.getPosition()[1],
|
||||
width: win.getSize()[0],
|
||||
height: win.getSize()[1]
|
||||
}
|
||||
if (newWinSizePosition.x !== this.winSizePosition.x ||
|
||||
newWinSizePosition.y !== this.winSizePosition.y ||
|
||||
newWinSizePosition.width !== this.winSizePosition.width ||
|
||||
newWinSizePosition.height !== this.winSizePosition.height) {
|
||||
this.winSizePosition = newWinSizePosition
|
||||
setting.find().then(res => {
|
||||
res.windowPositionAndSize = newWinSizePosition
|
||||
setting.update(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
@@ -110,6 +110,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="site">
|
||||
<div class="title">窗口</div>
|
||||
<div class="site-box">
|
||||
<div class="zy-input">
|
||||
<input type="checkbox" v-model = "d.restoreWindowPositionAndSize" @change="updateSettingEvent"> 恢复上次窗口位置和大小
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="theme">
|
||||
<div class="title">主题</div>
|
||||
<div class="theme-box">
|
||||
@@ -361,6 +369,7 @@ export default {
|
||||
updateSettingEvent () {
|
||||
this.show.editPlayerPath = false
|
||||
this.setting = this.d
|
||||
console.log(this.setting.restoreWindowPositionAndSize)
|
||||
setting.update(this.d)
|
||||
},
|
||||
toggleExcludeR18Films () {
|
||||
|
||||
@@ -73,6 +73,21 @@ db.version(10).stores({
|
||||
})
|
||||
})
|
||||
|
||||
db.version(11).stores({
|
||||
setting: 'id, theme, shortcut, view, volume, externalPlayer, searchGroup, excludeRootClasses, excludeR18Films, forwardTimeInSec, starViewMode, recommandationViewMode,' +
|
||||
'searchViewMode, password, proxy, allowPassWhenIptvCheck, autocleanWhenIptvCheck, rootClassFilter, r18ClassFilter, classFilter, restoreWindowPositionAndSize, windowPositionAndSize'
|
||||
}).upgrade(trans => {
|
||||
trans.setting.toCollection().modify(setting => {
|
||||
setting.restoreWindowPositionAndSize = false
|
||||
setting.windowPositionAndSize = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 1080,
|
||||
height: 720
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
db.on('populate', () => {
|
||||
db.setting.bulkAdd(iniSetting)
|
||||
db.sites.bulkAdd(sites)
|
||||
|
||||
@@ -70,5 +70,6 @@
|
||||
"性感",
|
||||
"里番",
|
||||
"VIP"
|
||||
]
|
||||
],
|
||||
"restoreWindowSize": false
|
||||
}]
|
||||
Reference in New Issue
Block a user