App.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <script>
  2. import {
  3. onBackPress
  4. } from "@dcloudio/uni-app"
  5. import cacheManager from "@/utils/cacheManager.js";
  6. import {
  7. useIsCanBack
  8. } from "@/store/isCanBack.js";
  9. export default {
  10. // creat by wgy 0619 生命周期 钩子
  11. onLaunch: function() {
  12. // #ifdef APP-PLUS
  13. if (cacheManager.get('auth')) {
  14. uni.reLaunch({
  15. url: `/pages/admin/ShouYe/shouye`,
  16. success() {
  17. plus.navigator.closeSplashscreen();
  18. }
  19. })
  20. } else {
  21. cacheManager.clearAll()
  22. uni.reLaunch({
  23. url: '/pages/Login/index',
  24. success() {
  25. plus.navigator.closeSplashscreen();
  26. }
  27. });
  28. }
  29. // #endif
  30. // #ifdef H5
  31. if (cacheManager.get('auth')) {
  32. uni.reLaunch({
  33. url: `/pages/admin/ShouYe/shouye`,
  34. success() {
  35. }
  36. })
  37. }
  38. // #endif
  39. },
  40. onShow: function() {
  41. // #ifdef APP-PLUS
  42. const webview = plus.webview.currentWebview();
  43. plus.key.addEventListener('backbutton', () => {
  44. const store = useIsCanBack();
  45. if (!store.isCanBack) {
  46. event.preventDefault();
  47. return false
  48. } else {
  49. return true
  50. }
  51. });
  52. // #endif
  53. // #ifdef H5
  54. if (cacheManager.get('auth')) {
  55. uni.reLaunch({
  56. url: `/pages/admin/ShouYe/shouye`,
  57. success() {
  58. }
  59. })
  60. }
  61. // #endif
  62. },
  63. onHide: function() {
  64. }
  65. }
  66. </script>
  67. <style lang="scss">
  68. /* 公共样式 */
  69. @import '/common/styles/index.scss';
  70. // 西文、雅黑、黑体、宋体
  71. body,
  72. html,
  73. #app {
  74. font-family: "Helvetica Neue", "Microsoft YaHei", "SimHei", "SimSun", "Arial", sans-serif;
  75. margin: 0;
  76. padding: 0;
  77. box-sizing: border-box;
  78. }
  79. </style>