Commit 82270ab6 by 岑成威

fix: 更新app.vue

1 parent 723cba3f
Showing 1 changed file with 160 additions and 177 deletions
<script> <script>
const PATH = ['/pages/common/caseDetail'] const PATH = ['/pages/common/caseDetail']
const keepAlive = uni.requireNativePlugin('Ba-KeepAliveSuit') const keepAlive = uni.requireNativePlugin('Ba-KeepAliveSuit')
import { mapState } from 'vuex' import { mapState } from 'vuex'
import { Ws } from '@/ws/Ws.js' import { Ws } from '@/ws/Ws.js'
import { RecordSaveService, UploadService } from '@/utils/recordManager/index.js' import { RecordSaveService, UploadService } from '@/utils/recordManager/index.js'
import appCacheApi from '@/utils/clearAppCache.js' export default {
import FloatLogConfig from '@/utils/logger/FloatLogConfig.js' computed: {
// #ifdef APP-PLUS ...mapState('audio', ['isEnd', 'isStart'])
import StoragePathMerge from '@/utils/storageMerge/StoragePathMerge.js' },
import { logStep as mergeLogStep, logStepFail as mergeLogStepFail } from '@/utils/storageMerge/log.js' globalData: {
// #endif userInfo: uni.getStorageSync('release_userInfo')
export default { },
computed: { onLaunch: async function () {
...mapState('audio', ['isEnd', 'isStart']) this.onKeep()
}, this.setAPPVersion()
globalData: { setTimeout(() => {
userInfo: uni.getStorageSync('release_userInfo') plus.screen.unlockOrientation() //解除锁定屏幕方向
plus.screen.lockOrientation('landscape-primary')
}, 300)
uni.setKeepScreenOn({
keepScreenOn: true
})
new Ws().connect()
},
methods: {
onKeep() {
keepAlive &&
keepAlive.onKeep(
{
title: '接待',
content: '接待通知'
},
res => {
console.log(res)
}
)
}, },
onLaunch: async function () { setAPPVersion() {
// 先拉取/应用悬浮窗配置并 install,再合并,避免启动日志丢失 let version = plus.runtime.version
try { let storageVersion = uni.$storage.get('storageVersion')
await FloatLogConfig.refreshFromServer(true) uni.$logger.local.info(`storageVersion ->${storageVersion}, version ->${version}`)
} catch (_) { if (storageVersion != version) {
/* ignore */ uni.$storage.rm('userInfo')
uni.$storage.rm('noSignInUuid')
} }
// #ifdef APP-PLUS uni.$storage.set('storageVersion', version)
try { }
await uni.$dbRecord.init() },
mergeLogStep('归并·启动', 'App onLaunch:主库 init 完成,调用 StoragePathMerge.run()') onShow: async function () {
await StoragePathMerge.run() this.$store.dispatch('setBackgroundState', false)
} catch (e) { this.$store.dispatch('setActivityWindowPopCount', 1) //冷启动重置活动弹框次数
mergeLogStepFail('归并·启动', '启动数据库/合并异常', { 错误: e?.message || String(e) }) // 触发轮询开始事件,通知上传管理重新开始轮询
} finally { // UploadService.startPolling()
uni.$resolveStorageMerge?.() RecordSaveService.startPolling()
mergeLogStep('归并·启动', 'App onLaunch:归并流程结束(uni.$resolveStorageMerge 已触发)') uni.onMemoryWarning(function () {
} console.log('onMemoryWarningReceive')
// #endif })
// #ifndef APP-PLUS // const systemInfo = await uni.$api.systemApi.getMockData();
uni.$resolveStorageMerge?.() // if (systemInfo.isCheckedUpdate) {
// #endif // checkUpdate();
this.onKeep() // }
// this.setAPPVersion() // let version = plus.runtime.version;
setTimeout(() => { // uni.$api.commonApi.getAPPVersion().then((res) => {
plus.screen.unlockOrientation() //解除锁定屏幕方向 // if (res != version && !systemInfo.isCheckedUpdate)
plus.screen.lockOrientation('landscape-primary') // this.$store.dispatch("openUpdateModal");
}, 300) // });
uni.setKeepScreenOn({ },
keepScreenOn: true onHide: function () {
this.$store.dispatch('setBackgroundState', true)
},
onError: function (e) {
try {
const msg = typeof e === 'string' ? e : e.message || '捕获全局异常'
const stack = typeof e === 'object' ? e.stack || JSON.stringify(e) : ''
uni.$logger?.error({
msg: `[全局异常] ${msg}`,
extra: {
stack,
raw: e,
url: this.$route?.path || 'unknown'
}
}) })
new Ws().connect() } catch (error) {
}, console.error('日志上报失败:', error)
methods: { }
onKeep() { },
keepAlive && onUnhandledRejection: function (res) {
keepAlive.onKeep( try {
{ const reason = res.reason
title: '接待', const msg = reason instanceof Error ? reason.message : typeof reason === 'string' ? reason : '未处理的 Promise 拒绝'
content: '接待通知' const stack = reason instanceof Error ? reason.stack : JSON.stringify(reason)
}, uni.$logger?.error({
res => { msg: `[UnhandledRejection] ${msg}`,
console.log(res) extra: {
} stack,
) reason: reason,
}, url: this.$route?.path || 'unknown'
setAPPVersion() {
let version = plus.runtime.version
let storageVersion = uni.$storage.get('storageVersion')
uni.$logger.local.info(`storageVersion ->${storageVersion}, version ->${version}`)
if (storageVersion != version) {
uni.$storage.rm('userInfo')
uni.$storage.rm('noSignInUuid')
} }
uni.$storage.set('storageVersion', version)
}
},
onShow: async function () {
appCacheApi.clearAppCache()
this.$store.dispatch('setBackgroundState', false)
this.$store.dispatch('setActivityWindowPopCount', 1) //冷启动重置活动弹框次数
RecordSaveService.startPolling()
uni.onMemoryWarning(function () {
console.log('onMemoryWarningReceive')
}) })
}, } catch (error) {
onHide: function () { console.error('Promise 异常上报失败:', error)
this.$store.dispatch('setBackgroundState', true)
},
onError: function (e) {
try {
const msg = typeof e === 'string' ? e : e.message || '捕获全局异常'
const stack = typeof e === 'object' ? e.stack || JSON.stringify(e) : ''
uni.$logger?.error({
msg: `[全局异常] ${msg}`,
extra: {
stack,
raw: e,
url: this.$route?.path || 'unknown'
}
})
} catch (error) {
console.error('日志上报失败:', error)
}
},
onUnhandledRejection: function (res) {
try {
const reason = res.reason
const msg = reason instanceof Error ? reason.message : typeof reason === 'string' ? reason : '未处理的 Promise 拒绝'
const stack = reason instanceof Error ? reason.stack : JSON.stringify(reason)
uni.$logger?.error({
msg: `[UnhandledRejection] ${msg}`,
extra: {
stack,
reason: reason,
url: this.$route?.path || 'unknown'
}
})
} catch (error) {
console.error('Promise 异常上报失败:', error)
}
} }
} }
</script> }
<style lang="scss"> </script>
page { <style lang="scss">
font-size: 28rpx; page {
height: 100%; font-size: 28rpx;
min-height: 100%; height: 100%;
} min-height: 100%;
view, }
navigator, view,
image, navigator,
text, image,
scroll-view, text,
swiper, scroll-view,
swiper-item, swiper,
input, swiper-item,
textarea, input,
button { textarea,
box-sizing: border-box; button {
} box-sizing: border-box;
/* 文字避头尾法则 */ }
.btw { /* 文字避头尾法则 */
table-layout: fixed; .btw {
word-wrap: break-word; table-layout: fixed;
word-break: normal; word-wrap: break-word;
text-align: justify; word-break: normal;
text-justify: inter-ideograph; text-align: justify;
} text-justify: inter-ideograph;
.bg-white { }
background: #fff; .bg-white {
} background: #fff;
.font-weight { }
font-weight: bold; .font-weight {
} font-weight: bold;
.u-flex-center { }
display: flex; .u-flex-center {
flex-direction: row; display: flex;
align-items: center; flex-direction: row;
justify-content: center; align-items: center;
} justify-content: center;
button { }
margin: 0; button {
padding: 0; margin: 0;
line-height: 1.5; padding: 0;
font-size: 28rpx; line-height: 1.5;
background-color: transparent; font-size: 28rpx;
border-radius: 0; background-color: transparent;
position: relative; border-radius: 0;
} position: relative;
button::after { }
border: none; button::after {
} border: none;
// 指定按钮按下去的样式类 }
.button-hover { // 指定按钮按下去的样式类
transform: translate(1rpx, 1rpx); .button-hover {
} transform: translate(1rpx, 1rpx);
.webview-container { }
position: absolute; .webview-container {
width: 100rpx; position: absolute;
height: 100rpx; width: 100rpx;
top: 0rpx; height: 100rpx;
left: 0rpx; top: 0rpx;
} left: 0rpx;
</style> }
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!