@@ -69,9 +69,13 @@ export default class EntryAbility extends UIAbility {
|
||||
odMs = parsed;
|
||||
}
|
||||
}
|
||||
if (odMs > 0) {
|
||||
// 合法性校验:13 位毫秒时间戳若按 int32 传递会溢出成 2147483647 等小值 →
|
||||
// 只接受 [2000-01-01, 2100-01-01] 区间,避免把日历定位到 1970
|
||||
if (odMs >= 946684800000 && odMs <= 4102444800000) {
|
||||
AppStorage.setOrCreate<number>('widgetOpenDate', odMs);
|
||||
LogUtil.write(`卡片进入日历:定位到显示日 ${odMs}`);
|
||||
} else if (odMs > 0) {
|
||||
LogUtil.write(`卡片 openDate 非法(疑似 int32 溢出):${odMs},忽略`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,11 +103,14 @@ struct Index {
|
||||
this.selectedDate = this.startOfDay(now.getTime());
|
||||
// 卡片点击:若携带显示日(用户可能已翻到其他日期),进入日历时定位到那一天
|
||||
const openFromCard: number = AppStorage.get<number>('widgetOpenDate') ?? 0;
|
||||
if (openFromCard > 0) {
|
||||
if (openFromCard !== 0) {
|
||||
AppStorage.setOrCreate<number>('widgetOpenDate', 0); // 用后即清,避免残留
|
||||
// 合法性校验(防 int32 溢出等脏值把日历定位到 1970)
|
||||
if (openFromCard >= 946684800000 && openFromCard <= 4102444800000) {
|
||||
this.selectedDate = this.startOfDay(openFromCard);
|
||||
AppStorage.setOrCreate<number>('widgetOpenDate', 0);
|
||||
LogUtil.write(`从卡片进入:定位到显示日 ${this.selectedDate}`);
|
||||
}
|
||||
}
|
||||
this.rebuildPages();
|
||||
this.initLandscapeListener();
|
||||
// 首启同意门禁:未同意《隐私政策》与《用户协议》前,不申请任何系统权限、不加载/同步数据(AGC 硬性要求)
|
||||
@@ -181,12 +184,15 @@ struct Index {
|
||||
/** 卡片点击携带的"显示日":App 已在后台运行时由 onNewWant 改写,定位到那一天后清除 */
|
||||
private onWidgetOpenDateChange(): void {
|
||||
const d: number = this.widgetOpenDate;
|
||||
if (d > 0) {
|
||||
if (d !== 0) {
|
||||
AppStorage.setOrCreate<number>('widgetOpenDate', 0); // 用后即清,避免残留
|
||||
// 合法性校验(防 int32 溢出等脏值)
|
||||
if (d >= 946684800000 && d <= 4102444800000) {
|
||||
this.selectedDate = this.startOfDay(d);
|
||||
AppStorage.setOrCreate<number>('widgetOpenDate', 0);
|
||||
LogUtil.write(`卡片切入(运行中):定位到显示日 ${this.selectedDate}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 消费卡片"添加"深链:拉起新建日程页并立即清除标记,避免重复触发 */
|
||||
private consumeWidgetAction(): void {
|
||||
|
||||
@@ -422,8 +422,9 @@ struct Widget4x4Card {
|
||||
postCardAction(this, {
|
||||
action: 'router',
|
||||
abilityName: 'EntryAbility',
|
||||
// 携带卡片当前显示日(用户可能已翻到其他日期),进入日历时定位到这一天
|
||||
params: { openDate: this.selectedDate }
|
||||
// 携带卡片当前显示日(用户可能已翻到其他日期),进入日历时定位到这一天。
|
||||
// 必须转成字符串:param 的数值按 int32 传递,13 位毫秒时间戳会溢出成 2147483647(曾导致定位到 1970)
|
||||
params: { openDate: `${this.selectedDate}` }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -419,8 +419,9 @@ struct Widget6x4Card {
|
||||
postCardAction(this, {
|
||||
action: 'router',
|
||||
abilityName: 'EntryAbility',
|
||||
// 携带卡片当前显示日(用户可能已翻到其他日期),进入日历时定位到这一天
|
||||
params: { openDate: this.selectedDate }
|
||||
// 携带卡片当前显示日(用户可能已翻到其他日期),进入日历时定位到这一天。
|
||||
// 必须转成字符串:param 的数值按 int32 传递,13 位毫秒时间戳会溢出成 2147483647(曾导致定位到 1970)
|
||||
params: { openDate: `${this.selectedDate}` }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user