Skip to content

Commit

Permalink
🐛 修复值未发生改变时的报错
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Jan 15, 2023
1 parent b17581b commit a97981c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/repo/value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface Value {
key: string;
value: any;
createtime: number;
updatetime: number;
}

export class ValueDAO extends DAO<Value> {
Expand Down
6 changes: 6 additions & 0 deletions src/app/service/value/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,16 @@ export class ValueManager extends Manager {
key,
value,
createtime: new Date().getTime(),
updatetime: 0,
};
} else {
// 值未发生改变
if (model.value === value) {
return Promise.resolve(true);
}
oldValue = model.value;
model.value = value;
model.updatetime = new Date().getTime();
}
let changeNum = 0;
// 更新缓存
Expand Down
1 change: 1 addition & 0 deletions src/runtime/content/gm_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export default class GMApi {
key,
value,
createtime: new Date().getTime(),
updatetime: 0,
};
}
if (value === undefined) {
Expand Down

0 comments on commit a97981c

Please sign in to comment.