Bladeren bron

页面跳转时弄个过渡

任一存 2 jaren geleden
bovenliggende
commit
429fc344d8
13 gewijzigde bestanden met toevoegingen van 48 en 11 verwijderingen
  1. 1 1
      .env.dev
  2. 1 1
      .env.prod
  3. 1 1
      .env.test
  4. 23 1
      src/App.vue
  5. 1 1
      src/store/index.js
  6. 3 0
      src/views/Bag.vue
  7. 3 0
      src/views/BuildTown.vue
  8. 3 1
      src/views/Home.vue
  9. 3 0
      src/views/JagsawGame.vue
  10. 3 1
      src/views/Level2.vue
  11. 3 1
      src/views/Level3.vue
  12. 2 2
      src/views/Watch.vue
  13. 1 1
      vue.config.js

+ 1 - 1
.env.dev

@@ -1,3 +1,3 @@
-CLI_MODE=dev
+VUE_APP_CLI_MODE=dev
 NODE_ENV=development
 PUBLIC_PATH=/

+ 1 - 1
.env.prod

@@ -1,3 +1,3 @@
-CLI_MODE=prod
+VUE_APP_CLI_MODE=prod
 NODE_ENV=production
 PUBLIC_PATH=./

+ 1 - 1
.env.test

@@ -1,3 +1,3 @@
-CLI_MODE=test
+VUE_APP_CLI_MODE=test
 NODE_ENV=production
 PUBLIC_PATH=./

+ 23 - 1
src/App.vue

@@ -1,6 +1,15 @@
 <template>
   <div class="comp-root">
-    <router-view />
+    <!-- <router-view /> -->
+    <router-view v-slot="{ Component }">
+      <transition
+        name="my"
+      >
+        <component
+          :is="Component"
+        />
+      </transition>
+    </router-view>
     <button
       v-if="$route.name !== 'HomeView'"
       class="back"
@@ -75,6 +84,19 @@ export default {
 // ::-webkit-scrollbar-corner { background: #dddecc; }
 
 // vue组件过渡效果
+.my-enter-active {
+  transition: opacity 2s;
+}
+.my-leave-active {
+  transition: opacity 2s;
+}
+.my-enter-from {
+  opacity: 0;
+}
+.my-leave-to {
+  opacity: 0;
+}
+
 .fade-out-leave-active {
   transition: opacity 1s;
 }

+ 1 - 1
src/store/index.js

@@ -2,7 +2,7 @@ import { createStore } from 'vuex'
 
 export default createStore({
   state: {
-    hasPlayedStartupVideo: false,
+    hasPlayedStartupVideo: process.env.VUE_APP_CLI_MODE === 'dev' ? true : false,
   },
   getters: {
   },

+ 3 - 0
src/views/Bag.vue

@@ -32,6 +32,9 @@ export default {
 
 <style lang="less" scoped>
 .home {
+  position: absolute;
+  left: 0;
+  top: 0;
   width: 100%;
   height: 100%;
 }

+ 3 - 0
src/views/BuildTown.vue

@@ -32,6 +32,9 @@ export default {
 
 <style lang="less" scoped>
 .home {
+  position: absolute;
+  left: 0;
+  top: 0;
   width: 100%;
   height: 100%;
 }

+ 3 - 1
src/views/Home.vue

@@ -138,13 +138,15 @@ export default {
 
 <style lang="less" scoped>
 .home {
+  position: absolute;
+  left: 0;
+  top: 0;
   width: 100%;
   height: 100%;
   background-image: url(@/assets/images/bg-home.jpg);
   background-size: cover;
   background-repeat: no-repeat;
   background-position: center center;
-  position: relative;
   >.lion-male {
     position: absolute;
     width: 219px;

+ 3 - 0
src/views/JagsawGame.vue

@@ -32,6 +32,9 @@ export default {
 
 <style lang="less" scoped>
 .home {
+  position: absolute;
+  left: 0;
+  top: 0;
   width: 100%;
   height: 100%;
 }

+ 3 - 1
src/views/Level2.vue

@@ -72,7 +72,9 @@ export default {
 
 <style lang="less" scoped>
 .level-2 {
-  position: relative;
+  position: absolute;
+  left: 0;
+  top: 0;
   width: 100%;
   height: 100%;
   background-size: cover;

+ 3 - 1
src/views/Level3.vue

@@ -106,7 +106,9 @@ export default {
 
 <style lang="less" scoped>
 .level-3 {
-  position: relative;
+  position: absolute;
+  left: 0;
+  top: 0;
   width: 100%;
   height: 100%;
   background-size: cover;

+ 2 - 2
src/views/Watch.vue

@@ -106,8 +106,8 @@ export default {
   }
   >.bag-wrapper {
     position: absolute;
-    right: 11vw;
-    bottom: 41px;
+    right: -28px;
+    bottom: 140px;
     >img.jigsaw {
       position: absolute;
       width: 60px;

+ 1 - 1
vue.config.js

@@ -9,7 +9,7 @@ process.env.VUE_APP_UPDATE_TIME = time
 
 module.exports = defineConfig({
   publicPath: process.env.PUBLIC_PATH,
-  productionSourceMap: process.env.CLI_MODE === 'prod' ? false : true,
+  productionSourceMap: process.env.VUE_APP_CLI_MODE === 'prod' ? false : true,
   // transpileDependencies: true, // 默认false,表示babel-loader 会忽略所有 node_modules 中的文件
   configureWebpack: {
     module: {