Browse Source

chore: login tenant compose

master
wangxiang 2 years ago
parent
commit
d428d2aa84
No known key found for this signature in database
GPG Key ID: 1BA7946AB6B232E4
  1. 4
      src/api/platform/system/controller/tenant.ts
  2. 1
      src/locales/lang/en/sys.ts
  3. 1
      src/locales/lang/zh-CN/sys.ts
  4. 82
      src/views/core/loginmini/MiniLogin.vue

4
src/api/platform/system/controller/tenant.ts

@ -8,6 +8,7 @@ import { defHttp } from '/@/utils/http/axios'; @@ -8,6 +8,7 @@ import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/system_proxy/system/tenant/list',
loginTenantList= '/system_proxy/system/tenant/loginTenantList',
add = '/system_proxy/system/tenant/save',
get = '/system_proxy/system/tenant',
edit = '/system_proxy/system/tenant/update',
@ -18,6 +19,9 @@ enum Api { @@ -18,6 +19,9 @@ enum Api {
/** 查询多租户列表 */
export const listTenant = (params?: Partial<TenantParams>) => defHttp.get<TenantResult>({ url: Api.list, params }, { isReturnResultResponse: true });
/** 查询登陆选择多租户列表 */
export const loginTenantList = () => defHttp.get<Tenant[]>({ url: Api.loginTenantList });
/** 新增多租户 */
export const addTenant = (params: Partial<Tenant>) => defHttp.post({ url: Api.add, data: params });

1
src/locales/lang/en/sys.ts

@ -95,6 +95,7 @@ export default { @@ -95,6 +95,7 @@ export default {
accountPlaceholder: 'Please input username',
passwordPlaceholder: 'Please input password',
identityProviderPlaceholder: 'Please select identity provider',
tenantPlaceholder: 'Please select Tenant',
smsPlaceholder: 'Please input sms code',
mobilePlaceholder: 'Please input mobile',
policyPlaceholder: 'Register after checking',

1
src/locales/lang/zh-CN/sys.ts

@ -90,6 +90,7 @@ export default { @@ -90,6 +90,7 @@ export default {
accountPlaceholder: '请输入账号',
passwordPlaceholder: '请输入密码',
identityProviderPlaceholder: '请选择身份提供商',
tenantPlaceholder: '请选择租户',
smsPlaceholder: '请输入验证码',
mobilePlaceholder: '请输入手机号码',
policyPlaceholder: '勾选后才能注册',

82
src/views/core/loginmini/MiniLogin.vue

@ -1,7 +1,39 @@ @@ -1,7 +1,39 @@
<template>
<div :class="prefixCls" class="login-background-img">
<!--多租户选择器-->
<Dropdown
class="absolute top-3 right-40 enter-x"
placement="bottom"
:trigger="['hover']"
:dropMenuList="options.tenantIdList"
:selectedKeys="formData.tenantId"
@menu-event="handleTenantIdMenuEvent"
>
<span>
<Button shape="circle" ghost size="large">
<i class="icon icon-tenant" style="float: none; margin: 2px auto -5px auto;"/>
<span style="color: #00000080; font-size: 10px;">租户</span>
</Button>
</span>
</Dropdown>
<!--身份提供商多选择器-->
<Dropdown
class="absolute top-3 right-26 enter-x"
placement="bottom"
:trigger="['hover']"
:dropMenuList="options.identityProviderList"
:selectedKeys="formData.identityProvider"
@menu-event="handleIdentityProviderMenuEvent"
>
<span>
<Button shape="circle" ghost size="large">
<i class="icon icon-role" style="float: none; margin: 2px auto -5px auto;"/>
<span style="color: #00000080; font-size: 10px;">身份</span>
</Button>
</span>
</Dropdown>
<AppLocalePicker v-if="!sessionTimeout && showLocale" class="absolute top-4 right-4 enter-x xl:text-gray-600" :showText="false"/>
<AppDarkModeToggle v-if="!sessionTimeout" class="absolute top-3 right-10 enter-x"/>
<AppDarkModeToggle v-if="!sessionTimeout" class="absolute top-4 right-10 enter-x"/>
<div v-if="!getIsMobile" class="aui-logo">
<div>
<h3>
@ -198,6 +230,10 @@ @@ -198,6 +230,10 @@
import { useDesign } from '/@/hooks/web/useDesign';
import { useAppInject } from '/@/hooks/web/useAppInject';
import { GithubFilled, WechatFilled, AlipayCircleFilled, DingtalkCircleFilled } from '@ant-design/icons-vue';
import { Dropdown, DropMenu } from '/@/components/Dropdown';
import { Button } from '/@/components/Button';
import { loginTenantList } from '/@/api/platform/system/controller/tenant';
import { getDataByDictType } from '/@/api/platform/system/controller/dictdata';
defineProps({
sessionTimeout: {
@ -225,12 +261,19 @@ @@ -225,12 +261,19 @@
inputCode: '',
username: '',
password: '',
identityProvider: [],
tenantId: [],
});
//
const phoneFormData = reactive<any>({
mobile: '',
smscode: '',
});
//
const options = reactive<any>({
identityProviderList: [],
tenantIdList: []
});
const loginRef = ref();
//
const codeRef = ref();
@ -293,6 +336,10 @@ @@ -293,6 +336,10 @@
createMessage.warn(t('sys.login.smsPlaceholder'));
return;
}
if (!formData.tenantId[0]) {
createMessage.warn(t('sys.login.tenantPlaceholder'));
return;
}
try {
loginLoading.value = true;
const userInfo = await userStore.login(toRaw({
@ -300,6 +347,8 @@ @@ -300,6 +347,8 @@
username: formData.username,
realKey: formData.realKey,
code: formData.inputCode,
identityProvider: formData.identityProvider[0],
tenantId: formData.tenantId[0],
}));
if (userInfo) {
notification.success({
@ -412,9 +461,36 @@ @@ -412,9 +461,36 @@
}, 300);
}
onMounted(() => {
function handleTenantIdMenuEvent(menu: DropMenu) {
if (formData.tenantId[0] === menu.event) {
return;
}
formData.tenantId = [menu.event];
}
function handleIdentityProviderMenuEvent(menu: DropMenu) {
if (formData.identityProvider[0] === menu.event) {
return;
}
formData.identityProvider = [menu.event];
}
onMounted(async () => {
//
handleChangeCheckCode();
await handleChangeCheckCode();
const tenantIdList = await loginTenantList();
options.tenantIdList = tenantIdList.map(item => ({
text: item.name,
event: item.code,
} as DropMenu));
options.tenantIdList[0] && (formData.tenantId = [options.tenantIdList[0].event]);
const identityProviderList = await getDataByDictType({ type: 'identityProvider', tenantId: formData.tenantId });
options.identityProviderList = identityProviderList.map(item => ({
text: item.label,
event: item.value,
} as DropMenu));
options.identityProviderList[0] && (formData.identityProvider = [options.identityProviderList[0].event]);
});
</script>

Loading…
Cancel
Save