@csntgao/uni-base 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/docs//350/264/246/346/210/267/344/270/216/347/231/273/345/275/225/347/273/204/344/273/266/345/212/250/346/200/201/346/216/245/345/205/245/350/257/264/346/230/216.md +3 -3
- package/package.json +1 -1
- package/packages/web-components/package.json +1 -1
- package/packages/web-components/src/user-login.ts +13 -2
- package/packages/web-components/tests/user-login.test.ts +27 -0
package/README.md
CHANGED
|
@@ -218,8 +218,8 @@ function applyNotificationRealtimeEvent(rawEvent: unknown) {
|
|
|
218
218
|
headerSubtitle: '手机号验证后进入企业服务平台',
|
|
219
219
|
headerIconUrl: '/assets/login-shield.svg',
|
|
220
220
|
securityHint: '登录凭证仅用于企业工作台认证,请勿向他人透露验证码',
|
|
221
|
-
userAgreementUrl: '/
|
|
222
|
-
privacyAgreementUrl: '/
|
|
221
|
+
userAgreementUrl: 'https://website.hrs100.com/agreement/user-service-agreement.html',
|
|
222
|
+
privacyAgreementUrl: 'https://website.hrs100.com/agreement/qqxb-user-privacy.html',
|
|
223
223
|
forgotPasswordUrl: '/account/forgot-password',
|
|
224
224
|
initialMethod: 'verification-code',
|
|
225
225
|
})
|
|
@@ -139,8 +139,8 @@ userLogin.configure({
|
|
|
139
139
|
headerSubtitle: '手机号验证后进入企业服务平台',
|
|
140
140
|
headerIconUrl: 'https://static.example.com/login-shield.svg',
|
|
141
141
|
securityHint: '登录凭证仅用于企业工作台认证,请勿向他人透露验证码',
|
|
142
|
-
userAgreementUrl: '/
|
|
143
|
-
privacyAgreementUrl: '/
|
|
142
|
+
userAgreementUrl: 'https://website.hrs100.com/agreement/user-service-agreement.html',
|
|
143
|
+
privacyAgreementUrl: 'https://website.hrs100.com/agreement/qqxb-user-privacy.html',
|
|
144
144
|
forgotPasswordUrl: '/account/forgot-password',
|
|
145
145
|
initialMethod: 'verification-code',
|
|
146
146
|
})
|
|
@@ -151,7 +151,7 @@ userLogin.configure({
|
|
|
151
151
|
| `transport` | 是 | 完成登录接口调用;专用 transport 的 `setAccessToken()` 必须原子保存 JWT。 |
|
|
152
152
|
| `applicationName` | 是 | 目标应用稳定名称。 |
|
|
153
153
|
| `headerTitle`、`headerSubtitle`、`headerIconUrl`、`securityHint` | 否 | 外观文案与图标;不得包含凭据。 |
|
|
154
|
-
| `userAgreementUrl`、`privacyAgreementUrl`、`forgotPasswordUrl` | 否 |
|
|
154
|
+
| `userAgreementUrl`、`privacyAgreementUrl`、`forgotPasswordUrl` | 否 | 调用方页面地址;两个协议地址未传时使用亲亲小保官网协议页。 |
|
|
155
155
|
| `initialMethod` | 否 | `password`、`verification-code` 或 `qr-code`。 |
|
|
156
156
|
| `countdownSeconds`、`qrPollIntervalMs`、`initiallyAgreed`、`initiallyRememberSession` | 否 | 固定行为的可选初始值。 |
|
|
157
157
|
|
package/package.json
CHANGED
|
@@ -86,6 +86,11 @@ type QrViewState = 'idle' | 'loading' | UserLoginQrStatus | 'error'
|
|
|
86
86
|
|
|
87
87
|
export const USER_LOGIN_QR_LOGIN_ENABLED = false
|
|
88
88
|
|
|
89
|
+
const USER_LOGIN_DEFAULT_USER_AGREEMENT_URL =
|
|
90
|
+
'https://website.hrs100.com/agreement/user-service-agreement.html'
|
|
91
|
+
const USER_LOGIN_DEFAULT_PRIVACY_AGREEMENT_URL =
|
|
92
|
+
'https://website.hrs100.com/agreement/qqxb-user-privacy.html'
|
|
93
|
+
|
|
89
94
|
const EMPTY_ERRORS: FormErrors = {
|
|
90
95
|
mobile: '',
|
|
91
96
|
smsCode: '',
|
|
@@ -923,8 +928,14 @@ export class UniplatUserLogin extends LitElement {
|
|
|
923
928
|
this.config = {
|
|
924
929
|
transport: config.transport,
|
|
925
930
|
applicationName: normalizeApplicationName(config.applicationName),
|
|
926
|
-
userAgreementUrl: safeNavigationUrl(
|
|
927
|
-
|
|
931
|
+
userAgreementUrl: safeNavigationUrl(
|
|
932
|
+
config.userAgreementUrl ?? USER_LOGIN_DEFAULT_USER_AGREEMENT_URL,
|
|
933
|
+
'Agreement URL',
|
|
934
|
+
),
|
|
935
|
+
privacyAgreementUrl: safeNavigationUrl(
|
|
936
|
+
config.privacyAgreementUrl ?? USER_LOGIN_DEFAULT_PRIVACY_AGREEMENT_URL,
|
|
937
|
+
'Agreement URL',
|
|
938
|
+
),
|
|
928
939
|
forgotPasswordUrl: safeNavigationUrl(config.forgotPasswordUrl, 'Forgot-password URL'),
|
|
929
940
|
countdownSeconds,
|
|
930
941
|
qrPollIntervalMs,
|
|
@@ -48,6 +48,7 @@ describe('<uniplat-user-login>', () => {
|
|
|
48
48
|
afterEach(() => {
|
|
49
49
|
document.body.replaceChildren()
|
|
50
50
|
vi.useRealTimers()
|
|
51
|
+
vi.restoreAllMocks()
|
|
51
52
|
})
|
|
52
53
|
|
|
53
54
|
it('registers, renders the verification login form and completes a safe login flow', async () => {
|
|
@@ -278,6 +279,32 @@ describe('<uniplat-user-login>', () => {
|
|
|
278
279
|
).toThrow(TypeError)
|
|
279
280
|
})
|
|
280
281
|
|
|
282
|
+
it('opens the official user and privacy agreements by default', async () => {
|
|
283
|
+
const openWindow = vi.spyOn(window, 'open').mockReturnValue(null)
|
|
284
|
+
const login = document.createElement(USER_LOGIN_TAG)
|
|
285
|
+
login.configure({ transport: createTransport(), applicationName: 'HrSaas' })
|
|
286
|
+
document.body.append(login)
|
|
287
|
+
await settle(login)
|
|
288
|
+
|
|
289
|
+
const links = login.shadowRoot?.querySelectorAll<HTMLButtonElement>('.agreement-link')
|
|
290
|
+
expect(links).toHaveLength(2)
|
|
291
|
+
links?.[0]?.click()
|
|
292
|
+
links?.[1]?.click()
|
|
293
|
+
|
|
294
|
+
expect(openWindow).toHaveBeenNthCalledWith(
|
|
295
|
+
1,
|
|
296
|
+
'https://website.hrs100.com/agreement/user-service-agreement.html',
|
|
297
|
+
'_blank',
|
|
298
|
+
'noopener,noreferrer',
|
|
299
|
+
)
|
|
300
|
+
expect(openWindow).toHaveBeenNthCalledWith(
|
|
301
|
+
2,
|
|
302
|
+
'https://website.hrs100.com/agreement/qqxb-user-privacy.html',
|
|
303
|
+
'_blank',
|
|
304
|
+
'noopener,noreferrer',
|
|
305
|
+
)
|
|
306
|
+
})
|
|
307
|
+
|
|
281
308
|
it('maps transport failures to stable errors without exposing the original exception', async () => {
|
|
282
309
|
const sensitiveText = 'backend stack with jwt=should-never-render'
|
|
283
310
|
const transport = createTransport({
|