|
|
@@ -13,11 +13,24 @@ import {
|
|
|
yTRouter,
|
|
|
YTToast,
|
|
|
YTUserRequest
|
|
|
-} from '../../../../Index'
|
|
|
+} from '../../../../../../Index'
|
|
|
import { identifier } from '@kit.AdsKit'
|
|
|
import { BusinessError } from '@kit.BasicServicesKit'
|
|
|
|
|
|
export class ContextHelper {
|
|
|
+ private static _oldContext: Context
|
|
|
+
|
|
|
+ static get oldContext() {
|
|
|
+ if (!ContextHelper._oldContext) {
|
|
|
+ throw new Error('oldContext is not set')
|
|
|
+ }
|
|
|
+ return ContextHelper._oldContext
|
|
|
+ }
|
|
|
+
|
|
|
+ private static set oldContext(value: Context) {
|
|
|
+ ContextHelper._oldContext = value
|
|
|
+ }
|
|
|
+
|
|
|
private static declare _UIContext: UIContext
|
|
|
|
|
|
static get UIContext() {
|
|
|
@@ -27,7 +40,7 @@ export class ContextHelper {
|
|
|
return ContextHelper._UIContext
|
|
|
}
|
|
|
|
|
|
- static set UIContext(value: UIContext) {
|
|
|
+ private static set UIContext(value: UIContext) {
|
|
|
ContextHelper._UIContext = value
|
|
|
const context = value.getHostContext()
|
|
|
if (context && !ContextHelper._context) {
|
|
|
@@ -45,7 +58,7 @@ export class ContextHelper {
|
|
|
return ContextHelper._UIAbilityContext
|
|
|
}
|
|
|
|
|
|
- static set UIAbilityContext(value: common.UIAbilityContext) {
|
|
|
+ private static set UIAbilityContext(value: common.UIAbilityContext) {
|
|
|
ContextHelper._UIAbilityContext = value
|
|
|
if (!ContextHelper._context) {
|
|
|
ContextHelper.context = value
|
|
|
@@ -62,7 +75,7 @@ export class ContextHelper {
|
|
|
return ContextHelper._context
|
|
|
}
|
|
|
|
|
|
- static set context(value: Context) {
|
|
|
+ private static set context(value: Context) {
|
|
|
ContextHelper._context = value
|
|
|
}
|
|
|
|
|
|
@@ -72,16 +85,17 @@ export class ContextHelper {
|
|
|
* @param context 上下文对象
|
|
|
* @param isOnline 是否为在线app
|
|
|
*/
|
|
|
- static init(context: UIContext, isOnline: boolean = true) {
|
|
|
+ static init(context: UIContext, oldContext: Context, isOnline: boolean = true) {
|
|
|
ContextHelper.UIContext = context
|
|
|
+ ContextHelper._oldContext = oldContext
|
|
|
PersistentStorage.persistProp(AppStorageKeyCollect.IS_STAND_ALONE_APP, isOnline)
|
|
|
- if(isOnline) {
|
|
|
+ if (isOnline) {
|
|
|
PersistentStorage.persistProp(AppStorageKeyCollect.TOKEN, '')
|
|
|
YTUserRequest.refreshUserInfo()
|
|
|
} else {
|
|
|
PersistentStorage.persistProp(AppStorageKeyCollect.FIRST_ENTER_APP, false)
|
|
|
let isFirst = AppStorage.get(AppStorageKeyCollect.FIRST_ENTER_APP)! as boolean
|
|
|
- if(!isFirst) {
|
|
|
+ if (!isFirst) {
|
|
|
yTRouter.pushPathByName('EntryPage', null)
|
|
|
}
|
|
|
}
|