fix(auth): 快捷登录 - 保留顶部切换并优化底部入口

This commit is contained in:
2026-09-10 11:49:24 +08:00
parent aa0d22bbe2
commit f8b6196205
301 changed files with 465 additions and 9 deletions
+24
View File
@@ -0,0 +1,24 @@
import assert from 'node:assert/strict'
import fs from 'node:fs'
import { createRequire } from 'node:module'
const require = createRequire(new URL('../../admin/package.json', import.meta.url))
const { parse, compileScript, compileTemplate } = require('@vue/compiler-sfc')
const filename = new URL('../../admin/src/views/account/login.vue', import.meta.url).pathname
const source = fs.readFileSync(filename, 'utf8')
const { descriptor, errors } = parse(source, { filename })
assert.deepEqual(errors, [])
const template = descriptor.template.content
assert.equal((template.match(/@click="handleIamLogin"/g) || []).length, 1, 'exactly one IAM entry')
const section = template.match(/<section v-if="iamEnabled" class="iam-login-alternative"[\s\S]*?<\/section>/)?.[0]
assert.ok(section, 'IAM alternative is enabled only by iamEnabled')
assert.match(section, /@click="handleIamLogin"/)
assert.ok(template.indexOf(section) > template.indexOf('@click="lockLogin"'), 'IAM follows local login')
assert.ok(template.indexOf(section) > template.indexOf('请使用企业微信扫描二维码登录'), 'IAM follows WeCom region')
assert.ok(template.indexOf(section) > template.indexOf('</el-radio-group>'), 'no IAM above mode switch')
assert.match(template, /<el-radio-button value="account">账号登录<\/el-radio-button>/)
assert.match(template, /<el-radio-button value="wxwork">企业微信<\/el-radio-button>/)
const script = compileScript(descriptor, { id: 'iam-login-placement' })
const compiled = compileTemplate({ source: template, filename, id: 'iam-login-placement', compilerOptions: { bindingMetadata: script.bindings } })
assert.deepEqual(compiled.errors, [])
console.log('PASS IAM placement: single optional bottom entry, original handler, account/WeCom switch, local/WeCom ordering, SFC script/template compilation')