@@ -2,8 +2,8 @@ var _ = require('underscore');
22
33var h = require ( './helper' ) ;
44
5- var DEFAULT_CONFIG = {
6- // usually you don't wanna change those
5+ // usually you don't wanna change those
6+ var DEFAULT_SYS_CONFIG = {
77 URL_BASE : 'https://leetcode.com' ,
88 URL_LOGIN : 'https://leetcode.com/accounts/login/' ,
99 URL_PROBLEMS : 'https://leetcode.com/api/problems/$category/' ,
@@ -16,23 +16,53 @@ var DEFAULT_CONFIG = {
1616 URL_FAVORITES : 'https://leetcode.com/list/api/questions' ,
1717 URL_FAVORITE_DELETE : 'https://leetcode.com/list/api/questions/$hash/$id' ,
1818
19- // but you will want change these
20- LANG : 'cpp' , // avail: [c,cpp,csharp,golang,java,javascript,python,ruby,swift]
19+ LANGS : [
20+ 'bash' ,
21+ 'c' ,
22+ 'cpp' ,
23+ 'csharp' ,
24+ 'golang' ,
25+ 'java' ,
26+ 'javascript' ,
27+ 'mysql' ,
28+ 'python' ,
29+ 'python3' ,
30+ 'ruby' ,
31+ 'scala' ,
32+ 'swift'
33+ ]
34+ } ;
35+
36+ // but you will want change these
37+ var DEFAULT_USER_CONFIG = {
2138 AUTO_LOGIN : false ,
22- USE_COLOR : true ,
2339 COLOR_THEME : 'default' ,
2440 ICON_THEME : '' ,
25- MAX_WORKERS : 10
41+ LANG : 'cpp' ,
42+ MAX_WORKERS : 10 ,
43+ USE_COLOR : true
2644} ;
2745
2846function Config ( ) { }
2947
3048Config . prototype . init = function ( ) {
31- _ . extendOwn ( this , DEFAULT_CONFIG ) ;
32-
3349 // check local config: ~/.lcconfig
3450 var localConfig = JSON . parse ( h . getFileData ( h . getConfigFile ( ) ) ) || { } ;
51+ _ . extendOwn ( this , this . getDefaultConfig ( ) ) ;
3552 _ . extendOwn ( this , localConfig ) ;
3653} ;
3754
55+ Config . prototype . getDefaultConfig = function ( ) {
56+ var cfg = { } ;
57+ _ . extendOwn ( cfg , DEFAULT_SYS_CONFIG ) ;
58+ _ . extendOwn ( cfg , DEFAULT_USER_CONFIG ) ;
59+ return cfg ;
60+ } ;
61+
62+ Config . prototype . getUserConfig = function ( ) {
63+ return _ . pick ( this , function ( v , k ) {
64+ return k in DEFAULT_USER_CONFIG ;
65+ } ) ;
66+ } ;
67+
3868module . exports = new Config ( ) ;
0 commit comments