mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
函数命名调整
This commit is contained in:
parent
efee673358
commit
0e48da299f
@ -136,7 +136,7 @@ import commandTypes from "../js/options/commandTypes.js";
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
initCommands: [],
|
remoteCommands: [],
|
||||||
matchedCommands: [],
|
matchedCommands: [],
|
||||||
commands: [],
|
commands: [],
|
||||||
installedCodes: [],
|
installedCodes: [],
|
||||||
@ -203,9 +203,10 @@ export default {
|
|||||||
quickcommand.showMessageBox("导入成功!可到「来自分享」标签查看");
|
quickcommand.showMessageBox("导入成功!可到「来自分享」标签查看");
|
||||||
},
|
},
|
||||||
updateSearch() {
|
updateSearch() {
|
||||||
if (!this.commandSearchKeyword) this.matchedCommands = this.initCommands;
|
if (!this.commandSearchKeyword)
|
||||||
|
this.matchedCommands = this.remoteCommands;
|
||||||
else
|
else
|
||||||
this.matchedCommands = this.initCommands.filter((x) =>
|
this.matchedCommands = this.remoteCommands.filter((x) =>
|
||||||
x.title
|
x.title
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.includes(this.commandSearchKeyword.toLowerCase())
|
.includes(this.commandSearchKeyword.toLowerCase())
|
||||||
@ -224,18 +225,17 @@ export default {
|
|||||||
);
|
);
|
||||||
if (!command) return;
|
if (!command) return;
|
||||||
Object.assign(command, { authorName, updateTime });
|
Object.assign(command, { authorName, updateTime });
|
||||||
command.updateTime = updateTime;
|
|
||||||
localStorage.setItem(id, JSON.stringify(command));
|
localStorage.setItem(id, JSON.stringify(command));
|
||||||
return command;
|
return command;
|
||||||
},
|
},
|
||||||
fetchCommands() {
|
fetchCommands() {
|
||||||
window.yuQueClient(`repos/${this.releaseRepo}/docs`).then((res) => {
|
window.yuQueClient(`repos/${this.releaseRepo}/docs`).then((res) => {
|
||||||
// 按更新日期排序
|
// 按更新日期排序
|
||||||
this.initCommands = res.data.data.sort((x, y) =>
|
this.remoteCommands = res.data.data.sort((x, y) =>
|
||||||
this.compareTime(y.content_updated_at, x.content_updated_at)
|
this.compareTime(y.content_updated_at, x.content_updated_at)
|
||||||
);
|
);
|
||||||
this.checkCommands();
|
this.checkCommands();
|
||||||
this.matchedCommands = _.cloneDeep(this.initCommands);
|
this.matchedCommands = _.cloneDeep(this.remoteCommands);
|
||||||
this.fetchCommandDetails(1);
|
this.fetchCommandDetails(1);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -245,19 +245,21 @@ export default {
|
|||||||
this.$root.utools.getDocs(this.$root.utools.DBPRE.QC).forEach((item) => {
|
this.$root.utools.getDocs(this.$root.utools.DBPRE.QC).forEach((item) => {
|
||||||
if (!item.data.fromShare) return;
|
if (!item.data.fromShare) return;
|
||||||
let code = item._id.slice(3);
|
let code = item._id.slice(3);
|
||||||
if(code.includes('pro')) console.log(code);
|
let remote = this.remoteCommands.filter((cmd) => cmd.slug === code)[0];
|
||||||
let remote = this.initCommands.filter((cmd) => cmd.slug === code)[0];
|
|
||||||
if (!remote) return;
|
if (!remote) return;
|
||||||
let localUpdateTime =
|
let localUpdateTime =
|
||||||
item.data.updateTime || "2022-04-01T00:00:00.000Z";
|
item.data.updateTime || "2022-04-01T00:00:00.000Z";
|
||||||
if (this.compareTime(remote.content_updated_at, localUpdateTime) > 0) {
|
if (this.compareTime(remote.content_updated_at, localUpdateTime) > 0) {
|
||||||
needUpdate.push(code);
|
needUpdate.push(code);
|
||||||
_.pull(this.initCommands, remote);
|
_.pull(this.remoteCommands, remote);
|
||||||
this.initCommands.unshift(remote);
|
this.remoteCommands.unshift(remote);
|
||||||
} else installed.push(code);
|
} else installed.push(code);
|
||||||
this.installedCodes = installed;
|
this.installedCodes = installed;
|
||||||
this.needUpdateCodes = needUpdate;
|
this.needUpdateCodes = needUpdate;
|
||||||
});
|
});
|
||||||
|
console.log("installedCodes", this.installedCodes);
|
||||||
|
console.log("needUpdateCodes", this.needUpdateCodes);
|
||||||
|
console.log("remoteCommands", this.remoteCommands);
|
||||||
},
|
},
|
||||||
compareTime(x, y) {
|
compareTime(x, y) {
|
||||||
return new Date(x).getTime() - new Date(y).getTime();
|
return new Date(x).getTime() - new Date(y).getTime();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user