-
Notifications
You must be signed in to change notification settings - Fork 0
/
io.js
63 lines (54 loc) · 1.7 KB
/
io.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
module.exports = async($) => {
let queryer = await $.rq('libs/queryer'), paramer = await $.rq('libs/paramer');
let subs = {
main: { type: 'work', title: '卡牌查询' },
info: { type: 'page' }
};
return async(emit) => {
let raw = {
app: {
load: async(name, ...param) => {
let info = subs[name];
if(info.type == 'work')
await emit('appload', name, 'work', info.title,
fs.readFileSync(await $.pa(`asset/subs/${name}/app.html`)).toString().replace(/(\t)/g, '').replace(/(__name__)/g, name)
);
else if(info.type == 'page')
await emit('appload', name, 'page', await (await $.rq(`asset/subs/${name}/app.js`))(...param) );
}
},
main: {
query: async(conds) => {
conds.word = conds.word? conds.word.trim() : '';
conds.zero = !!~~conds.zero;
conds.mark = conds.mark.split('|');
for(let i in conds.mark)
conds.mark[i] = ~~conds.mark[i];
let mark = conds.mark,
result = await queryer(
await paramer.main(conds),
conds.prio ? { 'rend.prio.pvp': 1 } : {},
conds.serv, conds.page, $.conf.pageEvery
);
await emit('mainquery', result, (mark && !/^(\||0)+$/.test(mark)) ? mark : undefined);
},
conds: async() => {
await emit('mainconds', await $.rq('data/conds'));
}
},
gcur: {
query: async(conds) => {
let result = await queryer(
paramer.gur(conds), {}, conds.serv, conds.page, conds.every
);
await emit('gur', result);
}
}
},
func = {};
for(let sub in raw)
for(let name in raw[sub])
func[sub+name] = raw[sub][name];
return func;
};
};