This commit is contained in:
2025-12-01 02:19:44 +08:00
parent 84775dd878
commit a51a366f00
21 changed files with 2628 additions and 229 deletions

View File

@@ -3,6 +3,9 @@ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js'
import { loginHandle, checkWechat, getQrCode, checkMpQrCodeLogin } from '../modules/login-handle.ts'
import { setWxerwma } from '../modules/wx/ws-login.ts';
import { useCreateLoginQRCode } from '../modules/wx-mp/qr.ts';
import { eventEmitter } from '../modules/mitt.ts';
import { useContextKey } from '@kevisual/context'
export const loginEmitter = useContextKey('login-emitter', eventEmitter);
export const WX_MP_APP_ID = "wxff97d569b1db16b6";
interface LoginMethod {
id: LoginMethods
@@ -46,7 +49,6 @@ const getLoginMethodByDomain = (): LoginMethod[] => {
}
return DefaultLoginMethods.filter(method => methods.includes(method.id))
}
console.log('可用登录方式:', getLoginMethodByDomain().map(m => m.name).join(', '));
class KvLogin extends HTMLElement {
private selectedMethod: LoginMethods = 'password'
@@ -80,7 +82,6 @@ class KvLogin extends HTMLElement {
}
private bindEvents() {
if (!this.shadowRoot) return
// 使用事件委托来处理登录方式切换
this.shadowRoot.addEventListener('click', (e) => {
const target = e.target as HTMLElement
@@ -101,6 +102,9 @@ class KvLogin extends HTMLElement {
this.handleLogin()
}
})
loginEmitter.on('login-success', () => {
console.log('收到登录成功事件,处理后续逻辑')
});
}
private handleLogin() {
@@ -331,8 +335,8 @@ class KvLogin extends HTMLElement {
.login-methods {
display: flex;
background: #f8f9fa;
border-bottom: 1px solid #e9ecef;
background: #f5f5f5;
border-bottom: 1px solid #000000;
}
.login-method {
@@ -350,7 +354,7 @@ class KvLogin extends HTMLElement {
}
.login-method:hover {
background: #e9ecef;
background: #d0d0d0;
}
.login-method.active {
@@ -418,7 +422,7 @@ class KvLogin extends HTMLElement {
.form-group input {
width: 100%;
padding: 12px 16px;
border: 2px solid #e9ecef;
border: 2px solid #cccccc;
border-radius: 8px;
font-size: 14px;
transition: border-color 0.3s ease;
@@ -481,7 +485,7 @@ class KvLogin extends HTMLElement {
.qr-container {
width: 340px;
height: 340px;
border: 2px dashed #cccccc;
border: 2px solid #000000;
border-radius: 8px;
display: flex;
align-items: center;
@@ -490,7 +494,7 @@ class KvLogin extends HTMLElement {
.qr-placeholder {
text-align: center;
color: #6c757d;
color: #333333;
}
.qr-icon {