diff --git a/README.md b/README.md index 231a5df..186a959 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,12 @@ node index.js 注意: 只需要引入 `crawler/casLogin.js` 作为模块即可获得验证 cookie 信息对象,含 `swms` 和 `campusphere` 参数,分别对应 学工 和 金智教务(今日校园相关) 验证凭据 +4. 清空学校配置: + +```sh +./init.js rm 'school' +``` + ## Features - 交互式配置: `campushpere-awesome-auth` 提供交互式的命令行完成 用户 及 学校 的配置,同时也支持使用 `yml` 文件来配置 diff --git a/init.js b/init.js index f4313af..4a4004b 100755 --- a/init.js +++ b/init.js @@ -153,29 +153,25 @@ class School { ] let res = await prompt(questions) - try { - res = await fetch( - `https://mobile.campushoy.com/v6/config/guest/tenant/info?ids=${res.ids}` - ) - - res = await JSON.parse(await res.text()) - const origin = new URL(res.data[0].ampUrl).origin - school = { - origin, - login: `${res.data[0].idsUrl}/login?service=${encodeURIComponent( - origin - )}/portal/login`, - campusphere: `${origin}/portal/login`, - checkCaptcha: `${res.data[0].idsUrl}/checkNeedCaptcha.htl`, - getCaptcha: `${res.data[0].idsUrl}/getCaptcha.htl`, - } - - this.conf.set('school', school) - log.success(`您的学校 ${res.data[0].name} 已完成设定`) - log.object(school) - } catch (e) { - log.error(e) + res = await fetch( + `https://mobile.campushoy.com/v6/config/guest/tenant/info?ids=${res.ids}` + ).catch(err => err) + + res = await JSON.parse(await res.text()) + const origin = new URL(res.data[0].ampUrl).origin + school = { + origin, + login: `${res.data[0].idsUrl}/login?service=${encodeURIComponent( + origin + )}/portal/login`, + campusphere: `${origin}/portal/login`, + checkCaptcha: `${res.data[0].idsUrl}/checkNeedCaptcha.htl`, + getCaptcha: `${res.data[0].idsUrl}/getCaptcha.htl`, } + + this.conf.set('school', school) + log.success(`您的学校 ${res.data[0].name} 已完成设定`) + log.object(school) } else { log.warning('学校信息已配置') } @@ -194,7 +190,8 @@ class School { if (type === 2) userUlti.deleteUser() } else if (process.argv[2].match(/(-s|--school)/)) { school = new School(conf).init() - } else { - process.exitCode = 0 + } + if (process.argv[2].match(/(rm|--remove)/)) { + conf.delete(process.argv[3]) } })()