Skip to content

Commit dd9c6d3

Browse files
committed
更新[chavy.box.js]: 返回主页时可以恢复之前的位置
1 parent 72de2aa commit dd9c6d3

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

‎chavy.box.js‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ function printHtml(data, curapp = null) {
466466
</head>
467467
<body>
468468
<div id="app">
469-
<v-app>
469+
<v-app v-scroll="onScroll">
470470
<v-app-bar :color="ui.appbar.color" app dense>
471471
<v-menu bottom left v-if="['app', 'home', 'log', 'data'].includes(ui.curview) && box.syscfgs.env === ''">
472472
<template v-slot:activator="{ on }">
@@ -737,6 +737,7 @@ function printHtml(data, curapp = null) {
737737
data() {
738738
return {
739739
ui: {
740+
scrollY: 0,
740741
bfview: 'app',
741742
curview: 'app',
742743
curapp: ${curapp},
@@ -782,6 +783,7 @@ function printHtml(data, curapp = null) {
782783
var state = { title: 'BoxJs' }
783784
document.title = state.title
784785
history.pushState(state, '', '/home')
786+
this.$vuetify.goTo(this.ui.scrollY, {duration: 0, offset: 0})
785787
}
786788
}
787789
}
@@ -790,16 +792,10 @@ function printHtml(data, curapp = null) {
790792
onLink(link) {
791793
window.open(link)
792794
},
793-
onShare() {
794-
const KEY_sessions = 'chavy_boxjs_sessions'
795-
const KEY_userCfgs = 'chavy_boxjs_userCfgs'
796-
const data = {}
797-
data[KEY_sessions] = this.box.sessions
798-
data[KEY_userCfgs] = this.box.usercfgs
799-
this.box.sessions.forEach((session, sessionIdx) => {
800-
session.datas.forEach((_data, dataIdx) => (data[_data.key] = _data.val))
801-
})
802-
this.$copyText(JSON.stringify(data))
795+
onScroll(e) {
796+
if(this.ui.curview === 'app') {
797+
this.ui.scrollY = e.currentTarget.scrollY + 48
798+
}
803799
},
804800
onUserCfgsChange() {
805801
axios.post('/api', JSON.stringify({ cmd: 'saveUserCfgs', val: this.box.usercfgs }))

0 commit comments

Comments
 (0)