更新登录组件,支持多种登录方式,修改版本号至0.1.1,并更新示例代码

This commit is contained in:
2025-12-17 15:08:31 +08:00
parent 65ee31e8ca
commit 7db3f1f6dc
6 changed files with 50 additions and 9 deletions

View File

@@ -10,3 +10,24 @@ $:
# stages: # stages:
# - name: pnpm install # - name: pnpm install
# script: pnpm install # script: pnpm install
main:
web_trigger_sync_to_gitea:
- services:
- docker
imports:
- https://cnb.cool/kevisual/env/-/blob/main/env.yml
stages:
- name: 'show username'
script: echo "GITEA_USERNAME is ${GITEA_USERNAME} and GITEA_PASSWORD is ${GITEA_PASSWORD}"
- name: sync to gitea
image: tencentcom/git-sync
settings:
target_url: https://git.xiongxiao.me/web-components/kv-login.git
auth_type: https
username: "oauth2"
password: ${GITEA_TOKEN}
git_user: "abearxiong"
git_email: "xiongxiao@xiongxiao.me"
sync_mode: rebase
branch: main

11
.cnb/web_trigger.yml Normal file
View File

@@ -0,0 +1,11 @@
# .cnb/web_trigger.yml
branch:
# 如下按钮在分支名以 release 开头的分支详情页面显示
- reg: "^main"
buttons:
- name: 同步代码到gitea
desc: 同步代码到gitea
event: web_trigger_sync_to_gitea
- name: 同步gitea代码到当前仓库
desc: 同步gitea代码到当前仓库
event: web_trigger_sync_from_gitea

View File

@@ -74,8 +74,7 @@
<div class="demo-container"> <div class="demo-container">
<div class="login-section"> <div class="login-section">
<h2>登录组件</h2> <h2>登录组件</h2>
<kv-login method="password"> <kv-login method="password,wechat,wechat-mp">
<div id="weixinLogin"></div>
</kv-login> </kv-login>
</div> </div>
</div> </div>

View File

@@ -1,6 +1,6 @@
{ {
"name": "@kevisual/kv-login", "name": "@kevisual/kv-login",
"version": "0.1.0", "version": "0.1.1",
"description": "", "description": "",
"main": "src/main.ts", "main": "src/main.ts",
"scripts": { "scripts": {
@@ -19,6 +19,10 @@
"access": "public" "access": "public"
}, },
"type": "module", "type": "module",
"files": [
"types",
"dist"
],
"dependencies": { "dependencies": {
"@kevisual/context": "^0.0.4", "@kevisual/context": "^0.0.4",
"@kevisual/query": "^0.0.32", "@kevisual/query": "^0.0.32",

View File

@@ -6,7 +6,6 @@
```html ```html
<kv-login> <kv-login>
<div id="weixinLogin"></div>
</kv-login> </kv-login>
``` ```
@@ -23,7 +22,6 @@
<script type="module"> <script type="module">
import '@kevisual/kv-login'; import '@kevisual/kv-login';
</script> </script>
<kv-login method="password"> <kv-login method="password,wechat,wechat-mp">
<div id="weixinLogin"></div>
</kv-login> </kv-login>
``` ```

View File

@@ -320,10 +320,18 @@ class KvLogin extends HTMLElement {
return this.renderPasswordForm() return this.renderPasswordForm()
} }
} }
createWeixinEl(){
const id = 'weixinLogin';
let el = this.querySelector('#' + id);
if (el) return el;
const weixinEl = document.createElement('div');
weixinEl.id = 'weixinLogin';
this.appendChild(weixinEl);
return weixinEl;
}
render() { render() {
if (!this.shadowRoot) return if (!this.shadowRoot) return
this.createWeixinEl();
const renderIcon = (icon: any) => { const renderIcon = (icon: any) => {
// 如果是emoji字符直接返回 // 如果是emoji字符直接返回
if (typeof icon === 'string' && !icons[icon]) { if (typeof icon === 'string' && !icons[icon]) {