Initial search
This commit is contained in:
parent
6db34b9cee
commit
7a9b72a33a
|
@ -7,12 +7,20 @@ export default class ServerEmu {
|
||||||
|
|
||||||
await new Promise(r => setTimeout(r, Math.random() * 3000));
|
await new Promise(r => setTimeout(r, Math.random() * 3000));
|
||||||
|
|
||||||
|
let docs = this._themes;
|
||||||
|
|
||||||
|
if (args && args.sterm) {
|
||||||
|
const { sterm } = args;
|
||||||
|
const reg = new RegExp(sterm, 'gi');
|
||||||
|
docs = docs.filter(doc => doc.tags.includes(sterm) || reg.exec(doc.name) || reg.exec(doc.description));
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
docs: this._themes,
|
docs,
|
||||||
pagination: {
|
pagination: {
|
||||||
total: this._themes.length,
|
total: docs.length,
|
||||||
pages: this._themes.length / 9,
|
pages: docs.length / 9,
|
||||||
limit: 0,
|
limit: 9,
|
||||||
page: 1
|
page: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +47,8 @@ export default class ServerEmu {
|
||||||
version: this.randomVersion(),
|
version: this.randomVersion(),
|
||||||
repository: this.dummyRepo,
|
repository: this.dummyRepo,
|
||||||
files: this.dummyFiles,
|
files: this.dummyFiles,
|
||||||
author: this.dummyAuthor
|
author: this.dummyAuthor,
|
||||||
|
description: ''
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,12 +98,12 @@
|
||||||
async refreshLocal() {
|
async refreshLocal() {
|
||||||
await this.ThemeManager.refreshThemes();
|
await this.ThemeManager.refreshThemes();
|
||||||
},
|
},
|
||||||
async refreshOnline() {
|
async refreshOnline(sterm) {
|
||||||
this.searchHint = '';
|
this.searchHint = '';
|
||||||
if (this.loadingOnline || this.loadingMore) return;
|
if (this.loadingOnline || this.loadingMore) return;
|
||||||
this.loadingOnline = true;
|
this.loadingOnline = true;
|
||||||
try {
|
try {
|
||||||
const getThemes = await BdWebApi.themes.get();
|
const getThemes = await BdWebApi.themes.get({ sterm });
|
||||||
this.onlineThemes = getThemes;
|
this.onlineThemes = getThemes;
|
||||||
if (!this.onlineThemes.docs) return;
|
if (!this.onlineThemes.docs) return;
|
||||||
this.searchHint = `${this.onlineThemes.pagination.total} Results`;
|
this.searchHint = `${this.onlineThemes.pagination.total} Results`;
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
},
|
},
|
||||||
searchInput(e) {
|
searchInput(e) {
|
||||||
if (this.loadingOnline || this.loadingMore) return;
|
if (this.loadingOnline || this.loadingMore) return;
|
||||||
this.refreshOnline();
|
this.refreshOnline(e.target.value);
|
||||||
},
|
},
|
||||||
async scrollend(e) {
|
async scrollend(e) {
|
||||||
if (this.loadingOnline || this.loadingMore) return;
|
if (this.loadingOnline || this.loadingMore) return;
|
||||||
|
|
Loading…
Reference in New Issue