Skip to content

Commit 79ad4e2

Browse files
committed
updatetime 严格递增
1 parent 33bb307 commit 79ad4e2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/app/service/service_worker/value.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { stackAsyncTask } from "@App/pkg/utils/async_queue";
1515
import { encodeMessage } from "@App/pkg/utils/message_value";
1616
import { isEarlyStartScript } from "../content/utils";
1717

18+
let lastUpdateTime = 0;
19+
1820
type ValueUpdateTaskInfo = {
1921
uuid: string;
2022
id: string;
@@ -156,7 +158,12 @@ export class ValueService {
156158
const entries = [] as [string, any, any][];
157159
const { uuid, values, removeNotProvided } = task;
158160
let oldValueRecord: { [key: string]: any } = {};
159-
const now = Date.now();
161+
let now = Date.now();
162+
// 保证严格递增
163+
if (lastUpdateTime >= now) {
164+
now = lastUpdateTime + 0.0009765625; // 2^-10
165+
}
166+
lastUpdateTime = now;
160167
let newData;
161168
if (!valueModel) {
162169
const dataModel: { [key: string]: any } = {};

0 commit comments

Comments
 (0)