Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
beetcb committed May 23, 2021
1 parent 5a857fc commit 1ed6699
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beetcb/cea",
"version": "2.1.19",
"version": "2.2.0",
"description": "campusphere-elegant-auth: login to swms/campusphere at ease",
"main": "dist/index.js",
"bin": "dist/cli.js",
Expand Down Expand Up @@ -31,6 +31,9 @@
"singleQuote": true,
"printWidth": 80
},
"signale": {
"underlineLabel": false
},
"dependencies": {
"@beetcb/sstore": "^0.1.0",
"@iarna/toml": "^2.2.5",
Expand Down
14 changes: 4 additions & 10 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,6 @@ class User {
name: 'alias',
message: '(可选)请输入用户别名',
},
{
type: 'input',
name: 'cookie',
message: '(可选,将省去登录操作)抓包到的 Cookie',
},
]

const res = await prompt(questions)
Expand All @@ -143,13 +138,12 @@ class User {
const addUser = {
username: res.username,
password: res.password,
alias: res.alias || null,
cookie: res.cookie,
alias: res.alias || res.username,
}
conf.set('users', [addUser, ...conf.get('users')])
console.log('🎉 成功添加用户', addUser)
log.success('🎉 成功添加用户', addUser)
} else {
console.log('🙃 用户已存在')
log.error('🙃 用户已存在')
}
}

Expand Down Expand Up @@ -178,7 +172,7 @@ class User {
.filter((el, index) => index !== res.selection)
conf.set('users', neoUsers)

console.log('🎉 成功删除用户')
log.success('🎉 成功删除用户')
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ async function handleLogin(i, storeCookiePath) {
cookie = await login(conf.get('school'), i)
if (cookie) {
conf.set(storeCookiePath, cookie)
log.success(`用户${name}: 已成功获取并缓存 Cookie`)
log.success({
message: `已成功获取并缓存 COOKIE`,
suffix: `@${name}`,
})
}
}
const sign = new signApp(conf.get('school'), i)
Expand All @@ -41,10 +44,16 @@ async function handleLogin(i, storeCookiePath) {
if (cookie) {
conf.set(storeCookiePath, cookie)
await sign.signInfo(cookie)
log.success(`用户${name}: 已成功刷新并缓存 Cookie`)
log.success({
message: `已成功刷新并缓存 COOKIE`,
suffix: `@${name}`,
})
}
} else {
log.success(`用户${name}: 尝试使用缓存中的 Cookie`)
log.success({
message: `尝试使用缓存中的 COOKIE`,
suffix: `@${name}`,
})
}
// Make use of the cur task we already have
return sign
Expand Down
2 changes: 1 addition & 1 deletion src/crawler/casLogIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ module.exports = async (school, user) => {
res = await fetch.follow({ cookiePath })

if (/30(1|2|7|8)/.test(res.status + '')) {
log.error({
log.success({
message: `登录成功`,
suffix: `@${name}`,
})
Expand Down

0 comments on commit 1ed6699

Please sign in to comment.