Skip to content

Commit

Permalink
feat(app): 删除超星智慧树的其他登录,新增自定义链接进入。
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Jun 4, 2022
1 parent 5ff27e5 commit 5851511
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 41 deletions.
6 changes: 6 additions & 0 deletions packages/scripts/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Page } from 'playwright';

export async function openLink(page: Page, { url }: { url: string }) {
await page.goto(url);
return page;
}
1 change: 0 additions & 1 deletion packages/scripts/src/cx/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { phoneCodeLogin } from './phone.code';
export { phoneLogin } from './phone';
export { schoolLogin } from './school';
export { otherLogin } from './other';
8 changes: 0 additions & 8 deletions packages/scripts/src/cx/login/other.ts

This file was deleted.

24 changes: 11 additions & 13 deletions packages/scripts/src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,24 @@ export interface LaunchScriptsOptions {
localStorage: any
}

export const scripts: Record<keyof ScriptOptions, ScriptFunction> = {
'cx-login-other': CX.otherLogin,
'cx-login-phone': CX.phoneLogin,
'cx-login-phone-code': CX.phoneCodeLogin,
'cx-login-school': CX.schoolLogin,
'zhs-login-other': ZHS.otherLogin,
'zhs-login-phone': ZHS.phoneLogin,
'zhs-login-school': ZHS.schoolLogin
};

export const scriptNames = [
['cx-login-other', '超星手动登录'],
['cx-login-phone', '超星手机密码登录'],
['cx-login-phone-code', '超星手机验证码登录'],
['cx-login-school', '超星学校登录'],
['zhs-login-other', '智慧树手动登录'],
['zhs-login-phone', '智慧树手机登录'],
['zhs-login-school', '智慧树学校登录']
['zhs-login-school', '智慧树学校登录'],
['open-diy-link', '进入自定义链接']
];

export const scripts: Record<keyof ScriptOptions, ScriptFunction> = {
'cx-login-phone': CX.phoneLogin,
'cx-login-phone-code': CX.phoneCodeLogin,
'cx-login-school': CX.schoolLogin,
'zhs-login-phone': ZHS.phoneLogin,
'zhs-login-school': ZHS.schoolLogin,
'open-diy-link': openLink
};

process.on('unhandledRejection', (e) => {
console.error('未知错误', e);
});
Expand Down
5 changes: 3 additions & 2 deletions packages/scripts/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { CXLoginOptions } from './cx/types';
import { ZHSLoginOptions } from './zhs/types';

export interface ScriptOptions {
'cx-login-other': {}
'cx-login-phone': CXLoginOptions['phone']
'cx-login-phone-code': CXLoginOptions['phoneCode']
'cx-login-school': CXLoginOptions['school']
'zhs-login-other': {}
'zhs-login-phone': ZHSLoginOptions['phone']
'zhs-login-school': ZHSLoginOptions['school']
'open-diy-link': {
url: string
}
}

export type ScriptFunction<Opts = any> = (page: Page, opts: Opts) => Promise<Page>
1 change: 0 additions & 1 deletion packages/scripts/src/zhs/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export { phoneLogin } from './phone';
export { schoolLogin } from './school';
export { otherLogin } from './other';
10 changes: 0 additions & 10 deletions packages/scripts/src/zhs/login/other.ts

This file was deleted.

18 changes: 12 additions & 6 deletions packages/web/src/components/file/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ export type Form<T extends keyof ScriptOptions> = Record<keyof ScriptOptions[T],
* 脚本的基础登录表单,使用 File.vue 可以自动生成表单内容
*/
export const scriptForms: Record<keyof ScriptOptions, any> = {
'cx-login-other': {} as Form<'cx-login-other'>,
'cx-login-phone': {
phone: {
type: 'tel',
title: '手机号',
title: '手机',
required: true
},
password: {
Expand All @@ -34,7 +33,7 @@ export const scriptForms: Record<keyof ScriptOptions, any> = {
'cx-login-phone-code': {
phone: {
type: 'tel',
title: '手机号',
title: '手机',
required: true
}
} as Form<'cx-login-phone-code'>,
Expand All @@ -55,11 +54,10 @@ export const scriptForms: Record<keyof ScriptOptions, any> = {
required: true
}
} as Form<'cx-login-school'>,
'zhs-login-other': {} as Form<'zhs-login-other'>,
'zhs-login-phone': {
phone: {
type: 'tel',
title: '手机号',
title: '手机',
required: true
},
password: {
Expand All @@ -84,5 +82,13 @@ export const scriptForms: Record<keyof ScriptOptions, any> = {
title: '密码',
required: true
}
} as Form<'zhs-login-school'>
} as Form<'zhs-login-school'>,
'open-diy-link': {
url: {
type: 'text',
title: '链接',
required: true
}
} as Form<'open-diy-link'>

};

0 comments on commit 5851511

Please sign in to comment.