Fixed: #175 || gallery page keep-alive

This commit is contained in:
Molunerfinn 2019-01-24 11:29:48 +08:00
parent e8f2185bbb
commit 649e9f0695
5 changed files with 28 additions and 14 deletions

View File

@ -109,7 +109,7 @@
"css-loader": "^0.28.4", "css-loader": "^0.28.4",
"del": "^3.0.0", "del": "^3.0.0",
"devtron": "^1.4.0", "devtron": "^1.4.0",
"electron": "4.0.0", "electron": "4.0.2",
"electron-builder": "^20.38.4", "electron-builder": "^20.38.4",
"electron-debug": "^1.4.0", "electron-debug": "^1.4.0",
"electron-devtools-installer": "^2.2.0", "electron-devtools-installer": "^2.2.0",

View File

@ -64,7 +64,12 @@
class="main-wrapper" class="main-wrapper"
:class="{ 'darwin': os === 'darwin' }"> :class="{ 'darwin': os === 'darwin' }">
<transition name="picgo-fade" mode="out-in"> <transition name="picgo-fade" mode="out-in">
<router-view :key="$route.params ? $route.params.type : $route.path"></router-view> <keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
</transition>
<transition name="picgo-fade" mode="out-in">
<router-view :key="$route.path" v-if="!$route.meta.keepAlive"></router-view>
</transition> </transition>
</el-col> </el-col>
</el-row> </el-row>
@ -296,7 +301,7 @@ $darwinBg = transparentify(#172426, #000, 0.7)
opacity 0 opacity 0
&-enter-active, &-enter-active,
&-leave-active &-leave-active
transition opacity 100ms linear transition all 100ms linear
.view-title .view-title
color #eee color #eee
font-size 20px font-size 20px

View File

@ -139,8 +139,14 @@ export default {
picBed: [] picBed: []
} }
}, },
beforeRouteEnter (to, from, next) {
next(vm => {
vm.getGallery()
vm.getPasteStyle()
vm.getPicBeds()
})
},
created () { created () {
this.getGallery()
this.$electron.ipcRenderer.on('updateGallery', (event) => { this.$electron.ipcRenderer.on('updateGallery', (event) => {
this.$nextTick(() => { this.$nextTick(() => {
this.filterList = this.getGallery() this.filterList = this.getGallery()
@ -148,8 +154,6 @@ export default {
}) })
this.$electron.ipcRenderer.send('getPicBeds') this.$electron.ipcRenderer.send('getPicBeds')
this.$electron.ipcRenderer.on('getPicBeds', this.getPicBeds) this.$electron.ipcRenderer.on('getPicBeds', this.getPicBeds)
this.getPasteStyle()
this.getPicBeds()
}, },
computed: { computed: {
filterList: { filterList: {
@ -368,6 +372,8 @@ export default {
transition all .2s ease-in-out transition all .2s ease-in-out
&.active &.active
transform: rotate(180deg) transform: rotate(180deg)
#gallery-view
height 100%
.item-base .item-base
background #2E2E2E background #2E2E2E
text-align center text-align center

View File

@ -78,7 +78,10 @@ export default new Router({
{ {
path: 'gallery', path: 'gallery',
component: require('@/pages/Gallery').default, component: require('@/pages/Gallery').default,
name: 'gallery' name: 'gallery',
meta: {
keepAlive: true
}
}, },
{ {
path: 'setting', path: 'setting',

View File

@ -31,9 +31,9 @@
dependencies: dependencies:
"@types/babel-types" "*" "@types/babel-types" "*"
"@types/node@^8.0.24": "@types/node@^10.12.18":
version "8.10.39" version "10.12.18"
resolved "http://registry.npm.taobao.org/@types/node/download/@types/node-8.10.39.tgz#e7e87ad00364dd7bc485c940926345b8ec1a26ca" resolved "http://registry.npm.taobao.org/@types/node/download/@types/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67"
"@vue/component-compiler-utils@^2.0.0": "@vue/component-compiler-utils@^2.0.0":
version "2.3.1" version "2.3.1"
@ -3247,11 +3247,11 @@ electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.47:
version "1.3.96" version "1.3.96"
resolved "http://registry.npm.taobao.org/electron-to-chromium/download/electron-to-chromium-1.3.96.tgz#25770ec99b8b07706dedf3a5f43fa50cb54c4f9a" resolved "http://registry.npm.taobao.org/electron-to-chromium/download/electron-to-chromium-1.3.96.tgz#25770ec99b8b07706dedf3a5f43fa50cb54c4f9a"
electron@4.0.0: electron@4.0.2:
version "4.0.0" version "4.0.2"
resolved "http://registry.npm.taobao.org/electron/download/electron-4.0.0.tgz#6ccb40cc8bf2d49954dcea73b97ae7ad12ee04b3" resolved "http://registry.npm.taobao.org/electron/download/electron-4.0.2.tgz#b5e074c149841490825d0785aa2bc4f5e29bbea4"
dependencies: dependencies:
"@types/node" "^8.0.24" "@types/node" "^10.12.18"
electron-download "^4.1.0" electron-download "^4.1.0"
extract-zip "^1.0.3" extract-zip "^1.0.3"