@kevisual/kv-login 0.0.7 → 0.0.8
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/dist/app.js +27 -2
- package/package.json +1 -1
- package/src/pages/kv-login.ts +27 -3
package/dist/app.js
CHANGED
|
@@ -5047,15 +5047,23 @@ var DefaultLoginMethods = [
|
|
|
5047
5047
|
{ id: "wechat-mp-ticket", name: "微信公众号", icon: "wxOpenSvg" },
|
|
5048
5048
|
{ id: "phone", name: "手机号登录", icon: "phone" }
|
|
5049
5049
|
];
|
|
5050
|
+
var LoginMethods = ["password", "phone", "wechat", "wechat-mp", "wechat-mp-ticket"];
|
|
5050
5051
|
var getLoginMethodByDomain = () => {
|
|
5051
|
-
|
|
5052
|
+
let domain = window.location.host;
|
|
5052
5053
|
let methods = [];
|
|
5054
|
+
const has51015 = domain.includes("51015");
|
|
5055
|
+
if (has51015) {
|
|
5056
|
+
domain = "localhost:51015";
|
|
5057
|
+
}
|
|
5053
5058
|
switch (domain) {
|
|
5054
5059
|
case "kevisual.xiongxiao.me":
|
|
5055
5060
|
methods = ["password", "wechat-mp"];
|
|
5056
5061
|
break;
|
|
5057
5062
|
case "kevisual.cn":
|
|
5058
|
-
methods = ["password", "wechat", "wechat
|
|
5063
|
+
methods = ["password", "wechat-mp-ticket", "wechat"];
|
|
5064
|
+
break;
|
|
5065
|
+
case "localhost:51015":
|
|
5066
|
+
methods = ["password"];
|
|
5059
5067
|
break;
|
|
5060
5068
|
default:
|
|
5061
5069
|
methods = ["password", "phone", "wechat", "wechat-mp", "wechat-mp-ticket"];
|
|
@@ -5063,6 +5071,9 @@ var getLoginMethodByDomain = () => {
|
|
|
5063
5071
|
}
|
|
5064
5072
|
return DefaultLoginMethods.filter((method) => methods.includes(method.id));
|
|
5065
5073
|
};
|
|
5074
|
+
var getLoginMethod = (methods) => {
|
|
5075
|
+
return DefaultLoginMethods.filter((method) => methods.includes(method.id));
|
|
5076
|
+
};
|
|
5066
5077
|
|
|
5067
5078
|
class KvLogin extends HTMLElement {
|
|
5068
5079
|
selectedMethod = "password";
|
|
@@ -5079,6 +5090,20 @@ class KvLogin extends HTMLElement {
|
|
|
5079
5090
|
this.render();
|
|
5080
5091
|
this.bindEvents();
|
|
5081
5092
|
checkWechat();
|
|
5093
|
+
const method = this.getAttribute("method");
|
|
5094
|
+
if (method) {
|
|
5095
|
+
const methods = method ? method.split(",") : [];
|
|
5096
|
+
if (methods.length > 0) {
|
|
5097
|
+
const loginMethods = methods.filter((m) => LoginMethods.includes(m));
|
|
5098
|
+
if (loginMethods.length > 0) {
|
|
5099
|
+
this.loginMethods = getLoginMethod(loginMethods);
|
|
5100
|
+
this.selectedMethod = loginMethods[0];
|
|
5101
|
+
return;
|
|
5102
|
+
}
|
|
5103
|
+
}
|
|
5104
|
+
this.loginMethods = getLoginMethodByDomain();
|
|
5105
|
+
this.selectedMethod = this.loginMethods[0].id;
|
|
5106
|
+
}
|
|
5082
5107
|
}
|
|
5083
5108
|
#clearTimer = null;
|
|
5084
5109
|
selectLoginMethod(methodId) {
|
package/package.json
CHANGED
package/src/pages/kv-login.ts
CHANGED
|
@@ -31,24 +31,35 @@ const DefaultLoginMethods: LoginMethod[] = [
|
|
|
31
31
|
{ id: 'wechat-mp-ticket', name: '微信公众号', icon: 'wxOpenSvg' },
|
|
32
32
|
{ id: 'phone', name: '手机号登录', icon: 'phone' }
|
|
33
33
|
]
|
|
34
|
+
const LoginMethods = ['password', 'phone', 'wechat', 'wechat-mp', 'wechat-mp-ticket'] as const;
|
|
34
35
|
type LoginMethods = 'password' | 'phone' | 'wechat' | 'wechat-mp' | 'wechat-mp-ticket';
|
|
35
36
|
|
|
36
37
|
const getLoginMethodByDomain = (): LoginMethod[] => {
|
|
37
|
-
|
|
38
|
+
let domain = window.location.host
|
|
38
39
|
let methods: LoginMethods[] = []
|
|
40
|
+
const has51015 = domain.includes('51015');
|
|
41
|
+
if (has51015) {
|
|
42
|
+
domain = 'localhost:51015'
|
|
43
|
+
}
|
|
39
44
|
switch (domain) {
|
|
40
45
|
case 'kevisual.xiongxiao.me':
|
|
41
46
|
methods = ['password', 'wechat-mp']
|
|
42
47
|
break;
|
|
43
48
|
case 'kevisual.cn':
|
|
44
|
-
methods = ['password', 'wechat', 'wechat
|
|
49
|
+
methods = ['password', 'wechat-mp-ticket', 'wechat',]
|
|
45
50
|
break;
|
|
51
|
+
case 'localhost:51015':
|
|
52
|
+
methods = ['password']
|
|
53
|
+
break
|
|
46
54
|
default:
|
|
47
55
|
methods = ['password', 'phone', 'wechat', 'wechat-mp', 'wechat-mp-ticket']
|
|
48
56
|
break;
|
|
49
57
|
}
|
|
50
58
|
return DefaultLoginMethods.filter(method => methods.includes(method.id))
|
|
51
59
|
}
|
|
60
|
+
const getLoginMethod = (methods: LoginMethods[]): LoginMethod[] => {
|
|
61
|
+
return DefaultLoginMethods.filter(method => methods.includes(method.id))
|
|
62
|
+
}
|
|
52
63
|
class KvLogin extends HTMLElement {
|
|
53
64
|
private selectedMethod: LoginMethods = 'password'
|
|
54
65
|
|
|
@@ -66,7 +77,20 @@ class KvLogin extends HTMLElement {
|
|
|
66
77
|
this.render()
|
|
67
78
|
this.bindEvents()
|
|
68
79
|
checkWechat()
|
|
69
|
-
|
|
80
|
+
const method = this.getAttribute('method');
|
|
81
|
+
if (method) {
|
|
82
|
+
const methods = method ? method.split(',') as LoginMethods[] : [];
|
|
83
|
+
if (methods.length > 0) {
|
|
84
|
+
const loginMethods = methods.filter(m => LoginMethods.includes(m));
|
|
85
|
+
if (loginMethods.length > 0) {
|
|
86
|
+
this.loginMethods = getLoginMethod(loginMethods)
|
|
87
|
+
this.selectedMethod = loginMethods[0]
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
this.loginMethods = getLoginMethodByDomain();
|
|
92
|
+
this.selectedMethod = this.loginMethods[0].id;
|
|
93
|
+
}
|
|
70
94
|
}
|
|
71
95
|
#clearTimer: any = null;
|
|
72
96
|
private selectLoginMethod(methodId: LoginMethods) {
|