mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: remove /user/search
This commit is contained in:
1 parent
6762e22bae
commit
5c97bbf1ba
8 files changed
+74
-48
No files matched your search
@@ -1,3 +1,26 @@
|
||||
import request from './request';
|
||||
|
||||
export default (q: string) => request.post('/api', { query: q.trim() });
|
||||
export default async (q: string, path: string[] = []) => {
|
||||
let query = q.trim();
|
||||
if (!query.startsWith('query')) query = `query{${query}}`;
|
||||
const res = await request.post('/api', { query });
|
||||
if (res.errors) throw new Error(res.errors[0].message);
|
||||
let cursor = res;
|
||||
for (const p of path) {
|
||||
cursor = cursor[p];
|
||||
if (!cursor) return undefined;
|
||||
}
|
||||
return cursor;
|
||||
};
|
||||
|
||||
export const e = (
|
||||
pieces: TemplateStringsArray,
|
||||
...templates: (string | number)[]
|
||||
) => {
|
||||
let res = '';
|
||||
for (let i = 0; i < pieces.length; i++) {
|
||||
res += pieces[i];
|
||||
if (templates[i]) res += JSON.stringify(templates[i]);
|
||||
}
|
||||
return res;
|
||||
};
|
||||
Reference in new issue
Block a user