App.vue 1.65 KB
<!--
 * @Author: hookehuyr hookehuyr@gmail.com
 * @Date: 2022-05-26 23:52:36
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2022-06-07 11:01:34
 * @FilePath: /tswj/src/App.vue
 * @Description: 
-->
<template>
  <!-- 页面缓存 -->
  <router-view v-slot="{ Component, route }">
    <keep-alive :include="keepPages" :max="10">
      <component :is="Component" :key="route.name" />
    </keep-alive>
  </router-view>
</template>

<script setup lang="ts">
import { mainStore, useTitle } from '@/utils/generatePackage'
import { computed, watchEffect } from 'vue';
import { useRoute } from 'vue-router'
import { Toast } from 'vant';
// 会根据配置判断是否显示调试控件
// eslint-disable-next-line no-unused-vars
import vConsole from '@/utils/vconsole'

// 使用 include + pinia 状态管理动态缓存页面
const store = mainStore()
const keepPages = computed(() => store.getKeepPages)

// 设置页面标题
const $route = useRoute();
watchEffect(
  () => {
    useTitle($route.meta.title)
  }
)

Toast.setDefaultOptions({
  duration: 2000,
  className: 'xxx'
});

</script>

<style lang="less">
@prefix: ~'@{namespace}-x';

html,
body {
  width: 100%;
  height: 100%;
}

body {
  position: relative;
  // --van-white: #fff;
  // --van-blue: #1989fa;
  // --van-button-primary-color: var(--van-white);
  // --van-button-primary-background: var(--van-primary-color);
  /* 全局修改主色调 */
  // --van-blue: #F9D95C;

  // background-color: #FAFAFA;
  p {
    margin: 0;
    padding: 0;
  }
}

.@{prefix} {
  color: red;
}

.glob-center {
  position: relative; 
  top: 50%; 
  transform: translateY(-50%);
}

.xxx {
  z-index: 4500 !important;
}
</style>