| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <script>
- import { initAppDatabase } from '@/utils/appDb';
- import { runWgtHotUpdate } from '@/utils/hot-update';
- export default {
- onLaunch: (options) => {
- // #ifdef APP
- initAppDatabase();
- // #endif
- console.log('App Launch');
- console.log(options);
- // uni.onNetworkStatusChange((event) => {
- // console.log(event)
- // })
- // #ifdef H5
- // 保存钉钉消息传递的参数,参数可能存在path或query中
- if (options.query.type) {
- uni.setStorageSync('dingTalkJson', JSON.stringify(options.query));
- } else if (options.path && options.path.includes('type')) {
- const path = options.path;
- const args = path.split('&');
- const params = {};
- args.forEach((arg) => {
- const [key, value] = arg.split('=');
- if (key && value) {
- params[key] = value;
- }
- console.log(params);
- });
- uni.setStorageSync('dingTalkJson', JSON.stringify(params));
- }
- // #endif
- // #ifdef APP
- plus.globalEvent.addEventListener('newintent', () => {
- const args = plus.runtime.arguments;
- const parts = args.match(/^deepoil:\/\/([^/]+)\/([^/]+)$/);
- if (parts) {
- const type = parts[1];
- const id = parts[2];
- uni.setStorageSync('dingTalkJson', JSON.stringify({ type, id }));
- console.log('App: dingTalkJson -> ' + uni.getStorageSync('dingTalkJson'));
- }
- });
- // #endif
- // #ifdef APP-PLUS
- /**
- * 这里是本次新增的 .wgt 热更新入口。
- *
- * 为什么放在 App.vue 的 onLaunch:
- * 1. 这是整个项目真正的应用启动入口,热更新要尽量早执行,就应该接在这里。
- * 2. 现有项目的旧升级逻辑写在页面组件里,只会在登录页 / 首页 mounted 后才触发,
- * 对“启动即检查热更新”这个目标来说太晚了。
- * 3. 放在这里还能保证热更新和数据库初始化、scheme 监听这类“应用级逻辑”处于同一层级,
- * 后续维护时更容易看清启动链路。
- *
- * 为什么这里不 await:
- * 1. 原有 onLaunch 里的数据库初始化本身就是非阻塞调用,项目没有把启动流程串行化。
- * 2. 热更新检查失败时我们希望“静默降级,不阻断原有启动”。
- * 3. 因此这里直接触发即可,让原有启动逻辑保持原样继续往下走。
- */
- runWgtHotUpdate();
- // #endif
- },
- onExit: () => {
- // #ifdef APP
- // sqlite.closeDB('app')
- // #endif
- },
- onShow: function () {
- // console.log('App Show')
- },
- onHide: function () {
- // console.log('App Hide')
- }
- };
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import './style/common.scss';
- @import './style/fonts.scss';
- /* uniapp组件 样式覆盖 */
- uni-button[type='primary'] {
- background: #004098 !important;
- }
- uni-button[disabled][type='primary'] {
- background: rgba(0, 64, 152, 0.6) !important;
- }
- uni-button[type='primary'][plain] {
- color: #004098 !important;
- border: 1px solid #004098 !important;
- background-color: transparent !important;
- }
- uni-page-body,
- body {
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- position: relative;
- }
- :deep(.uni-tabbar-bottom .uni-tabbar) {
- box-shadow: 0px -2px 10px 0px rgba(0, 0, 0, 0.1);
- // padding-top: 9px !important;
- // padding-bottom: 10px !important;
- box-sizing: border-box;
- .uni-tabbar__icon {
- margin-top: 4px;
- }
- }
- .page {
- position: relative;
- padding: 20rpx;
- padding-top: 0;
- box-sizing: border-box;
- background: #f3f5f9;
- width: 100%;
- height: 100%;
- font-family: PingFangSC, PingFang SC;
- overflow: hidden;
- }
- .page-nopadding {
- position: relative;
- box-sizing: border-box;
- background: #f3f5f9;
- width: 100%;
- height: 100%;
- font-family: PingFangSC, PingFang SC;
- overflow: hidden;
- }
- .page-back {
- background-image: url('/static/common/1.png');
- background-repeat: no-repeat;
- background-size: 100% 100%;
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 350px;
- z-index: 0;
- }
- .navgator {
- width: 100%;
- height: $header-height;
- line-height: 1;
- position: fixed;
- top: $header-top-height;
- left: 0;
- background-color: transparent !important;
- padding-top: calc(7px + env(safe-area-inset-top));
- box-sizing: border-box;
- z-index: 22;
- .nav-title {
- font-family: PingFang-SC, PingFang-SC;
- font-weight: bold;
- font-size: 16px;
- color: #ffffff;
- line-height: 22px;
- text-align: right;
- font-style: normal;
- }
- .nav-back {
- width: 40rpx;
- line-height: 1;
- position: absolute;
- left: 20rpx;
- .uni-icons {
- color: #fff !important;
- }
- }
- }
- .page-content {
- position: relative;
- box-sizing: border-box;
- width: 100%;
- height: calc(100% - $header-height - $header-top-height);
- margin-top: calc($header-height + $header-top-height);
- overflow: hidden;
- overflow-y: auto;
- }
- .item {
- box-sizing: border-box;
- }
- </style>
|