update
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
"@astrojs/sitemap": "^3.6.0",
|
"@astrojs/sitemap": "^3.6.0",
|
||||||
"@floating-ui/dom": "^1.7.4",
|
"@floating-ui/dom": "^1.7.4",
|
||||||
"@kevisual/context": "^0.0.4",
|
"@kevisual/context": "^0.0.4",
|
||||||
"@kevisual/kv-login": "^0.0.7",
|
"@kevisual/kv-login": "^0.0.8",
|
||||||
"@kevisual/query": "0.0.29",
|
"@kevisual/query": "0.0.29",
|
||||||
"@kevisual/query-login": "^0.0.7",
|
"@kevisual/query-login": "^0.0.7",
|
||||||
"@kevisual/registry": "^0.0.1",
|
"@kevisual/registry": "^0.0.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kevisual/kv-login",
|
"name": "@kevisual/kv-login",
|
||||||
"version": "0.0.7",
|
"version": "0.0.8",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -31,24 +31,35 @@ const DefaultLoginMethods: LoginMethod[] = [
|
|||||||
{ id: 'wechat-mp-ticket', name: '微信公众号', icon: 'wxOpenSvg' },
|
{ id: 'wechat-mp-ticket', name: '微信公众号', icon: 'wxOpenSvg' },
|
||||||
{ id: 'phone', name: '手机号登录', icon: 'phone' }
|
{ id: 'phone', name: '手机号登录', icon: 'phone' }
|
||||||
]
|
]
|
||||||
|
const LoginMethods = ['password', 'phone', 'wechat', 'wechat-mp', 'wechat-mp-ticket'] as const;
|
||||||
type LoginMethods = 'password' | 'phone' | 'wechat' | 'wechat-mp' | 'wechat-mp-ticket';
|
type LoginMethods = 'password' | 'phone' | 'wechat' | 'wechat-mp' | 'wechat-mp-ticket';
|
||||||
|
|
||||||
const getLoginMethodByDomain = (): LoginMethod[] => {
|
const getLoginMethodByDomain = (): LoginMethod[] => {
|
||||||
const domain = window.location.hostname
|
let domain = window.location.host
|
||||||
let methods: LoginMethods[] = []
|
let methods: LoginMethods[] = []
|
||||||
|
const has51015 = domain.includes('51015');
|
||||||
|
if (has51015) {
|
||||||
|
domain = 'localhost:51015'
|
||||||
|
}
|
||||||
switch (domain) {
|
switch (domain) {
|
||||||
case 'kevisual.xiongxiao.me':
|
case 'kevisual.xiongxiao.me':
|
||||||
methods = ['password', 'wechat-mp']
|
methods = ['password', 'wechat-mp']
|
||||||
break;
|
break;
|
||||||
case 'kevisual.cn':
|
case 'kevisual.cn':
|
||||||
methods = ['password', 'wechat', 'wechat-mp-ticket']
|
methods = ['password', 'wechat-mp-ticket', 'wechat',]
|
||||||
break;
|
break;
|
||||||
|
case 'localhost:51015':
|
||||||
|
methods = ['password']
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
methods = ['password', 'phone', 'wechat', 'wechat-mp', 'wechat-mp-ticket']
|
methods = ['password', 'phone', 'wechat', 'wechat-mp', 'wechat-mp-ticket']
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return DefaultLoginMethods.filter(method => methods.includes(method.id))
|
return DefaultLoginMethods.filter(method => methods.includes(method.id))
|
||||||
}
|
}
|
||||||
|
const getLoginMethod = (methods: LoginMethods[]): LoginMethod[] => {
|
||||||
|
return DefaultLoginMethods.filter(method => methods.includes(method.id))
|
||||||
|
}
|
||||||
class KvLogin extends HTMLElement {
|
class KvLogin extends HTMLElement {
|
||||||
private selectedMethod: LoginMethods = 'password'
|
private selectedMethod: LoginMethods = 'password'
|
||||||
|
|
||||||
@@ -66,7 +77,20 @@ class KvLogin extends HTMLElement {
|
|||||||
this.render()
|
this.render()
|
||||||
this.bindEvents()
|
this.bindEvents()
|
||||||
checkWechat()
|
checkWechat()
|
||||||
|
const method = this.getAttribute('method');
|
||||||
|
if (method) {
|
||||||
|
const methods = method ? method.split(',') as LoginMethods[] : [];
|
||||||
|
if (methods.length > 0) {
|
||||||
|
const loginMethods = methods.filter(m => LoginMethods.includes(m));
|
||||||
|
if (loginMethods.length > 0) {
|
||||||
|
this.loginMethods = getLoginMethod(loginMethods)
|
||||||
|
this.selectedMethod = loginMethods[0]
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.loginMethods = getLoginMethodByDomain();
|
||||||
|
this.selectedMethod = this.loginMethods[0].id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#clearTimer: any = null;
|
#clearTimer: any = null;
|
||||||
private selectLoginMethod(methodId: LoginMethods) {
|
private selectLoginMethod(methodId: LoginMethods) {
|
||||||
|
|||||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@@ -27,8 +27,8 @@ importers:
|
|||||||
specifier: ^0.0.4
|
specifier: ^0.0.4
|
||||||
version: 0.0.4
|
version: 0.0.4
|
||||||
'@kevisual/kv-login':
|
'@kevisual/kv-login':
|
||||||
specifier: ^0.0.7
|
specifier: ^0.0.8
|
||||||
version: 0.0.7(@kevisual/query@0.0.29(ws@8.18.0)(zod@3.25.76))
|
version: 0.0.8(@kevisual/query@0.0.29(ws@8.18.0)(zod@3.25.76))
|
||||||
'@kevisual/query':
|
'@kevisual/query':
|
||||||
specifier: 0.0.29
|
specifier: 0.0.29
|
||||||
version: 0.0.29(ws@8.18.0)(zod@3.25.76)
|
version: 0.0.29(ws@8.18.0)(zod@3.25.76)
|
||||||
@@ -880,8 +880,8 @@ packages:
|
|||||||
'@kevisual/context@0.0.4':
|
'@kevisual/context@0.0.4':
|
||||||
resolution: {integrity: sha512-HJeLeZQLU+7tCluSfOyvkgKLs0HjCZrdJlZgEgKRSa8XTwZfMAUt6J7qZTbrZAHBlPtX68EPu/PI8JMCeu3WAQ==}
|
resolution: {integrity: sha512-HJeLeZQLU+7tCluSfOyvkgKLs0HjCZrdJlZgEgKRSa8XTwZfMAUt6J7qZTbrZAHBlPtX68EPu/PI8JMCeu3WAQ==}
|
||||||
|
|
||||||
'@kevisual/kv-login@0.0.7':
|
'@kevisual/kv-login@0.0.8':
|
||||||
resolution: {integrity: sha512-PB4AultJdrnSf9Knz3zTCdMzE8TS7JbNpoaL9gQJDEpePXNhZrsnKNXMyd0XFh6f3GNhrc39cA/O4SsOlZlx2w==}
|
resolution: {integrity: sha512-N6nDCwI0sZkjQAiJf7JpyVvn5x3Nf2qWp9U9vzSMDyYeV/PHNzMZIr42Woma2MGFwcjMRjcnJxIC7HWARVLLsQ==}
|
||||||
|
|
||||||
'@kevisual/query-login@0.0.6':
|
'@kevisual/query-login@0.0.6':
|
||||||
resolution: {integrity: sha512-ZdX+sxeQaM3PV9fZXofMlxFz1RmpYIkoi47exzUgw6DADjEryBAQKRXe2/oL20NsBTV8owqaagRqffAVjq5c5g==}
|
resolution: {integrity: sha512-ZdX+sxeQaM3PV9fZXofMlxFz1RmpYIkoi47exzUgw6DADjEryBAQKRXe2/oL20NsBTV8owqaagRqffAVjq5c5g==}
|
||||||
@@ -4374,7 +4374,7 @@ snapshots:
|
|||||||
|
|
||||||
'@kevisual/context@0.0.4': {}
|
'@kevisual/context@0.0.4': {}
|
||||||
|
|
||||||
'@kevisual/kv-login@0.0.7(@kevisual/query@0.0.29(ws@8.18.0)(zod@3.25.76))':
|
'@kevisual/kv-login@0.0.8(@kevisual/query@0.0.29(ws@8.18.0)(zod@3.25.76))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@kevisual/context': 0.0.4
|
'@kevisual/context': 0.0.4
|
||||||
'@kevisual/query-login': 0.0.7(@kevisual/query@0.0.29(ws@8.18.0)(zod@3.25.76))
|
'@kevisual/query-login': 0.0.7(@kevisual/query@0.0.29(ws@8.18.0)(zod@3.25.76))
|
||||||
|
|||||||
Reference in New Issue
Block a user