修正排序逻辑

This commit is contained in:
fofolee 2022-05-23 10:49:28 +08:00
parent 450d70c954
commit 93963f0473

View File

@ -184,7 +184,9 @@ export default {
this.errCommandsCount++; this.errCommandsCount++;
return; return;
} }
this.commands.push(command); command.updated
? this.commands.unshift(command.data)
: this.commands.push(command.data);
}); });
}); });
}, },
@ -216,7 +218,11 @@ export default {
// //
async getCommand(id, updateTime, authorName, authorId) { async getCommand(id, updateTime, authorName, authorId) {
let localCache = JSON.parse(localStorage.getItem(id)); let localCache = JSON.parse(localStorage.getItem(id));
if (localCache?.updateTime === updateTime) return localCache; if (localCache?.updateTime === updateTime)
return {
data: localCache,
updated: false,
};
let res = await window.yuQueClient( let res = await window.yuQueClient(
`repos/${this.releaseRepo}/docs/${id}?raw=1` `repos/${this.releaseRepo}/docs/${id}?raw=1`
); );
@ -231,7 +237,10 @@ export default {
if (!command) return; if (!command) return;
Object.assign(command, { authorName, updateTime, authorId }); Object.assign(command, { authorName, updateTime, authorId });
localStorage.setItem(id, JSON.stringify(command)); localStorage.setItem(id, JSON.stringify(command));
return command; return {
data: command,
updated: true,
};
}, },
fetchCommands() { fetchCommands() {
window.yuQueClient(`repos/${this.releaseRepo}/docs`).then((res) => { window.yuQueClient(`repos/${this.releaseRepo}/docs`).then((res) => {