xyvcard-wechat-auth 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -0
- package/dist/api/auth/index.d.ts +21 -0
- package/dist/api/auth/index.js +1 -0
- package/dist/api/auth/types.d.ts +56 -0
- package/dist/api/auth/types.js +1 -0
- package/dist/api/dict/index.d.ts +18 -0
- package/dist/api/dict/index.js +1 -0
- package/dist/api/dict/types.d.ts +28 -0
- package/dist/api/dict/types.js +1 -0
- package/dist/api/dicts.d.ts +18 -0
- package/dist/api/dicts.js +1 -0
- package/dist/api/files/index.d.ts +25 -0
- package/dist/api/files/index.js +1 -0
- package/dist/api/files/types.d.ts +38 -0
- package/dist/api/files/types.js +1 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.js +1 -0
- package/dist/api/myorgan/index.d.ts +0 -0
- package/dist/api/myorgan/index.js +1 -0
- package/dist/api/myorgan/types.d.ts +22 -0
- package/dist/api/myorgan/types.js +1 -0
- package/dist/api/types.d.ts +26 -0
- package/dist/api/types.js +1 -0
- package/dist/app.d.ts +0 -0
- package/dist/app.js +1 -0
- package/dist/app.json +24 -0
- package/dist/app.wxss +0 -0
- package/dist/components/common/btn/footer-btn/index.d.ts +0 -0
- package/dist/components/common/btn/footer-btn/index.js +1 -0
- package/dist/components/common/btn/footer-btn/index.json +4 -0
- package/dist/components/common/btn/footer-btn/index.wxml +6 -0
- package/dist/components/common/btn/footer-btn/index.wxss +1 -0
- package/dist/components/common/btn/footer-double-btn/index.d.ts +0 -0
- package/dist/components/common/btn/footer-double-btn/index.js +1 -0
- package/dist/components/common/btn/footer-double-btn/index.json +4 -0
- package/dist/components/common/btn/footer-double-btn/index.wxml +2 -0
- package/dist/components/common/btn/footer-double-btn/index.wxss +0 -0
- package/dist/components/common/choose-avatar/index.d.ts +1 -0
- package/dist/components/common/choose-avatar/index.js +1 -0
- package/dist/components/common/choose-avatar/index.json +4 -0
- package/dist/components/common/choose-avatar/index.wxml +8 -0
- package/dist/components/common/choose-avatar/index.wxss +1 -0
- package/dist/components/common/none-data/index.d.ts +1 -0
- package/dist/components/common/none-data/index.js +1 -0
- package/dist/components/common/none-data/index.json +4 -0
- package/dist/components/common/none-data/index.wxml +4 -0
- package/dist/components/common/none-data/index.wxss +1 -0
- package/dist/components/common/popup/index.d.ts +1 -0
- package/dist/components/common/popup/index.js +1 -0
- package/dist/components/common/popup/index.json +4 -0
- package/dist/components/common/popup/index.wxml +8 -0
- package/dist/components/common/popup/index.wxss +1 -0
- package/dist/constant.d.ts +4 -0
- package/dist/constant.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -0
- package/dist/pages/index/index.d.ts +0 -0
- package/dist/pages/index/index.js +1 -0
- package/dist/pages/index/index.json +7 -0
- package/dist/pages/index/index.wxml +4 -0
- package/dist/pages/index/index.wxss +0 -0
- package/dist/sitemap.json +7 -0
- package/dist/styles/global.scss +22 -0
- package/dist/utils/auth.d.ts +19 -0
- package/dist/utils/auth.js +1 -0
- package/dist/utils/common.d.ts +26 -0
- package/dist/utils/common.js +1 -0
- package/dist/utils/config.d.ts +10 -0
- package/dist/utils/config.js +1 -0
- package/dist/utils/db.d.ts +41 -0
- package/dist/utils/db.js +1 -0
- package/dist/utils/request.d.ts +5 -0
- package/dist/utils/request.js +1 -0
- package/dist/utils/util.d.ts +1 -0
- package/dist/utils/util.js +1 -0
- package/package.json +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# XYVCARD-WECHAT-RBAC
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin http://192.168.1.63:8929/xyvcard/xyvcard-wechat-rbac.git
|
|
19
|
+
git branch -M master
|
|
20
|
+
git push -uf origin master
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
- [ ] [Set up project integrations](http://192.168.1.63:8929/xyvcard/xyvcard-wechat-rbac/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
+
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
40
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
|
|
53
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
|
+
|
|
55
|
+
## Name
|
|
56
|
+
Choose a self-explaining name for your project.
|
|
57
|
+
|
|
58
|
+
## Description
|
|
59
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
|
+
|
|
61
|
+
## Badges
|
|
62
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
|
+
|
|
64
|
+
## Visuals
|
|
65
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
|
+
|
|
73
|
+
## Support
|
|
74
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
|
+
|
|
76
|
+
## Roadmap
|
|
77
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
+
|
|
82
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
|
+
|
|
84
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
|
+
|
|
86
|
+
## Authors and acknowledgment
|
|
87
|
+
Show your appreciation to those who have contributed to the project.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
For open source projects, say how it is licensed.
|
|
91
|
+
|
|
92
|
+
## Project status
|
|
93
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ResponseData } from "../types";
|
|
2
|
+
import { LoginReq, LoginRes, PhoneNumberReq, RefreshTokenReq, TokenRes, RolesPerms, UserInfo, UpdateUserReq, UserInfoReq } from "./types";
|
|
3
|
+
declare class AuthApiImpl {
|
|
4
|
+
miniappLogin(data: LoginReq): Promise<ResponseData<LoginRes>>;
|
|
5
|
+
miniappPhoneNumber(data: PhoneNumberReq): Promise<ResponseData<LoginRes>>;
|
|
6
|
+
refreshToken(data: RefreshTokenReq): Promise<ResponseData<TokenRes>>;
|
|
7
|
+
logout(accessToken: string): Promise<ResponseData<any>>;
|
|
8
|
+
userInfo(): Promise<ResponseData<UserInfo>>;
|
|
9
|
+
userRolesPerms(): Promise<ResponseData<RolesPerms>>;
|
|
10
|
+
allowRunAsUser(): Promise<ResponseData<any>>;
|
|
11
|
+
runAsUser(userId: string): Promise<ResponseData<any>>;
|
|
12
|
+
updateUser(data: any): Promise<ResponseData<any>>;
|
|
13
|
+
updatePwd(encodeOldPwd: string, encodeNewPwd: string): Promise<ResponseData<any>>;
|
|
14
|
+
deptTree(deptId?: string): Promise<ResponseData<any>>;
|
|
15
|
+
jobTree(): Promise<ResponseData<any>>;
|
|
16
|
+
updateUserInfo(data: UpdateUserReq): Promise<ResponseData<UserInfo>>;
|
|
17
|
+
replaceBindphone(data: PhoneNumberReq): Promise<ResponseData<boolean>>;
|
|
18
|
+
findUserInfo(data: UserInfoReq): Promise<ResponseData<UserInfo>>;
|
|
19
|
+
}
|
|
20
|
+
declare const authApi: AuthApiImpl;
|
|
21
|
+
export { authApi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../utils/db.js"),t=require("../../utils/config.js"),n=require("../../utils/request.js");const r=new class a{miniappLogin(e){return n.sendRequest({url:"/v1/front/rbac/miniapp_login/"+t.config.tenant,method:"POST",data:e},{"content-type":"application/json"})}miniappPhoneNumber(e){return n.sendRequest({url:"/v1/front/rbac/miniapp_phonenumber/"+t.config.tenant,method:"POST",data:e},{"content-type":"application/json"})}refreshToken(e){e.tenant=t.config.tenant,e.clientId=t.config.appId;return n.sendRequest({url:"/v1/front/rbac/auth/refresh_token",method:"POST",data:e},{"content-type":"application/json"})}logout(e){return n.request({url:"/v1/rbac/auth/logout?tenant="+t.config.tenant+"&client_id="+t.config.appId+"&accessToken="+e,method:"DELETE"})}userInfo(){return n.request({url:"/v1/rbac/auth/user?tenant="+t.config.tenant,method:"GET"})}userRolesPerms(){return n.request({url:"/v1/rbac/auth/roles_perms?tenant="+t.config.tenant,method:"GET"})}allowRunAsUser(){return n.request({url:"/v1/rbac/auth/allow_run_as_user?tenant="+t.config.tenant,method:"GET"})}runAsUser(e){const r={tenant:t.config.tenant,userId:e};return n.request({url:"/v1/rbac/auth/run_as",method:"POST",data:r})}updateUser(e){return n.request({url:"/v1/rbac/auth/user",method:"PATCH",data:e})}updatePwd(t,r){const a={tenant:e.db.getUserTenant(),encodeOldPwd:t,encodeNewPwd:r};return n.request({url:"/v1/rbac/auth/change_pwd",method:"PATCH",data:a})}deptTree(t){const r={tenant:e.db.getUserTenant(),excludeId:t};return n.request({url:"/v1/rbac/dept/treelist",method:"GET",data:r})}jobTree(){const t={tenant:e.db.getUserTenant(),roleType:"job",hasRoleType:!0};return n.request({url:"/v1/rbac/role/treelist",method:"GET",data:t})}updateUserInfo(e){return e.tenant=t.config.tenant,n.clearEmpty(e),n.request({url:"/v1/rbac/auth/user",method:"PATCH",data:e})}replaceBindphone(e){return e.tenant=t.config.tenant,n.clearEmpty(e),n.request({url:"/v1/front/rbac/miniapp_bindphone",method:"POST",data:e})}findUserInfo(e){return e.tenant=t.config.tenant,n.request({url:"/v1/front/rbac/auth/user",method:"GET",data:e})}};exports.authApi=r,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface LoginReq {
|
|
2
|
+
appId: string;
|
|
3
|
+
loginCode: string;
|
|
4
|
+
componentAppid?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface LoginRes {
|
|
7
|
+
cacheKey?: string;
|
|
8
|
+
token?: TokenRes;
|
|
9
|
+
status?: boolean;
|
|
10
|
+
message?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RolesPerms {
|
|
13
|
+
roleCodes: string[];
|
|
14
|
+
permCodes: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface TokenRes {
|
|
17
|
+
accessToken?: string;
|
|
18
|
+
expiresIn?: number;
|
|
19
|
+
refreshToken?: string;
|
|
20
|
+
tokenType?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface UserInfo {
|
|
23
|
+
userId?: string;
|
|
24
|
+
loginName?: string;
|
|
25
|
+
nickName?: string;
|
|
26
|
+
realName?: string;
|
|
27
|
+
avatar?: string;
|
|
28
|
+
mobilePhone?: string;
|
|
29
|
+
mobilePhoneIns?: string;
|
|
30
|
+
storage: string;
|
|
31
|
+
unifiedId: string;
|
|
32
|
+
}
|
|
33
|
+
export interface PhoneNumberReq {
|
|
34
|
+
tenant?: string;
|
|
35
|
+
appId: string;
|
|
36
|
+
loginCode?: string;
|
|
37
|
+
phoneCode: string;
|
|
38
|
+
nickName?: string;
|
|
39
|
+
componentAppid?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface RefreshTokenReq {
|
|
42
|
+
tenant?: string;
|
|
43
|
+
refreshToken?: string;
|
|
44
|
+
clientId?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface UpdateUserReq {
|
|
47
|
+
tenant?: string;
|
|
48
|
+
requestId: string;
|
|
49
|
+
updateMask: string;
|
|
50
|
+
nickName?: string;
|
|
51
|
+
avatar?: string;
|
|
52
|
+
realName?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface UserInfoReq {
|
|
55
|
+
tenant?: string;
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ResponseData } from "../types";
|
|
2
|
+
import { EnumRes, DictEntryReq, DictEntryList } from "./types";
|
|
3
|
+
declare class DictApiImpl {
|
|
4
|
+
/**
|
|
5
|
+
* 枚举
|
|
6
|
+
* @param data 查询条件
|
|
7
|
+
* @returns 返回Promise<Entry[]>的对象
|
|
8
|
+
*/
|
|
9
|
+
enumApi(module: string, className: string, type?: number): Promise<ResponseData<EnumRes>>;
|
|
10
|
+
/**
|
|
11
|
+
* 普通字典
|
|
12
|
+
* @param data 查询条件
|
|
13
|
+
* @returns 返回Promise<Entry[]>的对象
|
|
14
|
+
*/
|
|
15
|
+
dictEntryApi(data: DictEntryReq): Promise<ResponseData<DictEntryList>>;
|
|
16
|
+
}
|
|
17
|
+
declare const dictApi: DictApiImpl;
|
|
18
|
+
export { dictApi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../utils/config.js"),t=require("../../utils/request.js");const r=new class o{enumApi(e,r,o){const s={className:r,type:o};return t.request({url:"/v1/"+e+"/enum/entry",method:"GET",data:s})}dictEntryApi(r){return r&&(r.hasEnable=null!=r.enable),t.request({url:"/v1/dict/dict_entry/list/"+e.config.tenant,method:"GET",data:r})}};exports.dictApi=r,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface Entry {
|
|
2
|
+
key?: string;
|
|
3
|
+
value?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface EnumEntryReq {
|
|
6
|
+
className?: string;
|
|
7
|
+
type?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface EnumRes {
|
|
10
|
+
values: Array<Entry>;
|
|
11
|
+
}
|
|
12
|
+
export interface DictEntryModel {
|
|
13
|
+
typeCode?: string;
|
|
14
|
+
dictCode?: string;
|
|
15
|
+
dictName?: string;
|
|
16
|
+
listOrder?: number;
|
|
17
|
+
enable?: boolean;
|
|
18
|
+
description?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface DictEntryList {
|
|
21
|
+
results: Array<DictEntryModel>;
|
|
22
|
+
}
|
|
23
|
+
export interface DictEntryReq {
|
|
24
|
+
typeCode?: string;
|
|
25
|
+
dictCode?: string;
|
|
26
|
+
hasEnable?: boolean;
|
|
27
|
+
enable?: boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Entry, DictEntryModel } from "./dict/types";
|
|
2
|
+
export declare class EnumDict {
|
|
3
|
+
module: string;
|
|
4
|
+
enumClass: string;
|
|
5
|
+
type: number;
|
|
6
|
+
values: Entry[];
|
|
7
|
+
constructor(module: string, enumClass: string, type?: number);
|
|
8
|
+
useEnumValues(): Promise<Entry[]>;
|
|
9
|
+
getEnumValue(key: string): string;
|
|
10
|
+
}
|
|
11
|
+
export declare class EntryDict {
|
|
12
|
+
typeCode: string;
|
|
13
|
+
enable?: boolean;
|
|
14
|
+
values: DictEntryModel[];
|
|
15
|
+
constructor(typeCode: string, enable?: boolean);
|
|
16
|
+
useDictValues(): Promise<DictEntryModel[]>;
|
|
17
|
+
getDictValue(key: string): string;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./dict/index.js");exports.EntryDict=class t{constructor(e,t=!0){this.values=[],this.typeCode=e,this.enable=t}useDictValues(){return new Promise(t=>{const s={typeCode:this.typeCode,enable:this.enable};e.dictApi.dictEntryApi(s).then(({data:e})=>{this.values.length=0,this.values.push(...e.results),t(this.values)})})}getDictValue(e){const t=this.values.find(t=>t.dictCode===e);return(null==t?void 0:t.dictName)?t.dictName:""}},exports.EnumDict=class s{constructor(e,t,s=0){this.values=[],this.module=e,this.enumClass=t,this.type=s}useEnumValues(){return new Promise(t=>{e.dictApi.enumApi(this.module,this.enumClass,this.type).then(({data:e})=>{this.values.length=0,this.values.push(...e.values),t(this.values)})})}getEnumValue(e){for(const t of this.values)if(t.key==e)return t.value;return""}},"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ResponseData } from "../types";
|
|
2
|
+
import { FileInfo, FileBase64Req, FileDownInfo, FileWebReq } from "./types";
|
|
3
|
+
declare class FileApi {
|
|
4
|
+
baseApiUrl(): string;
|
|
5
|
+
uploadUrl(): string;
|
|
6
|
+
/**
|
|
7
|
+
* url 获取图片Full路径
|
|
8
|
+
* @param type resize 等比例缩放,white 补白,trans 补透明,clip 裁剪
|
|
9
|
+
*/
|
|
10
|
+
imageUrl(imageUrl: string, width?: number, height?: number, type?: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Id 获取图片Full路径
|
|
13
|
+
* @param type resize 等比例缩放,white 补白,trans 补透明,clip 裁剪
|
|
14
|
+
*/
|
|
15
|
+
imageIdUrl(imageId: string, width?: number, height?: number, type?: string): string;
|
|
16
|
+
fileUrl(fileUrl?: string): string;
|
|
17
|
+
fileIdUrl(fileId?: string): string;
|
|
18
|
+
uploadBase64File(base64: FileBase64Req): Promise<ResponseData<FileInfo>>;
|
|
19
|
+
uploadFile(file: string): Promise<ResponseData<FileInfo>>;
|
|
20
|
+
downloadFile(url: string): Promise<FileDownInfo>;
|
|
21
|
+
uploadWebFile(data: FileWebReq): Promise<ResponseData<FileInfo>>;
|
|
22
|
+
deleteFile(filePath?: string): Promise<ResponseData<any>>;
|
|
23
|
+
}
|
|
24
|
+
declare const fileApi: FileApi;
|
|
25
|
+
export { fileApi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../utils/config.js"),t=require("../../utils/request.js"),r=require("../../utils/db.js");const a=new class i{baseApiUrl(){let t=e.config.baseUrl;return"/"===t.slice(-1)&&(t=t.slice(0,-1)),t}uploadUrl(){return this.baseApiUrl()+"/v1/file/upload?tenant="+e.config.tenant}imageUrl(e,t=0,r=0,a="clip"){return/^\//.test(e)?this.baseApiUrl()+`/v1/file/image/${a}/${t}/${r}`+e:this.baseApiUrl()+`/v1/file/image/${a}/${t}/${r}/`+e}imageIdUrl(t,r=0,a=0,i="clip"){return this.baseApiUrl()+"/v1/file/image_id/"+e.config.tenant+`/${i}/${r}/${a}/`+t}fileUrl(e){return this.baseApiUrl()+"/v1/file/path/"+e}fileIdUrl(t){return this.baseApiUrl()+"/v1/file/id/"+e.config.tenant+t}uploadBase64File(r){return r.tenant=e.config.tenant,t.clearEmpty(r),t.request({url:"/v1/file/base64upload",method:"POST",data:r})}uploadFile(e){let t=this;return new Promise((a,i)=>{wx.uploadFile({url:t.uploadUrl(),filePath:e,name:"file",header:{"Content-Type":"multipart/form-data",Authorization:r.db.getBearerToken()},success(e){200===e.statusCode?a({code:e.statusCode,message:e.errMsg,data:JSON.parse(e.data)}):401===e.statusCode?wx.clearStorage():(wx.showToast({title:e.errMsg,icon:"none",duration:2e3}),a({code:e.statusCode,message:e.errMsg,data:JSON.parse(e.data)}))},fail(e){i(e)}})})}downloadFile(e){return new Promise((t,a)=>{wx.downloadFile({url:e,header:{Authorization:r.db.getBearerToken()},success(e){t({statusCode:e.statusCode,tempFilePath:e.tempFilePath,filePath:e.tempFilePath})},fail(e){a(e)}})})}uploadWebFile(e){return t.clearEmpty(e),t.request({url:"/v1/file/webupload",method:"POST",data:e})}deleteFile(e){return t.request({url:"/api/v1/files",method:"DELETE",data:{filePath:e}})}};exports.fileApi=a,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件API类型声明
|
|
3
|
+
*/
|
|
4
|
+
export interface FileInfo {
|
|
5
|
+
fileId: string;
|
|
6
|
+
fileSrc: string;
|
|
7
|
+
contentType: string;
|
|
8
|
+
fileExt: string;
|
|
9
|
+
fileWidth: number;
|
|
10
|
+
fileHeight: number;
|
|
11
|
+
fileSize: number;
|
|
12
|
+
hashSha256: string;
|
|
13
|
+
hashSm3: string;
|
|
14
|
+
createDate: string;
|
|
15
|
+
tempFilePath: string;
|
|
16
|
+
}
|
|
17
|
+
export interface FileBase64Req {
|
|
18
|
+
tenant?: string;
|
|
19
|
+
base64?: string;
|
|
20
|
+
fileName?: string;
|
|
21
|
+
contentType?: string;
|
|
22
|
+
fileDir?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface FileDownInfo {
|
|
25
|
+
tempFilePath: string;
|
|
26
|
+
filePath: string;
|
|
27
|
+
statusCode: number;
|
|
28
|
+
}
|
|
29
|
+
export interface FileWebReq {
|
|
30
|
+
tenant?: string;
|
|
31
|
+
body?: string;
|
|
32
|
+
fileName?: string;
|
|
33
|
+
contentType?: string;
|
|
34
|
+
fileDir?: string;
|
|
35
|
+
fileSize?: number;
|
|
36
|
+
requestId?: string;
|
|
37
|
+
filePart?: number;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./dicts.js"),t=require("../constant"),o=class e{};o.genderDict=new e.EnumDict(t.MODULE_RBAC,t.ENUM_GENDER);let r=o;exports.Dict=r,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface BaseOrganModel {
|
|
2
|
+
organId?: string;
|
|
3
|
+
organName?: string;
|
|
4
|
+
organCode?: string;
|
|
5
|
+
pinYin?: string;
|
|
6
|
+
userId?: string;
|
|
7
|
+
shortName?: string;
|
|
8
|
+
organType?: string;
|
|
9
|
+
parentId?: string;
|
|
10
|
+
logoUrl?: string;
|
|
11
|
+
industry?: string;
|
|
12
|
+
address?: string;
|
|
13
|
+
geoLongitude?: string;
|
|
14
|
+
geoLatitude?: string;
|
|
15
|
+
contactPerson?: string;
|
|
16
|
+
contactPersonMobile?: string;
|
|
17
|
+
contactPersonMobileIns?: string;
|
|
18
|
+
perfectStatus?: boolean;
|
|
19
|
+
status?: string;
|
|
20
|
+
tenant: string;
|
|
21
|
+
memberInviteStatus: boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface ResponseData<T> {
|
|
2
|
+
code: number;
|
|
3
|
+
message: string;
|
|
4
|
+
data: T;
|
|
5
|
+
}
|
|
6
|
+
export interface RequestData<T> {
|
|
7
|
+
url?: string;
|
|
8
|
+
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
9
|
+
data?: T;
|
|
10
|
+
responseType?: "text" | "arraybuffer" | "blob";
|
|
11
|
+
}
|
|
12
|
+
export interface RequestHeader {
|
|
13
|
+
"content-type"?: string;
|
|
14
|
+
Authorization?: string;
|
|
15
|
+
"Grpc-Metadata-Tenant"?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare enum TenantType {
|
|
18
|
+
System = 0,
|
|
19
|
+
User = 1,
|
|
20
|
+
Organ = 2
|
|
21
|
+
}
|
|
22
|
+
export interface SearchHistoricalModel {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
time: Date;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(e=>(e[e.System=0]="System",e[e.User=1]="User",e[e.Organ=2]="Organ",e))(e||{});exports.TenantType=e,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
package/dist/app.d.ts
ADDED
|
File without changes
|
package/dist/app.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";App({globalData:{},onLaunch(){(wx.getStorageSync("logs")||[]).unshift(Date.now()),wx.login({success:e=>{}})}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
package/dist/app.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pages": [
|
|
3
|
+
"pages/index/index"
|
|
4
|
+
],
|
|
5
|
+
"window": {
|
|
6
|
+
"navigationBarTextStyle": "black",
|
|
7
|
+
"navigationBarTitleText": "",
|
|
8
|
+
"navigationBarBackgroundColor": "#fff"
|
|
9
|
+
},
|
|
10
|
+
"style": "v2",
|
|
11
|
+
"rendererOptions": {
|
|
12
|
+
"skyline": {
|
|
13
|
+
"defaultDisplayBlock": true,
|
|
14
|
+
"defaultContentBox": true,
|
|
15
|
+
"tagNameStyleIsolation": "legacy",
|
|
16
|
+
"disableABTest": true,
|
|
17
|
+
"sdkVersionBegin": "3.0.0",
|
|
18
|
+
"sdkVersionEnd": "15.255.255"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"componentFramework": "glass-easel",
|
|
22
|
+
"sitemapLocation": "sitemap.json",
|
|
23
|
+
"lazyCodeLoading": "requiredComponents"
|
|
24
|
+
}
|
package/dist/app.wxss
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Component({properties:{text:{type:String,value:""},btnBgColor:{type:String,value:""},fontColor:{type:String,value:""},disabled:{type:Boolean,value:!1}},data:{},methods:{onClick(){this.triggerEvent("click",null,{})}}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.btn{font-size:16px;width:100% !important}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Component({properties:{},data:{},methods:{}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("../../../utils/config.js"),t=require("../../../utils/auth.js"),a=require("../../../api/files/index.js");Component({properties:{value:{type:String,value:"",observer(){this.setData({avatar:this.properties.value?a.fileApi.imageUrl(this.properties.value,320,320,"trans"):this.data.avatar})}},logoImg:{type:String,value:"",observer(){this.setData({avatar:this.properties.logoImg?this.properties.logoImg:this.data.avatar})}},logo:{type:Boolean,value:!1,observer(){this.setData({avatar:this.properties.logo?this.data.defaultlogo:this.data.avatar})}},pathType:{type:Boolean,value:!1}},data:{resourceUrl:e.config.resourceUrl+"/images",avatar:e.config.resourceUrl+"/images/components/gray_head2x.png",defaultlogo:e.config.resourceUrl+"/images/components/gray_logo.png"},lifetimes:{attached(){""!=this.properties.value&&(this.data.avatar=this.properties.pathType?this.properties.value:a.fileApi.imageUrl(this.properties.value,320,320,"trans"),this.setData({avatar:this.data.avatar}))}},methods:{onChooseAvatar(e){const{avatarUrl:r}=e.detail;t.auth.checkLogin()?a.fileApi.uploadFile(r).then(e=>{this.triggerEvent("change",e,{}),this.setData({avatar:a.fileApi.imageUrl(e.data.fileSrc,320,320,"trans")})}):wx.showToast({title:"请先获取手机号!",duration:2e3})}}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<!-- 创建卡片选择头像 样式组件 -->
|
|
2
|
+
<!-- 头像背景盒子 -->
|
|
3
|
+
<button plain class="image-box-bgc" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
|
|
4
|
+
<!-- 显示的头像 -->
|
|
5
|
+
<image class="image-box-show" src="{{ avatar }}" mode="widthFix" />
|
|
6
|
+
<!-- 提示选择头像图片 -->
|
|
7
|
+
<image class="select-image" src="{{ resourceUrl + '/icon_image/camera2x.png' }}" mode="" />
|
|
8
|
+
</button>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.image-box-bgc{position:relative;display:flex;align-items:center;justify-content:center;width:80px !important;height:80px;border:none !important;border-radius:10px;padding:0}.image-box-bgc .image-box-show{width:80px;height:80px}.image-box-bgc .select-image{position:absolute;width:24px;height:24px;bottom:0;right:0}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("../../../utils/config.js");Component({properties:{marginTop:{type:Number,value:300},paddingTop:{type:Number,value:0},content:{type:String,value:"暂无数据"}},data:{resourceUrl:e.config.resourceUrl+"/images"},methods:{}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.none-data{display:flex;align-items:center;justify-content:center;flex-direction:column}.none-data .holder-image{width:auto;height:250rpx}.none-data .holder-text{font-size:30rpx;color:#b6b6b6;position:relative;top:-30rpx}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("../../../utils/config.js");Component({properties:{show:{type:Boolean,value:!1},title:{type:String,value:""},titleShow:{type:Boolean,value:!1},height:{type:String,value:"300px"}},data:{resourceUrl:e.config.resourceUrl+"/images",closeModel:!1,titleShow:!0},methods:{closePopup(){this.triggerEvent("close",null,{})}}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<view class="mask-box" wx:if="{{ show }}"></view>
|
|
2
|
+
<view class="mask-popup" wx:if="{{ show }}" style="height: {{ height }}">
|
|
3
|
+
<view class="popup-title" titleShow="{{ titleShow }}">
|
|
4
|
+
{{ title }}
|
|
5
|
+
<image mode="widthFix" src="{{ resourceUrl + '/icon_image/close_circle2x.png' }}" class="close-icon" bind:tap="closePopup"></image>
|
|
6
|
+
</view>
|
|
7
|
+
<slot></slot>
|
|
8
|
+
</view>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.mask-box{position:fixed;left:0;top:0;bottom:0;right:0;width:100%;background-color:rgba(0,0,0,.5);z-index:99999}.mask-popup{position:fixed;bottom:0;left:0;background-color:#fff;border-top-left-radius:25px;border-top-right-radius:25px;padding:10px 4% 30px 4%;width:92%;z-index:99999}.mask-popup .popup-title{color:#333;font-size:15px;padding:10px 0;font-weight:bold;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #ebebeb}.mask-popup .popup-title .close-icon{width:20px}
|
package/dist/constant.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=class e{};e.MODULE_RBAC="rbac",e.ENUM_GENDER="jmash.protobuf.Gender";let o=e;module.exports=o,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./utils/auth.js"),t=require("./utils/db.js"),i=require("./api/dict/index.js"),r=require("./api/files/index.js"),s=require("./api/index.js"),o=require("./api/dicts.js");exports.auth=e.auth,exports.db=t.db,exports.dictApi=i.dictApi,exports.fileApi=r.fileApi,exports.Dict=s.Dict,exports.EntryDict=o.EntryDict,exports.EnumDict=o.EnumDict,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Page({data:{},onLoad(){},onReady(){},onShow(){},onHide(){},onUnload(){},onPullDownRefresh(){},onReachBottom(){},onShareAppMessage(){}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(o){exports[o]=module.exports[o]});
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// 圆角
|
|
2
|
+
$border-radius: 10px;
|
|
3
|
+
$border-mini-radius: 5px;
|
|
4
|
+
$border-max-radius: 25px;
|
|
5
|
+
// 字体大小
|
|
6
|
+
$font-size: 14px;
|
|
7
|
+
$font-size-mini: 12px;
|
|
8
|
+
// 颜色
|
|
9
|
+
$white-color: #fff;
|
|
10
|
+
$red-color: #EF4444;
|
|
11
|
+
$green-color: #16A34A;
|
|
12
|
+
$blue-color: #2563EB;
|
|
13
|
+
// 字体颜色
|
|
14
|
+
$font-color: #333;
|
|
15
|
+
$font-color-grey: #666;
|
|
16
|
+
$font-color-grey-opacity: #999;
|
|
17
|
+
// 宽
|
|
18
|
+
$width: 100%;
|
|
19
|
+
// 层级
|
|
20
|
+
$z-index: 99999;
|
|
21
|
+
// 下拉线颜色
|
|
22
|
+
$border-line: #EBEBEB;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LoginRes, RolesPerms, UserInfo } from "../api/auth/types";
|
|
2
|
+
declare class Auth {
|
|
3
|
+
/** 登录检查并跳转登录 */
|
|
4
|
+
loginAC(backurl: string, tabbar: boolean): void;
|
|
5
|
+
/** 检查登录是否有效? */
|
|
6
|
+
checkLogin(): boolean;
|
|
7
|
+
_checkLogin(): Promise<unknown>;
|
|
8
|
+
hasUser(): Promise<boolean>;
|
|
9
|
+
checkRole(role: string): boolean;
|
|
10
|
+
/** 静默登录 */
|
|
11
|
+
silentLogin(): Promise<LoginRes>;
|
|
12
|
+
phoneCodeLogin(phoneCode: string, nickName?: string): Promise<LoginRes>;
|
|
13
|
+
getRolePerm(cache?: boolean): Promise<RolesPerms>;
|
|
14
|
+
getUserInfo(cache?: boolean): Promise<UserInfo>;
|
|
15
|
+
refreshToken(): Promise<boolean>;
|
|
16
|
+
loginOut(): void;
|
|
17
|
+
}
|
|
18
|
+
declare const auth: Auth;
|
|
19
|
+
export { auth };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./config.js"),t=require("./db.js"),o=require("../api/auth/index.js");const n=new class r{loginAC(e,t){this.checkLogin()||this.silentLogin().then(t=>{if(!t.status){let t="/pages/login/index?";t+="true",t+="&backurl="+e,wx.navigateTo({url:t})}})}checkLogin(){return!(!t.db.getToken()||t.db.isTokenExpire())}_checkLogin(){return new Promise(e=>{const o=t.db.getToken(),n=t.db.isTokenExpire();e(!(!o||n))})}hasUser(){return e=this,t=null,o=function*(){return(yield n.checkLogin())?Promise.resolve(!0):n.silentLogin().then(e=>!!e.status).catch(e=>!1)},new Promise((n,r)=>{var s=e=>{try{a(o.next(e))}catch(t){r(t)}},i=e=>{try{a(o.throw(e))}catch(t){r(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((o=o.apply(e,t)).next())});var e,t,o}checkRole(e){const o=t.db.getRoleCodes();return o.length>0&&-1!==o.indexOf(e)}silentLogin(){return new Promise((n,r)=>{try{wx.login({success:s=>{s.code&&o.authApi.miniappLogin({loginCode:s.code,appId:e.config.appId,componentAppid:e.config.componentAppid}).then(e=>{200===e.code&&!0===e.data.status?(t.db.loginStorage(e.data),this.getUserInfo(!1),this.getRolePerm(!1).then(()=>{n(e.data)})):200===e.code?n(e.data):r(e.message)})},fail:e=>{r(e.errMsg)}})}catch(s){}})}phoneCodeLogin(n,r=""){return new Promise((s,i)=>{wx.login({success:a=>{a.code&&o.authApi.miniappPhoneNumber({phoneCode:n,loginCode:a.code,appId:e.config.appId,nickName:r,componentAppid:e.config.componentAppid}).then(e=>{200===e.code&&!0===e.data.status?(t.db.loginStorage(e.data),this.getRolePerm().then(()=>{s(e.data)})):i(e.message)})},fail:e=>{i(e.errMsg)}})})}getRolePerm(e=!0){return new Promise((n,r)=>{let s={roleCodes:t.db.getRoleCodes(),permCodes:t.db.getPermCodes()};e&&(Object.keys(s.roleCodes).length>0||Object.keys(s.permCodes).length>0)?n(s):o.authApi.userRolesPerms().then(e=>{t.db.rolesPermsStorage(e.data),n(e.data)}).catch(()=>{r("获取角色权限错误!")})})}getUserInfo(e=!0){return new Promise((n,r)=>{let s=t.db.getUserInfo();e&&Object.keys(s).length>0?n(s):o.authApi.userInfo().then(e=>{t.db.userInfoStorage(e.data),n(e.data)}).catch(()=>{r("获取角色权限错误!")})})}refreshToken(){return new Promise((n,r)=>{o.authApi.refreshToken({tenant:e.config.tenant,refreshToken:t.db.getRefreshToken(),clientId:e.config.appId}).then(e=>{t.db.tokenStorage(e.data),n(!0)}).catch(e=>{r(e)})})}loginOut(){t.db.clearStorage()}};exports.auth=n,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 正则校验规则
|
|
3
|
+
* @param {string} value 需要校验的值
|
|
4
|
+
* @param {string} message 错误提示信息
|
|
5
|
+
* @param {string} rules 正则校验规则
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateRules(value: string, message: string, rules: any): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* 校验必填项
|
|
10
|
+
* @param {string} value 需要校验的值
|
|
11
|
+
* @param {string} message 错误提示信息
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateRequired(value: string, message: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 格式化日期时间字符串
|
|
16
|
+
* @param dateTimeString 日期时间字符串
|
|
17
|
+
* @returns 格式化后的日期时间字符串
|
|
18
|
+
*/
|
|
19
|
+
export declare const formatDateTime: (dateTimeString: string, format?: any) => string;
|
|
20
|
+
export declare function kbToMb(kb: number, decimalPlaces?: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* 将日期字符串转换为标准 ISO 8601 格式字符串
|
|
23
|
+
* @param dateString - 可被 Date 构造函数解析的日期字符串
|
|
24
|
+
* @returns 返回 ISO 格式字符串 (如 "2023-01-01T00:00:00.000Z")
|
|
25
|
+
*/
|
|
26
|
+
export declare function convertToISOString(dateString: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});exports.convertToISOString=function(e){return new Date(e).toISOString()},exports.formatDateTime=(e,t)=>{var o=new Date(e);if(isNaN(o.getTime()))return"";var r=o.getFullYear(),n=("0"+(o.getMonth()+1)).slice(-2),i=("0"+o.getDate()).slice(-2),s=("0"+o.getHours()).slice(-2),u=("0"+o.getMinutes()).slice(-2),a=("0"+o.getSeconds()).slice(-2);return"YYYY-MM-DD HH:mm:ss"===t?r+"-"+n+"-"+i+" "+s+":"+u+":"+a:"YYYY-MM-DD HH:mm"===t?r+"-"+n+"-"+i+" "+s+":"+u:"YYYY-MM-DD"===t?r+"-"+n+"-"+i:""},exports.kbToMb=function(e,t=2){return parseFloat((e/1024/1024).toFixed(t))},exports.validateRequired=function(e,t){return!(!e||""==e.trim())||(wx.showToast({title:t,icon:"none",duration:2e3}),!1)},exports.validateRules=function(e,t,o){return!(e&&!o.test(e))||(wx.showToast({title:t,icon:"none",duration:2e3}),!1)},"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="https://",o="gh.sooyie.cn",t={baseUrl:e+o,resourceUrl:e+o+"/v1/file/path/wxapp",appId:wx.getAccountInfoSync().miniProgram.appId,tenant:"xyvcard",componentAppid:"wxe1b784ea80c01f40",siteId:"552416fb-5dc8-46b8-8a35-bc26b1a09be1"};exports.config=t,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BaseOrganModel } from "../api/myorgan/types";
|
|
2
|
+
import { LoginRes, TokenRes, RolesPerms, UserInfo } from "../api/auth/types";
|
|
3
|
+
import { SearchHistoricalModel } from "../api/types";
|
|
4
|
+
declare class LocalStorage {
|
|
5
|
+
getTenant(): string;
|
|
6
|
+
getUserTenant(): string;
|
|
7
|
+
getOrganTenant(): string;
|
|
8
|
+
getToken(): string;
|
|
9
|
+
getRefreshToken(): string;
|
|
10
|
+
getRoleCodes(): Array<string>;
|
|
11
|
+
getPermCodes(): Array<string>;
|
|
12
|
+
getUserInfo(): UserInfo;
|
|
13
|
+
getBearerToken(): string;
|
|
14
|
+
isTokenExpire(): boolean;
|
|
15
|
+
loginStorage(loginResp: LoginRes): void;
|
|
16
|
+
tokenStorage(tokenRes: TokenRes): void;
|
|
17
|
+
rolesPermsStorage(rolesPerms: RolesPerms): void;
|
|
18
|
+
userInfoStorage(userInfo: UserInfo): void;
|
|
19
|
+
clearStorage(): void;
|
|
20
|
+
setSearchStorage(info: SearchHistoricalModel): void;
|
|
21
|
+
setSearchStorageAll(infoArr: SearchHistoricalModel[]): void;
|
|
22
|
+
getSearchStorage(): SearchHistoricalModel[];
|
|
23
|
+
clearSearchStorage(): void;
|
|
24
|
+
setDefaultOrgan(organ: BaseOrganModel): void;
|
|
25
|
+
getDefaultOrgan(): BaseOrganModel;
|
|
26
|
+
clearDefaultOrgan(): void;
|
|
27
|
+
clearDefaultCmsinfo(): void;
|
|
28
|
+
getNetworkStatus(): any;
|
|
29
|
+
setNetWorkStatus(status: boolean): void;
|
|
30
|
+
clearNetWorkStatus(): void;
|
|
31
|
+
getDespTopStatus(): any;
|
|
32
|
+
setDespTopStatus(status: boolean): void;
|
|
33
|
+
getBeforeExchangeStatus(): any;
|
|
34
|
+
setBeforeExchangeStatus(status: boolean): void;
|
|
35
|
+
clearBeforeExchangeStatus(): void;
|
|
36
|
+
getAddrNotesStorage(): any;
|
|
37
|
+
setAddrNotesStorage(notes: string): void;
|
|
38
|
+
clearAddrNotesStorage(): void;
|
|
39
|
+
}
|
|
40
|
+
declare const db: LocalStorage;
|
|
41
|
+
export { db };
|
package/dist/utils/db.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./config.js");const t=new class r{getTenant(){return e.config.tenant}getUserTenant(){return this.getUserInfo().storage}getOrganTenant(){return this.getDefaultOrgan().tenant}getToken(){return wx.getStorageSync("token")}getRefreshToken(){return wx.getStorageSync("refreshToken")}getRoleCodes(){return wx.getStorageSync("roleCodes")}getPermCodes(){return wx.getStorageSync("permCodes")}getUserInfo(){return wx.getStorageSync("userInfo")}getBearerToken(){return wx.getStorageSync("token")?"Bearer "+wx.getStorageSync("token"):""}isTokenExpire(){if(wx.getStorageSync("token")){const e=wx.getStorageSync("expireTime");return e&&(new Date).getTime()>e}return!1}loginStorage(e){e.token&&this.tokenStorage(e.token),wx.setStorageSync("mobilePhone",e.message)}tokenStorage(e){if(wx.setStorageSync("token",e.accessToken),wx.setStorageSync("expiresIn",e.expiresIn),wx.setStorageSync("refreshToken",e.refreshToken),e.expiresIn){const t=(new Date).getTime()+1e3*e.expiresIn-6e4;wx.setStorageSync("expireTime",t)}}rolesPermsStorage(e){wx.setStorageSync("roleCodes",e.roleCodes),wx.setStorageSync("permCodes",e.permCodes)}userInfoStorage(e){wx.setStorageSync("userInfo",e)}clearStorage(){wx.clearStorage()}setSearchStorage(e){const t=wx.getStorageSync("historical")?wx.getStorageSync("historical"):JSON.stringify([]);let r=JSON.parse(t);r.push(e),wx.setStorageSync("historical",JSON.stringify(r))}setSearchStorageAll(e){wx.setStorageSync("historical",JSON.stringify(e))}getSearchStorage(){return wx.getStorageSync("historical")?JSON.parse(wx.getStorageSync("historical")):[]}clearSearchStorage(){wx.setStorageSync("historical",JSON.stringify([]))}setDefaultOrgan(e){wx.setStorageSync("defaultOrgan",e)}getDefaultOrgan(){return wx.getStorageSync("defaultOrgan")||{}}clearDefaultOrgan(){wx.setStorageSync("defaultOrgan",{})}clearDefaultCmsinfo(){wx.setStorageSync("defaultCms",{})}getNetworkStatus(){return!!wx.getStorageSync("netWork")&&wx.getStorageSync("netWork")}setNetWorkStatus(e){wx.setStorageSync("netWork",e)}clearNetWorkStatus(){wx.setStorageSync("netWork","")}getDespTopStatus(){return!!wx.getStorageSync("desktop")&&wx.getStorageSync("desktop")}setDespTopStatus(e){wx.setStorageSync("desktop",e)}getBeforeExchangeStatus(){return wx.getStorageSync("exchange")}setBeforeExchangeStatus(e){wx.setStorageSync("exchange",e)}clearBeforeExchangeStatus(){wx.setStorageSync("exchange",!1)}getAddrNotesStorage(){return wx.getStorageSync("notes")}setAddrNotesStorage(e){wx.setStorageSync("notes",e)}clearAddrNotesStorage(){wx.setStorageSync("notes","")}};exports.db=t,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RequestData, ResponseData, RequestHeader } from "../api/types";
|
|
2
|
+
declare const request: (options?: RequestData<any>, tenant?: string) => Promise<ResponseData<any>>;
|
|
3
|
+
declare const sendRequest: (options: RequestData<any>, header: RequestHeader) => Promise<ResponseData<any>>;
|
|
4
|
+
declare function clearEmpty(params: any): any;
|
|
5
|
+
export { request, sendRequest, clearEmpty };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./config.js"),t=require("./db.js"),r=require("./auth.js");let o=!1,s=null;const a=(t,r)=>new Promise((o,s)=>{var a;wx.request({url:e.config.baseUrl+t.url,method:t.method,data:t.data,header:r,responseType:null!=(a=t.responseType)?a:"text",success(e){200===e.statusCode?o({code:e.statusCode,message:e.errMsg,data:e.data}):401===e.statusCode?wx.clearStorage():o({code:e.statusCode,message:e.errMsg,data:e.data})},fail(e){s(e)}})});exports.clearEmpty=function e(t){for(const r in t)"object"==typeof t[r]&&e(t[r]),"object"==typeof t[r]&&0===Object.keys(t[r]).length&&delete t[r],""===t[r]&&delete t[r];return t},exports.request=(...e)=>{return n=null,c=[...e],u=function*(e={},n=""){t.db.isTokenExpire()&&(o?yield s:(o=!0,s||(s=new Promise((e,t)=>{r.auth.refreshToken().then(()=>e(!0)).catch(e=>{wx.clearStorage(),t(e)})})),yield s,o=!1));try{let r={"content-type":"application/json",Authorization:t.db.getBearerToken(),"Grpc-Metadata-Tenant":n};return yield a(e,r)}catch(c){return Promise.reject(c)}},new Promise((e,t)=>{var r=e=>{try{s(u.next(e))}catch(r){t(r)}},o=e=>{try{s(u.throw(e))}catch(r){t(r)}},s=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,o);s((u=u.apply(n,c)).next())});var n,c,u},exports.sendRequest=a,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatTime: (date: Date) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=e=>{const t=e.toString();return t[1]?t:"0"+t};exports.formatTime=t=>{const o=t.getFullYear(),r=t.getMonth()+1,n=t.getDate(),s=t.getHours(),u=t.getMinutes(),p=t.getSeconds();return[o,r,n].map(e).join("/")+" "+[s,u,p].map(e).join(":")},"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xyvcard-wechat-auth",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"miniprogram": "dist",
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"miniprogram-api-typings": "^4.0.7"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"xyvcard-mini-wechat": "^0.0.3",
|
|
16
|
+
"typescript": "^5.8.3"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "build"
|
|
20
|
+
}
|
|
21
|
+
}
|