Merge pull request 'Update project config' (#68) from dev-mrkbear into master

Reviewed-on: http://git.mrkbear.com/MrKBear/mini-dlpu-v3/pulls/68
This commit is contained in:
MrKBear 2022-06-09 17:25:22 +08:00
commit bb962cb8cf
5 changed files with 128 additions and 54 deletions

View File

@ -32,11 +32,6 @@ interface ILoginOutput {
*/ */
actualName: string; actualName: string;
/**
*
*/
isSubscribeWxAccount: boolean;
/** /**
* session * session
*/ */

View File

@ -1,12 +1,46 @@
import { Data } from "../core/Data"; import { Data } from "../core/Data";
import { Storage } from "../core/Storage";
import { Login, ILoginOutput } from "../api/Login";
/** /**
* *
*/ */
enum LoginStatus { enum LoginStatus {
/**
*
*/
verified = 1,
/**
*
*
*/
invalid = 2,
/**
*
*/
none = 3
} }
/**
* API
*/
type ILoginApiData = {
[P in keyof ILoginOutput]: {
type: ILoginOutput[P];
getAsync: () => Promise<ILoginOutput[P]>;
}
}
/**
* Storage
*/
type IStudentInfoStorageData = ILoginOutput & {
[P in keyof IStudentInfoData]: IStudentInfoData[P]["type"];
};
/** /**
* *
*/ */
@ -27,49 +61,94 @@ type IStudentInfoData = {
}; };
/** /**
* *
*
*/ */
idCardLast6: { loginStatus: {
type: string type: LoginStatus
}; }
/** /**
* 使 *
*
*/ */
eduService: { lastLoginTime: {
type: string type: number
}; }
/** /**
* *
*
*/ */
actualName: { isUserInfoChange: {
type: string
};
/**
*
*/
isSubscribeWxAccount: {
type: boolean type: boolean
}; }
/**
* session
*/
eduSession: {
type: string
};
} }
/** /**
* *
*/ */
class StudentInfo extends Data<IStudentInfoData> { class StudentInfo extends Data<IStudentInfoData & ILoginApiData> {
/**
*
*/
private eduStorage = new Storage<IStudentInfoStorageData>("StudentInfo", {
idCardLast6: "",
eduService: "",
actualName: "",
eduSession: "",
studentId: "",
password: "",
loginStatus: LoginStatus.none,
lastLoginTime: 0,
isUserInfoChange: false
});
public override onLoad() { public override onLoad() {
} }
/**
*
*/
private async login(): Promise<boolean> {
// 获取账号密码
const stuId = this.eduStorage.get("studentId");
const pwd = this.eduStorage.get("password");
if (!stuId || !pwd) return false;
// 发送请求
const data = await new Login().param({
studentId: stuId,
password: pwd
}).request().wait();
// 请求成功
let res = data.data;
if (res) {
// 保存数据
this.eduStorage.set("actualName", res.actualName);
this.eduStorage.set("eduService", res.eduService);
this.eduStorage.set("eduSession", res.eduSession);
this.eduStorage.set("idCardLast6", res.idCardLast6);
// 记录时间
this.eduStorage.set("lastLoginTime", new Date().getTime());
return true;
} else {
return false;
}
}
/**
*
*/
private async getStatus() {}
} }
export { StudentInfo };
export default StudentInfo;

View File

@ -1,5 +1,5 @@
import { IAnyData } from "core/Api"; import { IAnyData } from "../core/Api";
import { Emitter } from "core/Emitter"; import { Emitter } from "../core/Emitter";
import { Modular, Manager } from "../core/Module"; import { Modular, Manager } from "../core/Module";
/** /**

View File

@ -1,7 +1,8 @@
{ {
"description": "项目配置文件", "description": "项目配置文件详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"packOptions": { "packOptions": {
"ignore": [] "ignore": [],
"include": []
}, },
"miniprogramRoot": "miniprogram/", "miniprogramRoot": "miniprogram/",
"compileType": "miniprogram", "compileType": "miniprogram",
@ -46,13 +47,16 @@
"useCompilerPlugins": [ "useCompilerPlugins": [
"typescript", "typescript",
"sass" "sass"
] ],
"useStaticServer": true
}, },
"simulatorType": "wechat", "simulatorType": "wechat",
"simulatorPluginLibVersion": {}, "simulatorPluginLibVersion": {},
"appid": "wx7d809f5e8955843d", "appid": "wx7d809f5e8955843d",
"scripts": { "condition": {},
"beforeCompile": "" "srcMiniprogramRoot": "miniprogram/",
}, "editorSetting": {
"condition": {} "tabIndent": "insertSpaces",
"tabSize": 2
}
} }

View File

@ -1,14 +1,5 @@
{ {
"condition": { "condition": {
"plugin": {
"list": []
},
"game": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": { "miniprogram": {
"list": [ "list": [
{ {
@ -19,5 +10,10 @@
} }
] ]
} }
} },
"projectname": "mini-dlpu-v3",
"setting": {
"compileHotReLoad": true
},
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
} }