App.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 { useCollectStore } from './store/collect';
  9. import { configTheme } from './components/theme/ThemeDefine';
  10. import { getCurrentPageUrl, navTo } from './components/utils/PageAction';
  11. const authStore = useAuthStore();
  12. const collectStore = useCollectStore();
  13. onLaunch(async () => {
  14. console.log('App Launch');
  15. //加载登录信息。如果未登录,跳转登录页
  16. if (!await authStore.loadLoginState()) {
  17. const lastRedirectTime = uni.getStorageSync('lastRedirectTime') || 0;
  18. if (Date.now() - lastRedirectTime < 50000)
  19. return;
  20. uni.setStorageSync('lastRedirectTime', Date.now());
  21. setTimeout(() => {
  22. const pageUrl = getCurrentPageUrl() || '';
  23. const noLoginPages = AppConfig.noLoginPages;
  24. if (noLoginPages.indexOf('/' + pageUrl) == -1 && noLoginPages.indexOf(pageUrl) == -1)
  25. navTo('/pages/user/login');
  26. }, 1500);
  27. }
  28. //加载采集板块信息
  29. await collectStore.loadCollectableModules();
  30. })
  31. //修改默认主题颜色
  32. configTheme((theme) => {
  33. theme.colorConfigs.default.primary = '#00b66a';
  34. theme.colorConfigs.pressed.primary = '#00814b';
  35. theme.colorConfigs.background.primary = '#dcfff0';
  36. return theme;
  37. });
  38. </script>
  39. <style lang="scss">
  40. /*每个页面公共css */
  41. @import "@/static/css/font.css";
  42. @import "@/components/index.scss";
  43. page {
  44. //color: #00b66a;
  45. background: #f7f8f9;
  46. }
  47. </style>