Browse Source

✨ 添加id4 ui

pull/10/head
王军 5 years ago
parent
commit
b1ebad5176
  1. 8
      aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerApiResourceManager.cs
  2. 32
      aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerClientManager.cs
  3. 7528
      aspnet-core/services/src/CompanyName.ProjectName.HttpApi.Host/Logs/logs.txt
  4. 4
      vben271/src/main.ts
  5. 6
      vben271/src/views/admin/users/EditAbpUser.vue
  6. 65
      vben271/src/views/identityServers/apiResources/EditApiResources.vue
  7. 155
      vben271/src/views/identityServers/clients/ClientUri.vue
  8. 50
      vben271/src/views/identityServers/clients/Clients.ts
  9. 34
      vben271/src/views/identityServers/clients/Clients.vue
  10. 16
      vben271/src/views/identityServers/clients/EditClientBasic.vue

8
aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerApiResourceManager.cs

@ -127,8 +127,12 @@ namespace CompanyName.ProjectName.IdentityServer
}
apiResource.Scopes.Clear();
scopes?.Distinct().ToList().ForEach(item => { apiResource.AddScope(item); });
foreach (var item in scopes)
{
apiResource.AddScope(item);
}
return await _apiResourceRepository.UpdateAsync(apiResource, cancellationToken: cancellationToken);

32
aspnet-core/services/src/CompanyName.ProjectName.Domain/IdentityServer/IdenityServerClientManager.cs

@ -163,7 +163,7 @@ namespace CompanyName.ProjectName.IdentityServer
public async Task<Client> UpdateScopesAsync(string clientId, List<string> scopes)
{
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: "Client不存在");
if (client == null) throw new UserFriendlyException(message: $"{clientId}不存在");
client.RemoveAllScopes();
scopes.ForEach(item => { client.AddScope(item.Trim()); });
@ -178,13 +178,15 @@ namespace CompanyName.ProjectName.IdentityServer
uri = uri.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: $"{clientId}不存在");
if (client.RedirectUris.Any(e => e.RedirectUri != uri.Trim()))
if (client.RedirectUris.Any(e => e.RedirectUri == uri.Trim()))
{
return client;
}
else
{
client.AddRedirectUri(uri);
return await _clientRepository.UpdateAsync(client);
}
return client;
}
/// <summary>
@ -200,8 +202,10 @@ namespace CompanyName.ProjectName.IdentityServer
client.RemoveRedirectUri(uri);
return await _clientRepository.UpdateAsync(client);
}
return client;
else
{
return client;
}
}
/// <summary>
@ -212,13 +216,13 @@ namespace CompanyName.ProjectName.IdentityServer
uri = uri.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: $"{clientId}不存在");
if (client.PostLogoutRedirectUris.Any(e => e.PostLogoutRedirectUri != uri))
if (client.PostLogoutRedirectUris.Any(e => e.PostLogoutRedirectUri == uri))
{
client.AddPostLogoutRedirectUri(uri);
await _clientRepository.UpdateAsync(client);
return client;
}
return client;
client.AddPostLogoutRedirectUri(uri);
return await _clientRepository.UpdateAsync(client);
}
/// <summary>
@ -246,13 +250,15 @@ namespace CompanyName.ProjectName.IdentityServer
origin = origin.Trim();
var client = await _clientRepository.FindByClientIdAsync(clientId);
if (client == null) throw new UserFriendlyException(message: $"{clientId}不存在");
if (client.AllowedCorsOrigins.Any(e => e.Origin != origin))
if (client.AllowedCorsOrigins.Any(e => e.Origin == origin))
{
return client;
}
else
{
client.AddCorsOrigin(origin);
return await _clientRepository.UpdateAsync(client);
}
return client;
}
/// <summary>

7528
aspnet-core/services/src/CompanyName.ProjectName.HttpApi.Host/Logs/logs.txt

File diff suppressed because it is too large

4
vben271/src/main.ts

