@liujitcn/kratos-uni-app-core 0.0.81 → 0.0.83
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 -0
- package/dist/module.mjs +28 -69
- package/package.json +1 -1
- package/src/components/KratosEmpty.vue +35 -0
- package/src/components/KratosTabBar.vue +8 -17
- package/src/index.ts +2 -0
- package/src/locales/README.md +1 -1
- package/src/locales/en-US.json +7 -17
- package/src/locales/ja-JP.json +7 -17
- package/src/locales/zh-CN.json +7 -17
- package/src/locales/zh-TW.json +7 -17
- package/src/navigation.ts +42 -16
- package/src/pages.ts +0 -1
- package/src/styles/base.scss +21 -0
- package/src/styles/components.scss +122 -73
- package/src/utils/http.ts +25 -9
- package/src/utils/navigation.ts +36 -5
- package/src/views/pages/index/index.vue +35 -15
- package/src/views/pages/login/login.vue +13 -19
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { useSettingStore, useThemeStore, useUserStore } from '../../../stores'
|
|
3
3
|
import type { LoginRequest } from '../../../rpc/base/v1/login'
|
|
4
4
|
import { LoginStatus, type LoginResponse } from '../../../rpc/base/v1/login'
|
|
5
|
-
import { onLoad, onUnload } from '@dcloudio/uni-app'
|
|
5
|
+
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'
|
|
6
6
|
import { computed, defineAsyncComponent, nextTick, reactive, ref, watch } from 'vue'
|
|
7
7
|
import { defLoginService } from '../../../api/base/v1/login'
|
|
8
8
|
import { defMfaService } from '../../../api/base/v1/mfa'
|
|
9
9
|
import defaultLogo from '../../../static/images/logo_icon.png'
|
|
10
10
|
import { formatSrc } from '../../../utils'
|
|
11
|
-
import {
|
|
11
|
+
import { prepareLoginPage, restoreLoginRedirect, returnFromLogin } from '../../../utils/navigation'
|
|
12
12
|
import { encryptPassword } from '../../../utils/secretCrypto'
|
|
13
13
|
import { createWebAuthnCredential, getWebAuthnAssertion } from '../../../utils/webauthn'
|
|
14
14
|
import { navigateAppRoute } from '../../../navigation'
|
|
@@ -600,11 +600,9 @@ const refreshCaptcha = async () => {
|
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
602
|
|
|
603
|
-
/**
|
|
603
|
+
/** 返回首页并结束本次登录回跳,避免上一页再次要求登录。 */
|
|
604
604
|
const goBack = () => {
|
|
605
|
-
|
|
606
|
-
fail: () => uni.reLaunch({ url: homeTabPage }),
|
|
607
|
-
})
|
|
605
|
+
void returnFromLogin()
|
|
608
606
|
}
|
|
609
607
|
|
|
610
608
|
// 页面加载或普通表单刷新验证码,行为验证码延迟到登录弹窗打开时再请求。
|
|
@@ -786,6 +784,7 @@ const onSubmit = async () => {
|
|
|
786
784
|
}
|
|
787
785
|
}
|
|
788
786
|
// #endif
|
|
787
|
+
/** 完成用户资料加载并替换到本次登录目标,直接登录默认进入首页。 */
|
|
789
788
|
const loginSuccess = async () => {
|
|
790
789
|
await userStore.getUserProfile()
|
|
791
790
|
// 成功提示
|
|
@@ -793,13 +792,7 @@ const loginSuccess = async () => {
|
|
|
793
792
|
if (loginSuccessTimer) clearTimeout(loginSuccessTimer)
|
|
794
793
|
loginSuccessTimer = setTimeout(() => {
|
|
795
794
|
loginSuccessTimer = undefined
|
|
796
|
-
|
|
797
|
-
if (lastRoute.startsWith(homeTabPage)) {
|
|
798
|
-
uni.setStorageSync('SwitchTabIndex', true)
|
|
799
|
-
}
|
|
800
|
-
uni.removeStorageSync('lastRoute')
|
|
801
|
-
|
|
802
|
-
uni.reLaunch({ url: lastRoute })
|
|
795
|
+
void restoreLoginRedirect()
|
|
803
796
|
}, 500)
|
|
804
797
|
}
|
|
805
798
|
|
|
@@ -882,8 +875,13 @@ const loadLoginSettings = () => {
|
|
|
882
875
|
/** 确保登录前已完成移动端配置加载。 */
|
|
883
876
|
const ensureLoginSettings = () => loadLoginSettings()
|
|
884
877
|
|
|
885
|
-
|
|
886
|
-
onLoad(() => {
|
|
878
|
+
let loginRedirect: string | undefined
|
|
879
|
+
onLoad((options) => {
|
|
880
|
+
loginRedirect = options?.redirect
|
|
881
|
+
})
|
|
882
|
+
|
|
883
|
+
onShow(() => {
|
|
884
|
+
if (!prepareLoginPage(loginRedirect)) return
|
|
887
885
|
void loadLoginSettings()
|
|
888
886
|
})
|
|
889
887
|
|
|
@@ -918,10 +916,6 @@ onUnload(() => {
|
|
|
918
916
|
</view>
|
|
919
917
|
</view>
|
|
920
918
|
<view class="k-glass k-glass--lit login-panel">
|
|
921
|
-
<view class="k-cnr k-cnr--tl" aria-hidden="true"></view>
|
|
922
|
-
<view class="k-cnr k-cnr--tr" aria-hidden="true"></view>
|
|
923
|
-
<view class="k-cnr k-cnr--bl" aria-hidden="true"></view>
|
|
924
|
-
<view class="k-cnr k-cnr--br" aria-hidden="true"></view>
|
|
925
919
|
<view class="login-form">
|
|
926
920
|
<!-- 网页端表单登录 -->
|
|
927
921
|
<!-- #ifdef H5 -->
|