App.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <script>
  2. import { initAppDatabase } from '@/utils/appDb';
  3. import { runWgtHotUpdate } from '@/utils/hot-update';
  4. export default {
  5. onLaunch: (options) => {
  6. // #ifdef APP
  7. initAppDatabase();
  8. // #endif
  9. console.log('App Launch');
  10. console.log(options);
  11. // uni.onNetworkStatusChange((event) => {
  12. // console.log(event)
  13. // })
  14. // #ifdef H5
  15. // 保存钉钉消息传递的参数,参数可能存在path或query中
  16. if (options.query.type) {
  17. uni.setStorageSync('dingTalkJson', JSON.stringify(options.query));
  18. } else if (options.path && options.path.includes('type')) {
  19. const path = options.path;
  20. const args = path.split('&');
  21. const params = {};
  22. args.forEach((arg) => {
  23. const [key, value] = arg.split('=');
  24. if (key && value) {
  25. params[key] = value;
  26. }
  27. console.log(params);
  28. });
  29. uni.setStorageSync('dingTalkJson', JSON.stringify(params));
  30. }
  31. // #endif
  32. // #ifdef APP
  33. plus.globalEvent.addEventListener('newintent', () => {
  34. const args = plus.runtime.arguments;
  35. const parts = args.match(/^deepoil:\/\/([^/]+)\/([^/]+)$/);
  36. if (parts) {
  37. const type = parts[1];
  38. const id = parts[2];
  39. uni.setStorageSync('dingTalkJson', JSON.stringify({ type, id }));
  40. console.log('App: dingTalkJson -> ' + uni.getStorageSync('dingTalkJson'));
  41. }
  42. });
  43. // #endif
  44. // #ifdef APP-PLUS
  45. /**
  46. * 这里是本次新增的 .wgt 热更新入口。
  47. *
  48. * 为什么放在 App.vue 的 onLaunch:
  49. * 1. 这是整个项目真正的应用启动入口,热更新要尽量早执行,就应该接在这里。
  50. * 2. 现有项目的旧升级逻辑写在页面组件里,只会在登录页 / 首页 mounted 后才触发,
  51. * 对“启动即检查热更新”这个目标来说太晚了。
  52. * 3. 放在这里还能保证热更新和数据库初始化、scheme 监听这类“应用级逻辑”处于同一层级,
  53. * 后续维护时更容易看清启动链路。
  54. *
  55. * 为什么这里不 await:
  56. * 1. 原有 onLaunch 里的数据库初始化本身就是非阻塞调用,项目没有把启动流程串行化。
  57. * 2. 热更新检查失败时我们希望“静默降级,不阻断原有启动”。
  58. * 3. 因此这里直接触发即可,让原有启动逻辑保持原样继续往下走。
  59. */
  60. runWgtHotUpdate();
  61. // #endif
  62. },
  63. onExit: () => {
  64. // #ifdef APP
  65. // sqlite.closeDB('app')
  66. // #endif
  67. },
  68. onShow: function () {
  69. // console.log('App Show')
  70. },
  71. onHide: function () {
  72. // console.log('App Hide')
  73. }
  74. };
  75. </script>
  76. <style lang="scss">
  77. /*每个页面公共css */
  78. @import './style/common.scss';
  79. @import './style/fonts.scss';
  80. /* uniapp组件 样式覆盖 */
  81. uni-button[type='primary'] {
  82. background: #004098 !important;
  83. }
  84. uni-button[disabled][type='primary'] {
  85. background: rgba(0, 64, 152, 0.6) !important;
  86. }
  87. uni-button[type='primary'][plain] {
  88. color: #004098 !important;
  89. border: 1px solid #004098 !important;
  90. background-color: transparent !important;
  91. }
  92. uni-page-body,
  93. body {
  94. width: 100%;
  95. height: 100%;
  96. box-sizing: border-box;
  97. position: relative;
  98. }
  99. :deep(.uni-tabbar-bottom .uni-tabbar) {
  100. box-shadow: 0px -2px 10px 0px rgba(0, 0, 0, 0.1);
  101. // padding-top: 9px !important;
  102. // padding-bottom: 10px !important;
  103. box-sizing: border-box;
  104. .uni-tabbar__icon {
  105. margin-top: 4px;
  106. }
  107. }
  108. .page {
  109. position: relative;
  110. padding: 20rpx;
  111. padding-top: 0;
  112. box-sizing: border-box;
  113. background: #f3f5f9;
  114. width: 100%;
  115. height: 100%;
  116. font-family: PingFangSC, PingFang SC;
  117. overflow: hidden;
  118. }
  119. .page-nopadding {
  120. position: relative;
  121. box-sizing: border-box;
  122. background: #f3f5f9;
  123. width: 100%;
  124. height: 100%;
  125. font-family: PingFangSC, PingFang SC;
  126. overflow: hidden;
  127. }
  128. .page-back {
  129. background-image: url('/static/common/1.png');
  130. background-repeat: no-repeat;
  131. background-size: 100% 100%;
  132. position: fixed;
  133. top: 0;
  134. left: 0;
  135. width: 100%;
  136. height: 350px;
  137. z-index: 0;
  138. }
  139. .navgator {
  140. width: 100%;
  141. height: $header-height;
  142. line-height: 1;
  143. position: fixed;
  144. top: $header-top-height;
  145. left: 0;
  146. background-color: transparent !important;
  147. padding-top: calc(7px + env(safe-area-inset-top));
  148. box-sizing: border-box;
  149. z-index: 22;
  150. .nav-title {
  151. font-family: PingFang-SC, PingFang-SC;
  152. font-weight: bold;
  153. font-size: 16px;
  154. color: #ffffff;
  155. line-height: 22px;
  156. text-align: right;
  157. font-style: normal;
  158. }
  159. .nav-back {
  160. width: 40rpx;
  161. line-height: 1;
  162. position: absolute;
  163. left: 20rpx;
  164. .uni-icons {
  165. color: #fff !important;
  166. }
  167. }
  168. }
  169. .page-content {
  170. position: relative;
  171. box-sizing: border-box;
  172. width: 100%;
  173. height: calc(100% - $header-height - $header-top-height);
  174. margin-top: calc($header-height + $header-top-height);
  175. overflow: hidden;
  176. overflow-y: auto;
  177. }
  178. .item {
  179. box-sizing: border-box;
  180. }
  181. </style>