add kv-login modules

This commit is contained in:
2025-11-28 20:22:58 +08:00
parent 2ae2b3ab4c
commit 6ff8d7acde
4 changed files with 48 additions and 8 deletions

View File

@@ -13,14 +13,30 @@ const DefaultLoginMethods: LoginMethod[] = [
{ id: 'password', name: '密码登录', icon: '🔒' },
{ id: 'wechat', name: '微信登录', icon: '💬', appid: "wx9378885c8390e09b" },
{ id: 'wechat-mp', name: '微信公众号登录', icon: '💬', appid: WX_MP_APP_ID },
// { id: 'phone', name: '手机号登录', icon: '📱' }
{ id: 'phone', name: '手机号登录', icon: '📱' }
]
type LoginMethods = 'password' | 'phone' | 'wechat' | 'wechat-mp'
const getLoginMethodByDomain = (): LoginMethod[] => {
const domain = window.location.hostname
let methods: LoginMethods[] = []
switch (domain) {
case 'kevisual.xiongxiao.me':
methods = ['password', 'wechat-mp']
break;
case 'kevisual.cn':
methods = ['password', 'wechat']
break;
default:
methods = ['password', 'phone', 'wechat', 'wechat-mp']
break;
}
return DefaultLoginMethods.filter(method => methods.includes(method.id))
}
console.log('可用登录方式:', getLoginMethodByDomain().map(m => m.name).join(', '));
class KvLogin extends HTMLElement {
private selectedMethod: LoginMethods = 'password'
private loginMethods: LoginMethod[] = DefaultLoginMethods
private loginMethods: LoginMethod[] = getLoginMethodByDomain();
setLoginMethods(methods: LoginMethod[]) {
this.loginMethods = methods
this.render()
@@ -34,6 +50,7 @@ class KvLogin extends HTMLElement {
this.render()
this.bindEvents()
checkWechat()
}
#clearTimer: any = null;
private selectLoginMethod(methodId: LoginMethods) {