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';
enum Api { enum Api {
list = '/system_proxy/system/tenant/list', list = '/system_proxy/system/tenant/list',
loginTenantList= '/system_proxy/system/tenant/loginTenantList',
add = '/system_proxy/system/tenant/save', add = '/system_proxy/system/tenant/save',
get = '/system_proxy/system/tenant', get = '/system_proxy/system/tenant',
edit = '/system_proxy/system/tenant/update', edit = '/system_proxy/system/tenant/update',
@ -18,6 +19,9 @@ enum Api {
/** 查询多租户列表 */ /** 查询多租户列表 */
export const listTenant = (params?: Partial<TenantParams>) => defHttp.get<TenantResult>({ url: Api.list, params }, { isReturnResultResponse: true }); 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 }); 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 {
accountPlaceholder: 'Please input username', accountPlaceholder: 'Please input username',
passwordPlaceholder: 'Please input password', passwordPlaceholder: 'Please input password',
identityProviderPlaceholder: 'Please select identity provider', identityProviderPlaceholder: 'Please select identity provider',
tenantPlaceholder: 'Please select Tenant',
smsPlaceholder: 'Please input sms code', smsPlaceholder: 'Please input sms code',
mobilePlaceholder: 'Please input mobile', mobilePlaceholder: 'Please input mobile',
policyPlaceholder: 'Register after checking', policyPlaceholder: 'Register after checking',

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

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

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

@ -1,7 +1,39 @@
<template> <template>
<div :class="prefixCls" class="login-background-img"> <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"/> <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 v-if="!getIsMobile" class="aui-logo">
<div> <div>
<h3> <h3>
@ -198,6 +230,10 @@
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { useAppInject } from '/@/hooks/web/useAppInject'; import { useAppInject } from '/@/hooks/web/useAppInject';
import { GithubFilled, WechatFilled, AlipayCircleFilled, DingtalkCircleFilled } from '@ant-design/icons-vue'; 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({ defineProps({
sessionTimeout: { sessionTimeout: {
@ -225,12 +261,19 @@
inputCode: '', inputCode: '',
username: '', username: '',
password: '', password: '',
identityProvider: [],
tenantId: [],
}); });
// //
const phoneFormData = reactive<any>({ const phoneFormData = reactive<any>({
mobile: '', mobile: '',
smscode: '', smscode: '',
}); });
//
const options = reactive<any>({
identityProviderList: [],
tenantIdList: []
});
const loginRef = ref(); const loginRef = ref();
// //
const codeRef = ref(); const codeRef = ref();
@ -293,6 +336,10 @@
createMessage.warn(t('sys.login.smsPlaceholder')); createMessage.warn(t('sys.login.smsPlaceholder'));
return; return;
} }
if (!formData.tenantId[0]) {
createMessage.warn(t('sys.login.tenantPlaceholder'));
return;
}
try { try {
loginLoading.value = true; loginLoading.value = true;
const userInfo = await userStore.login(toRaw({ const userInfo = await userStore.login(toRaw({
@ -300,6 +347,8 @@
username: formData.username, username: formData.username,
realKey: formData.realKey, realKey: formData.realKey,
code: formData.inputCode, code: formData.inputCode,
identityProvider: formData.identityProvider[0],
tenantId: formData.tenantId[0],
})); }));
if (userInfo) { if (userInfo) {
notification.success({ notification.success({
@ -412,9 +461,36 @@
}, 300); }, 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> </script>

Loading…
Cancel
Save