Skip to content

Commit 6e62b10

Browse files
committed
采用多个key进行减少对key的压力...
1 parent e829bf7 commit 6e62b10

File tree

9 files changed

+92
-26
lines changed

9 files changed

+92
-26
lines changed

CodeVar.alfredworkflow

806 KB
Binary file not shown.

Configuration/variableGlobale.js

Lines changed: 84 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,97 @@
1212
'use strict';
1313

1414
const alfy = require('alfy');
15+
const sample = require('lodash.sample');
16+
17+
// 此 key 全采集于 github 上面 若有冒犯就先谢罪了啊哈...
18+
const FIXED_KEY = [
19+
{
20+
keyfrom: 'CoderVar',
21+
key: '802458398'
22+
},
23+
{
24+
keyfrom: 'whatMean',
25+
key: '1933652137'
26+
},
27+
{
28+
keyfrom: 'chinacache',
29+
key: '1247577973'
30+
},
31+
{
32+
keyfrom: 'huipblog',
33+
key: '439918742'
34+
},
35+
{
36+
keyfrom: 'chinacache',
37+
key: '1247577973'
38+
},
39+
{
40+
keyfrom: 'fanyi-node',
41+
key: '593554388'
42+
},
43+
{
44+
keyfrom: 'wbinglee',
45+
key: '1127870837'
46+
},
47+
{
48+
keyfrom: 'forum3',
49+
key: '1268771022'
50+
},
51+
{
52+
keyfrom: 'node-translator',
53+
key: '2058911035'
54+
},
55+
{
56+
keyfrom: 'kaiyao-robot',
57+
key: '2016811247'
58+
},
59+
{
60+
keyfrom: 'stone2083',
61+
key: '1576383390'
62+
},
63+
{
64+
keyfrom: 'myWebsite',
65+
key: '423366321'
66+
},
67+
{
68+
keyfrom: 'leecade',
69+
key: '54015339'
70+
},
71+
{
72+
keyfrom: 'github-wdict',
73+
key: '619541059'
74+
},
75+
{
76+
keyfrom: 'lanyuejin',
77+
key: '2033774719'
78+
},
79+
];
1580

1681
module.exports = {
1782
youDaoApi: 'http://fanyi.youdao.com/openapi.do',
18-
params : {
19-
query: {
20-
keyfrom: 'CoderVar',
21-
key: '802458398',
22-
type: 'data',
23-
doctype: 'json',
24-
version: '1.1',
25-
q: alfy.input
83+
getParams: function () {
84+
let selected = sample(FIXED_KEY);
85+
return {
86+
query: {
87+
keyfrom: selected.keyfrom,
88+
key: selected.key,
89+
type: 'data',
90+
doctype: 'json',
91+
version: '1.1',
92+
q: alfy.input
93+
94+
}
2695
}
2796
},
28-
filter:{
29-
prep:[
30-
'and','or','the','a','at','of'
31-
],
32-
prefix:[
33-
97+
filter: {
98+
prep: [
99+
'and', 'or', 'the', 'a', 'at', 'of'
34100
],
35-
suffix:[
36-
'ing','ed','ly'
101+
prefix: [],
102+
suffix: [
103+
'ing', 'ed', 'ly'
37104
],
38-
verb:[
105+
verb: [
39106
'was'
40107
]
41108
}

Configuration/variableStyle.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ module.exports = {
6060
},
6161
bigHump: function (s) {
6262
let strArr = filter.run(s);
63-
// 首单词首小写
64-
strArr[0] = strArr[0].toLowerCase();
6563
strArr[0] = strArr[0].charAt(0).toUpperCase() + strArr[0].substring(1);
6664
// 单词首字母大写
6765
for (let i = 1; i < strArr.length; i++) {
@@ -71,8 +69,6 @@ module.exports = {
7169
},
7270
hump: function (s) {
7371
let strArr = filter.run(s);
74-
// 首单词首小写
75-
strArr[0] = strArr[0].toLowerCase();
7672
// 单词首字母大写
7773
for (let i = 1; i < strArr.length; i++) {
7874
strArr[i] = strArr[i].charAt(0).toUpperCase() + strArr[i].substring(1);

NamedConstant.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ const config = require('./Configuration/variableGlobale.js');
1616
const style = require('./Configuration/variableStyle.js');
1717

1818
(function () {
19-
style.core(config.youDaoApi,config.params,style.namedConst);
19+
style.core(config.youDaoApi,config.getParams(),style.namedConst);
2020
})();

bigHump.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ const config = require('./Configuration/variableGlobale.js');
1616
const style = require('./Configuration/variableStyle.js');
1717

1818
(function () {
19-
style.core(config.youDaoApi,config.params,style.bigHump);
19+
style.core(config.youDaoApi,config.getParams(),style.bigHump);
2020
})();

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ const config = require('./Configuration/variableGlobale.js');
1515
const style = require('./Configuration/variableStyle.js');
1616

1717
(function () {
18-
style.core(config.youDaoApi,config.params,style.hump);
18+
style.core(config.youDaoApi,config.getParams(),style.hump);
1919
})();

info.plist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<dict>
55
<key>bundleid</key>
66
<string>codevar</string>
7+
<key>category</key>
8+
<string>Tools</string>
79
<key>connections</key>
810
<dict>
911
<key>0A329E4B-AB21-41F7-A869-D878DF4EAE92</key>
@@ -302,6 +304,6 @@
302304
</dict>
303305
</dict>
304306
<key>webaddress</key>
305-
<string></string>
307+
<string>https://github.com/xudaolong/CodeVar</string>
306308
</dict>
307309
</plist>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"lodash.difference": "^4.5.0",
16+
"lodash.sample": "^4.2.1",
1617
"lodash.union": "^4.6.0",
1718
"lodash.without": "^4.4.0"
1819
}

underline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ const config = require('./Configuration/variableGlobale.js');
1616
const style = require('./Configuration/variableStyle.js');
1717

1818
(function () {
19-
style.core(config.youDaoApi,config.params,style.underline);
19+
style.core(config.youDaoApi,config.getParams(),style.underline);
2020
})();

0 commit comments

Comments
 (0)