@ -14,7 +14,7 @@ import { setupStore } from '/@/store';
import { setupGlobDirectives } from '/@/directives';
import { setupI18n } from '/@/locales/setupI18n';
import { registerGlobComp } from '/@/components/registerGlobComp';
import Antd from 'ant-design-vue';
// Do not introduce on-demand in local development?
// In the local development for introduce on-demand, the number of browser requests will increase by about 20%.
// Which may slow down the browser refresh.
@ -25,7 +25,7 @@ if (import.meta.env.DEV) {
async function bootstrap() {
const app = createApp(App);
app.use(Antd);
// Configure store
setupStore(app);

6
vben271/src/views/admin/users/EditAbpUser.vue

@ -17,12 +17,6 @@
<BasicForm @register="registerUserForm" />
</TabPane>
<TabPane tab="角色" key="2">
<!-- <a-checkbox-group @change="onRoleSelectedChange" v-model:value="defaultRolesRef">
<a-checkbox v-for="(item, index) in rolesRef" :key="index" :value="item.name">
{{ item.name }}
</a-checkbox>
</a-checkbox-group> -->
<a-checkbox-group v-model:value="defaultRolesRef">
<a-row justify="center">
<a-col :span="24">

65
vben271/src/views/identityServers/apiResources/EditApiResources.vue

@ -13,8 +13,20 @@
<TabPane tab="基本信息" key="1">
<BasicForm @register="registerBasicInfoForm" />
</TabPane>
<TabPane tab="ApiScopes" key="2" forceRender>
<BasicForm @register="registerApiScopeForm" />
<TabPane tab="ApiScopes" key="2">
<a-checkbox-group v-model:value="defaultApiScope">
<a-row justify="center">
<a-col :span="24">
<a-checkbox
style="width: 150px"
v-for="(item, index) in apiScopes"
:key="index"
:value="item.value"
>{{ item.label }}</a-checkbox
>
</a-col>
</a-row>
</a-checkbox-group>
</TabPane>
</Tabs>
</div>
@ -22,17 +34,12 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { defineComponent, reactive, toRefs } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { Tabs } from 'ant-design-vue';
import {
editFormSchema,
editApiScopeSchema,
getAllApiScopeAsync,
updateApiResourceAsync,
} from './ApiResources';
import { editFormSchema, getAllApiScopeAsync, updateApiResourceAsync } from './ApiResources';
import { StringStringFromSelector } from '/@/services/ServiceProxies';
export default defineComponent({
name: 'EditApiResources',
components: {
@ -55,19 +62,16 @@
schemas: editFormSchema,
showActionButtonGroup: false,
});
const [
registerApiScopeForm,
{
getFieldsValue: getFieldsApiScopeValue,
validate: apiScopeValidate,
updateSchema: updateApiScopeSchema,
},
] = useForm({
labelWidth: 120,
schemas: editApiScopeSchema,
showActionButtonGroup: false,
let currentApiResuource: any;
let apiScopes: StringStringFromSelector[] = [];
const state = reactive({
defaultApiScope: [],
apiScopes,
});
const [registerModal, { changeOkLoading, closeModal }] = useModalInner(async (data) => {
currentApiResuource = data;
setBasicInfoFieldsValue({
name: data.record.name,
displayName: data.record.displayName,
@ -77,32 +81,23 @@
showInDiscoveryDocument: data.record.showInDiscoveryDocument,
});
let apiScopes = await getAllApiScopeAsync();
const defaultApiScopes = data.record.scopes.map((e) => e.scope);
console.log(defaultApiScopes);
updateApiScopeSchema([
{
field: 'apiScopes',
defaultValue: defaultApiScopes,
componentProps: { options: apiScopes },
},
]);
state.apiScopes = await getAllApiScopeAsync();
state.defaultApiScope = data.record.scopes.map((e) => e.scope);
});
const submit = async () => {
await basicInfoValidate();
await apiScopeValidate();
var basicInfo = getFieldsBasicInfoValue();
var apiScope = getFieldsApiScopeValue();
var request = Object.assign(basicInfo, apiScope);
let requestScope = { apiScopes: state.defaultApiScope };
var request = Object.assign(basicInfo, requestScope);
await updateApiResourceAsync({ request, changeOkLoading, closeModal });
emit('reload');
};
return {
registerModal,
registerBasicInfoForm,
registerApiScopeForm,
submit,
...toRefs(state),
};
},
});

155
vben271/src/views/identityServers/clients/ClientUri.vue

@ -0,0 +1,155 @@
<template>
<BasicDrawer v-bind="$attrs" @register="register" title="Uri" width="30%">
<Tabs>
<TabPane tab="RedirectUri" key="1">
<a-input
placeholder="Please Enter Uri"
style="width: 470px"
v-model:value="redirectUriValue"
/>
<a-button type="primary" @click="handleAddRedirectUri" style="margin-bottom: 10px"
>新增</a-button
>
<div v-for="item in currentClient.redirectUris">
<a-input placeholder="" style="width: 470px" :defaultValue="item.redirectUri" disabled />
<a-button type="primary" @click="handleRemoveRedirectUri(item.redirectUri)" danger
>删除</a-button
>
</div>
</TabPane>
<TabPane tab="LogoutRedirectUri" key="2" forceRender>
<a-input
placeholder="Please Enter Uri"
style="width: 470px"
v-model:value="postLogoutRedirectUriValue"
/>
<a-button type="primary" @click="handleAddLogoutRedirectUri" style="margin-bottom: 10px"
>新增</a-button
>
<div v-for="item in currentClient.postLogoutRedirectUris">
<a-input
placeholder=""
style="width: 470px"
:defaultValue="item.postLogoutRedirectUri"
disabled
/>
<a-button
type="primary"
@click="handleRemoveLogoutRedirectUri(item.postLogoutRedirectUris)"
danger
>删除</a-button
>
</div>
</TabPane>
<TabPane tab="CORS" key="3" forceRender>
<a-input placeholder="Please Enter Uri" style="width: 470px" v-model:value="originValue" />
<a-button type="primary" @click="handleAddCors" style="margin-bottom: 10px">新增</a-button>
<div v-for="item in currentClient.allowedCorsOrigins">
<a-input placeholder="" style="width: 470px" :defaultValue="item.origin" disabled />
<a-button type="primary" @click="handleRemoveCors(item.origin)" danger>删除</a-button>
</div>
</TabPane>
</Tabs>
</BasicDrawer>
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs } from 'vue';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { Tabs } from 'ant-design-vue';
import {
addRedirectUriAsync,
removeRedirectUriAsync,
addLogoutRedirectUriAsync,
removeLogoutRedirectUriAsync,
addCorsAsync,
removeCorsAsync,
} from './Clients';
import { PagingClientListOutput } from '/@/services/ServiceProxies';
export default defineComponent({
name: 'ClientUri',
components: { BasicDrawer, Tabs, TabPane: Tabs.TabPane },
emits: ['reload'],
setup(_, { emit }) {
let currentClient: PagingClientListOutput = new PagingClientListOutput();
const state = reactive({
redirectUriValue: '',
postLogoutRedirectUriValue: '',
originValue: '',
currentClient,
});
const [register, { closeDrawer }] = useDrawerInner((data) => {
state.currentClient = data.record;
console.log(state);
});
const handleAddRedirectUri = async () => {
if (state.redirectUriValue) {
await addRedirectUriAsync({
clientId: state.currentClient.clientId,
uri: state.redirectUriValue,
});
closeDrawer();
emit('reload');
}
};
const handleRemoveRedirectUri = async (redirectUri: string) => {
await removeRedirectUriAsync({
clientId: state.currentClient.clientId,
uri: redirectUri,
});
closeDrawer();
emit('reload');
};
const handleAddLogoutRedirectUri = async () => {
await addLogoutRedirectUriAsync({
clientId: state.currentClient.clientId,
uri: state.postLogoutRedirectUriValue,
});
closeDrawer();
emit('reload');
};
const handleRemoveLogoutRedirectUri = async (redirectUri: string) => {
await removeLogoutRedirectUriAsync({
clientId: state.currentClient.clientId,
uri: redirectUri,
});
closeDrawer();
emit('reload');
};
const handleAddCors = async () => {
await addCorsAsync({
clientId: state.currentClient.clientId,
origin: state.originValue,
});
closeDrawer();
emit('reload');
};
const handleRemoveCors = async (origin: string) => {
await removeCorsAsync({
clientId: state.currentClient.clientId,
origin: origin,
});
closeDrawer();
emit('reload');
};
return {
register,
handleAddRedirectUri,
handleRemoveRedirectUri,
handleAddLogoutRedirectUri,
handleRemoveLogoutRedirectUri,
handleAddCors,
handleRemoveCors,
...toRefs(state),
};
},
});
</script>

50
vben271/src/views/identityServers/clients/Clients.ts

@ -8,6 +8,10 @@ import {
EnabledInput,
IdInput,
PagingClientListInput,
AddRedirectUriInput,
RemoveRedirectUriInput,
AddCorsInput,
RemoveCorsInput,
} from '/@/services/ServiceProxies';
export const searchFormSchema: FormSchema[] = [
@ -345,3 +349,49 @@ export async function enabledClientAsync({ clientId, enabled, reload }) {
await _clientServiceProxy.enabled(request);
reload();
}
export async function addRedirectUriAsync({ clientId, uri }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new AddRedirectUriInput();
request.clientId = clientId;
request.uri = uri;
return await _clientServiceProxy.addRedirectUri(request);
}
export async function removeRedirectUriAsync({ clientId, uri }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new RemoveRedirectUriInput();
request.clientId = clientId;
request.uri = uri;
return await _clientServiceProxy.removeRedirectUri(request);
}
export async function addLogoutRedirectUriAsync({ clientId, uri }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new RemoveRedirectUriInput();
request.clientId = clientId;
request.uri = uri;
return await _clientServiceProxy.addLogoutRedirectUri(request);
}
export async function removeLogoutRedirectUriAsync({ clientId, uri }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new RemoveRedirectUriInput();
request.clientId = clientId;
request.uri = uri;
return await _clientServiceProxy.removeLogoutRedirectUri(request);
}
export async function addCorsAsync({ clientId, origin }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new AddCorsInput();
request.clientId = clientId;
request.origin = origin;
return await _clientServiceProxy.addCors(request);
}
export async function removeCorsAsync({ clientId, origin }) {
const _clientServiceProxy = new ClientServiceProxy();
let request = new RemoveCorsInput();
request.clientId = clientId;
request.origin = origin;
return await _clientServiceProxy.removeCors(request);
}

34
vben271/src/views/identityServers/clients/Clients.vue

@ -20,26 +20,45 @@
<a-button type="link" size="small" @click="handleEnabled(record)">
{{ record.enabled ? '禁用' : '启用' }}
</a-button>
<a-button type="link" size="small" @click="handleUri(record)"> Uri </a-button>
<a-button type="link" size="small" @click="handleDelete(record)">
{{ t('common.delText') }}
</a-button>
</template>
</BasicTable>
<CreateClient @register="registerCreateClientModal" @reload="reload" :bodyStyle="{ 'padding-top': '0' }" />
<EditClientBasic @register="registerEditClientModal" @reload="reload" :bodyStyle="{ 'padding-top': '0' }" />
<CreateClient
@register="registerCreateClientModal"
@reload="reload"
:bodyStyle="{ 'padding-top': '0' }"
/>
<EditClientBasic
@register="registerEditClientModal"
@reload="reload"
:bodyStyle="{ 'padding-top': '0' }"
/>
<ClientUri @register="registerUriDrawer" @reload="reload" :bodyStyle="{ 'padding-top': '0' }" />
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { tableColumns, searchFormSchema, getTableListAsync, deleteClientAsync, enabledClientAsync } from './Clients';
import {
tableColumns,
searchFormSchema,
getTableListAsync,
deleteClientAsync,
enabledClientAsync,
} from './Clients';
import { useI18n } from '/@/hooks/web/useI18n';
import { Tag } from 'ant-design-vue';
import CreateClient from './CreateClient.vue';
import EditClientBasic from './EditClientBasic.vue';
import ClientUri from './ClientUri.vue';
import { useModal } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage';
import { useDrawer } from '/@/components/Drawer';
export default defineComponent({
name: 'Clients',
components: {
@ -48,6 +67,7 @@
Tag,
CreateClient,
EditClientBasic,
ClientUri,
},
setup() {
const { t } = useI18n();
@ -66,7 +86,7 @@
canResize: true,
showIndexColumn: true,
actionColumn: {
width: 150,
width: 300,
title: t('common.action'),
dataIndex: 'action',
slots: {
@ -97,6 +117,10 @@
const handleEnabled = async (record: Recordable) => {
await enabledClientAsync({ clientId: record.clientId, enabled: !record.enabled, reload });
};
const [registerUriDrawer, { openDrawer: openUriDrawer }] = useDrawer();
const handleUri = async (record: Recordable) => {
openUriDrawer(true, { record: record });
};
return {
registerTable,
registerCreateClientModal,
@ -108,6 +132,8 @@
handleEdit,
handleDelete,
handleEnabled,
handleUri,
registerUriDrawer,
};
},
});

16
vben271/src/views/identityServers/clients/EditClientBasic.vue

@ -50,9 +50,6 @@
},
emits: ['reload'],
setup(_, { emit }) {
// 加载父组件方法
// defineEmit(['reload']);
const [
registerDetailForm,
{
@ -146,19 +143,6 @@
}
});
// const visibleChange = async (visible: boolean) => {
// if (visible) {
// detailValidate();
// optionValidate();
// tokenValidate();
// secretValidate();
// getFieldsTokenValue();
// getFieldsSecretValue();
// getFieldsOptionValue();
// getFieldsDetailValue();
// }
// };
const submit = async () => {
await detailValidate();
await optionValidate();

Loading…
Cancel
Save