App.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <script>
  2. import { RequestApi } from '@/api/requestApi';
  3. import { useGlobalStore } from '@/stores/global';
  4. export default {
  5. onLaunch: function () {
  6. this.listenNetwork();
  7. },
  8. onShow: function () {
  9. console.log('App Show');
  10. let global = useGlobalStore();
  11. global.setAppHide(false);
  12. this.initNetworkStatus();
  13. },
  14. onHide: function () {
  15. console.log('App Hide');
  16. let global = useGlobalStore();
  17. global.setAppHide(true);
  18. },
  19. data() {
  20. return {
  21. globalStore: useGlobalStore()
  22. };
  23. },
  24. methods: {
  25. loadBasic() {
  26. RequestApi.getBasic().then((basic) => {
  27. this.globalStore.setBasic(basic);
  28. });
  29. },
  30. loadService() {
  31. RequestApi.getService().then((service) => {
  32. this.globalStore.setService(service);
  33. });
  34. },
  35. initNetworkStatus() {
  36. uni.getNetworkType({
  37. success: (e) => {
  38. if (e.networkType != 'none') {
  39. this.globalStore.setNetworkIsConnected(true);
  40. this.loadBasic();
  41. this.loadService();
  42. } else {
  43. this.globalStore.setNetworkIsConnected(false);
  44. }
  45. }
  46. });
  47. },
  48. listenNetwork() {
  49. uni.onNetworkStatusChange((e) => {
  50. this.globalStore.setNetworkIsConnected(e.isConnected);
  51. if (e.isConnected) {
  52. this.loadBasic();
  53. this.loadService();
  54. }
  55. });
  56. }
  57. }
  58. };
  59. </script>
  60. <style lang="scss">
  61. @import '@/static/global.scss';
  62. view {
  63. -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  64. tap-highlight-color: rgba(0, 0, 0, 0);
  65. }
  66. // @font-face {
  67. // font-family: 'PingFang SC';
  68. // src: url(getImageUrl('/fonts/PingFang_SC_Thin.ttf')) format('truetype');
  69. // font-weight: 100;
  70. // }
  71. // @font-face {
  72. // font-family: 'PingFang SC';
  73. // src: url(getImageUrl('/fonts/PingFang_SC_ExtraLight.ttf')) format('truetype');
  74. // font-weight: 200;
  75. // }
  76. // @font-face {
  77. // font-family: 'PingFang SC';
  78. // src: url(getImageUrl('/fonts/PingFang_SC_Light.ttf')) format('truetype');
  79. // font-weight: 300;
  80. // }
  81. // @font-face {
  82. // font-family: 'PingFang SC';
  83. // src: url(getImageUrl('/fonts/PingFang_SC_Regular.ttf')) format('truetype');
  84. // font-weight: 400;
  85. // }
  86. // @font-face {
  87. // font-family: 'PingFang SC';
  88. // src: url(getImageUrl('/fonts/PingFang_SC_Medium.ttf')) format('truetype');
  89. // font-weight: 500;
  90. // }
  91. // @font-face {
  92. // font-family: 'PingFang SC';
  93. // src: url(getImageUrl('/fonts/PingFang_SC_Semibold.ttf')) format('truetype');
  94. // font-weight: 00;
  95. // }
  96. .uni-load-more {
  97. height: unset !important;
  98. }
  99. </style>
  100. <style>
  101. /* 自定义全局样式 */
  102. /deep/ .markdown-body {
  103. padding: 20rpx;
  104. font-size: 28rpx;
  105. line-height: 1.6;
  106. }
  107. /deep/ pre {
  108. padding: 20rpx;
  109. background: #f8f8f8;
  110. border-radius: 8rpx;
  111. overflow-x: auto;
  112. }
  113. /deep/ .uni-load-more {
  114. height: unset !important;
  115. }
  116. </style>