Browse Source

chore: sso login

master
wangxiang 2 years ago
parent
commit
7d99cbe501
No known key found for this signature in database
GPG Key ID: 1BA7946AB6B232E4
  1. 49
      src/views/system/ssoLogin/kics/index.vue
  2. 51
      src/views/system/ssoLogin/klab/index.vue

49
src/views/system/ssoLogin/kics/index.vue

@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
<a-form
ref="loginRef"
:model="formData"
@keypress.enter="loginHandleClick"
@keypress.enter="handleLogin"
>
<div class="aui-account">
<div class="aui-inputClear">
@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
:loading="loginLoading"
class="aui-link-login aui-flex-box"
type="primary"
@click="loginHandleClick"
@click="handleLogin"
>{{ t('sys.login.loginButton') }}</a-button>
</div>
</div>
@ -73,7 +73,7 @@ @@ -73,7 +73,7 @@
</div>
</template>
<script lang="ts" setup>
import { reactive, ref, toRaw } from 'vue';
import { reactive, ref } from 'vue';
import { useUserStore } from '/@/store/modules/user';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
@ -83,35 +83,24 @@ @@ -83,35 +83,24 @@
import { useLocaleStore } from '/@/store/modules/locale';
import { useDesign } from '/@/hooks/web/useDesign';
import { useAppInject } from '/@/hooks/web/useAppInject';
import {User} from '/@/api/platform/core/entity/user';
const { prefixCls } = useDesign('mini-login');
const { prefixCls } = useDesign('sso-kics-login');
const { notification, createMessage } = useMessage();
const userStore = useUserStore();
const { t } = useI18n();
const localeStore = useLocaleStore();
const showLocale = localeStore.getShowPicker;
//
const formData = reactive<any>({
realKey: '',
inputCode: '',
const formData = reactive<Recordable>({
username: '',
password: '',
});
//
const phoneFormData = reactive<any>({
mobile: '',
smscode: '',
});
const loginRef = ref();
const loginLoading = ref<boolean>(false);
const { getIsMobile } = useAppInject();
async function loginHandleClick() {
await accountLogin();
}
async function accountLogin() {
async function handleLogin() {
if (!formData.username) {
createMessage.warn(t('sys.login.accountPlaceholder'));
return;
@ -120,28 +109,16 @@ @@ -120,28 +109,16 @@
createMessage.warn(t('sys.login.passwordPlaceholder'));
return;
}
if (!formData.inputCode) {
createMessage.warn(t('sys.login.smsPlaceholder'));
return;
}
try {
loginLoading.value = true;
const userInfo = await userStore.login(toRaw({
await userStore.login({
password: formData.password,
username: formData.username,
realKey: formData.realKey,
code: formData.inputCode,
}));
if (userInfo) {
notification.success({
message: t('sys.login.loginSuccessTitle'),
description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.nickName}`,
duration: 3,
goHome: false,
clientId: 'kics'
});
}
} catch (error){
formData.code='';
formData.realKey='';
// sso
document.location.reload();
} finally {
loginLoading.value = false;
}
@ -220,7 +197,7 @@ @@ -220,7 +197,7 @@
</style>
<style lang="less">
@prefix-cls: ~'@{namespace}-mini-login';
@prefix-cls: ~'@{namespace}-sso-kics-login';
@dark-bg: #293146;
html[data-theme='dark'] {

51
src/views/system/ssoLogin/klab/index.vue

@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
<div v-else class="aui-phone-logo">
<img :src="logoPhoneImg" alt="">
</div>
<header class="aui-title text-white text-center">KLAB系统</header>
<header class="aui-title text-white text-center">康来生物KLAB系统</header>
<main class="aui-content">
<div class="aui-container">
<div class="aui-form">
@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
<a-form
ref="loginRef"
:model="formData"
@keypress.enter="loginHandleClick"
@keypress.enter="handleLogin"
>
<div class="aui-account">
<div class="aui-inputClear">
@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
:loading="loginLoading"
class="aui-link-login aui-flex-box"
type="primary"
@click="loginHandleClick"
@click="handleLogin"
>{{ t('sys.login.loginButton') }}</a-button>
</div>
</div>
@ -73,7 +73,7 @@ @@ -73,7 +73,7 @@
</div>
</template>
<script lang="ts" setup>
import { reactive, ref, toRaw } from 'vue';
import { reactive, ref } from 'vue';
import { useUserStore } from '/@/store/modules/user';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
@ -83,35 +83,24 @@ @@ -83,35 +83,24 @@
import { useLocaleStore } from '/@/store/modules/locale';
import { useDesign } from '/@/hooks/web/useDesign';
import { useAppInject } from '/@/hooks/web/useAppInject';
import {User} from '/@/api/platform/core/entity/user';
const { prefixCls } = useDesign('mini-login');
const { prefixCls } = useDesign('sso-klab-login');
const { notification, createMessage } = useMessage();
const userStore = useUserStore();
const { t } = useI18n();
const localeStore = useLocaleStore();
const showLocale = localeStore.getShowPicker;
//
const formData = reactive<any>({
realKey: '',
inputCode: '',
const formData = reactive<Recordable>({
username: '',
password: '',
});
//
const phoneFormData = reactive<any>({
mobile: '',
smscode: '',
});
const loginRef = ref();
const loginLoading = ref<boolean>(false);
const { getIsMobile } = useAppInject();
async function loginHandleClick() {
await accountLogin();
}
async function accountLogin() {
async function handleLogin() {
if (!formData.username) {
createMessage.warn(t('sys.login.accountPlaceholder'));
return;
@ -120,28 +109,16 @@ @@ -120,28 +109,16 @@
createMessage.warn(t('sys.login.passwordPlaceholder'));
return;
}
if (!formData.inputCode) {
createMessage.warn(t('sys.login.smsPlaceholder'));
return;
}
try {
loginLoading.value = true;
const userInfo = await userStore.login(toRaw({
await userStore.login({
password: formData.password,
username: formData.username,
realKey: formData.realKey,
code: formData.inputCode,
}));
if (userInfo) {
notification.success({
message: t('sys.login.loginSuccessTitle'),
description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.nickName}`,
duration: 3,
goHome: false,
clientId: 'klab'
});
}
} catch (error){
formData.code='';
formData.realKey='';
// sso
document.location.reload();
} finally {
loginLoading.value = false;
}
@ -220,7 +197,7 @@ @@ -220,7 +197,7 @@
</style>
<style lang="less">
@prefix-cls: ~'@{namespace}-mini-login';
@prefix-cls: ~'@{namespace}-sso-klab-login';
@dark-bg: #293146;
html[data-theme='dark'] {

Loading…
Cancel
Save