App.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <style lang="scss">
  2. @import "@/common/scss/global/base.scss";
  3. </style>
  4. <script setup lang="ts">
  5. import AppConfig from '@/common/config/AppCofig'
  6. import { onLaunch } from '@dcloudio/uni-app'
  7. import { useAuthStore } from './store/auth'
  8. import { configTheme } from './components/theme/ThemeDefine';
  9. import { getCurrentPageUrl, navTo } from './components/utils/PageAction';
  10. const authStore = useAuthStore();
  11. onLaunch(async () => {
  12. console.log('App Launch');
  13. //加载登录信息。如果未登录,跳转登录页
  14. if (!await authStore.loadLoginState()) {
  15. const lastRedirectTime = uni.getStorageSync('lastRedirectTime') || 0;
  16. if (Date.now() - lastRedirectTime < 50000)
  17. return;
  18. uni.setStorageSync('lastRedirectTime', Date.now());
  19. setTimeout(() => {
  20. const pageUrl = getCurrentPageUrl() || '';
  21. const noLoginPages = AppConfig.noLoginPages;
  22. if (noLoginPages.indexOf('/' + pageUrl) == -1 && noLoginPages.indexOf(pageUrl) == -1)
  23. navTo('/pages/user/login');
  24. }, 1500);
  25. }
  26. })
  27. //修改默认主题颜色
  28. configTheme((theme) => {
  29. theme.colorConfigs.default.primary = '#00ca76';
  30. theme.colorConfigs.pressed.primary = '#00814b';
  31. theme.colorConfigs.background.primary = '#dcfff0';
  32. return theme;
  33. });
  34. </script>
  35. <style>
  36. /*每个页面公共css */
  37. @import "@/static/css/font.css";
  38. @import "@/components/index.scss";
  39. page {
  40. background: #f7f8f9;
  41. }
  42. </style>