Browse Source

Merge pull request #657 from colinin/upt-5.3.2

fix: fix PermissionModal
pull/712/head
yx lin 3 years ago
committed by GitHub
parent
commit
b080ea8219
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 130
      apps/vue/src/components/Permission/src/PermissionModal.vue
  2. 20
      gateways/web/LY.MicroService.ApiGateway/InternalApiGatewayModule.cs
  3. 126
      gateways/web/LY.MicroService.ApiGateway/InternalApiGatewayOptions.cs
  4. 9
      gateways/web/LY.MicroService.ApiGateway/Properties/launchSettings.json
  5. 6
      gateways/web/LY.MicroService.ApiGateway/yarp.json

130
apps/vue/src/components/Permission/src/PermissionModal.vue

@ -59,16 +59,18 @@
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { computed, defineComponent, ref } from 'vue'; import { computed, ref } from 'vue';
import { message } from 'ant-design-vue';
import { Card, Checkbox, Col, Divider, Row, Tabs } from 'ant-design-vue'; import { Card, Checkbox, Col, Divider, Row, Tabs } from 'ant-design-vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { useLocalization } from '/@/hooks/abp/useLocalization'; import { useLocalization } from '/@/hooks/abp/useLocalization';
import { BasicModal, useModalInner } from '/@/components/Modal'; import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTree } from '/@/components/Tree'; import { BasicTree } from '/@/components/Tree';
import { usePermissions } from './hooks/usePermissions'; import { usePermissions } from './hooks/usePermissions';
import { PermissionProps } from './types/permission'; import { PermissionProps } from './types/permission';
const TabPane = Tabs.TabPane;
const defaultProps: PermissionProps = { const defaultProps: PermissionProps = {
providerName: 'G', providerName: 'G',
providerKey: '', providerKey: '',
@ -76,84 +78,50 @@
identity: '', identity: '',
}; };
export default defineComponent({ const { createMessage } = useMessage();
name: 'PermissionModal', const { L } = useLocalization('AbpPermissionManagement');
components: { const activeKey = ref('');
BasicModal, const model = ref<PermissionProps>(defaultProps);
BasicTree, const {
Card, title,
Checkbox, permissionTree,
Divider, permissionTab,
Col, permissionGrantKeys,
Row, permissionTabCheckState,
Tabs, permissionTreeCheckState,
TabPane: Tabs.TabPane, permissionTreeDisabled,
}, handlePermissionGranted,
setup() { handleSavePermission,
const { L } = useLocalization('AbpPermissionManagement'); handleGrantAllPermission,
const activeKey = ref(''); handleGrantPermissions,
const model = ref<PermissionProps>(defaultProps); } = usePermissions({
const { getPropsRef: model,
title, });
permissionTree, const [registerModal, { closeModal, changeOkLoading }] = useModalInner((val) => {
permissionTab, model.value = val;
permissionGrantKeys, });
permissionTabCheckState, const getIdentity = computed(() => {
permissionTreeCheckState, if (model.value.identity) {
permissionTreeDisabled, return `${L('Permissions')} - ${model.value.identity}`;
handlePermissionGranted, }
handleSavePermission, return title.value;
handleGrantAllPermission, });
handleGrantPermissions,
} = usePermissions({
getPropsRef: model,
});
const [registerModal, { closeModal, changeOkLoading }] = useModalInner((val) => {
model.value = val;
});
const getIdentity = computed(() => {
if (model.value.identity) {
return `${L('Permissions')} - ${model.value.identity}`;
}
return title.value;
});
function handleVisibleChange(visible: boolean) {
if (!visible) {
model.value.providerKey = '';
}
}
function handleSubmit() { function handleVisibleChange(visible: boolean) {
changeOkLoading(true); if (!visible) {
handleSavePermission() model.value.providerKey = '';
.then(() => { }
message.success(L('Successful')); }
closeModal();
})
.finally(() => {
changeOkLoading(false);
});
}
return { function handleSubmit() {
L, changeOkLoading(true);
activeKey, handleSavePermission()
title, .then(() => {
getIdentity, createMessage.success(L('Successful'));
permissionTab, closeModal();
permissionTree, })
permissionGrantKeys, .finally(() => {
permissionTabCheckState, changeOkLoading(false);
permissionTreeCheckState, });
permissionTreeDisabled, }
handlePermissionGranted,
handleGrantAllPermission,
handleGrantPermissions,
registerModal,
handleSubmit,
handleVisibleChange,
};
},
});
</script> </script>

20
gateways/web/LY.MicroService.ApiGateway/InternalApiGatewayModule.cs

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Builder; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Rewrite; using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@ -23,7 +24,8 @@ namespace LY.MicroService.ApiGateway;
typeof(AbpAutofacModule), typeof(AbpAutofacModule),
typeof(AbpDataModule), typeof(AbpDataModule),
typeof(AbpSwashbuckleModule), typeof(AbpSwashbuckleModule),
typeof(AbpAspNetCoreSerilogModule) typeof(AbpAspNetCoreSerilogModule),
typeof(AbpAspNetCoreMvcWrapperModule)
)] )]
public class InternalApiGatewayModule : AbpModule public class InternalApiGatewayModule : AbpModule
{ {
@ -32,6 +34,18 @@ public class InternalApiGatewayModule : AbpModule
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment(); var hostingEnvironment = context.Services.GetHostingEnvironment();
Configure<InternalApiGatewayOptions>(options =>
{
options.Aggregator.ConfigurationUrl.ClientName = "_Abp_Application_Configuration";
options.Aggregator.ConfigurationUrl.GetUrls.AddIfNotContains(new RequestUrl("http://10.21.15.28:30010"));
options.Aggregator.ConfigurationUrl.GetUrls.AddIfNotContains(new RequestUrl("http://10.21.15.28:30015"));
options.Aggregator.ConfigurationUrl.GetUrls.AddIfNotContains(new RequestUrl("http://10.21.15.28:30020"));
options.Aggregator.ConfigurationUrl.GetUrls.AddIfNotContains(new RequestUrl("http://10.21.15.28:30025"));
options.Aggregator.ConfigurationUrl.GetUrls.AddIfNotContains(new RequestUrl("http://10.21.15.28:30030"));
options.Aggregator.ConfigurationUrl.GetUrls.AddIfNotContains(new RequestUrl("http://10.21.15.28:30035"));
options.Aggregator.ConfigurationUrl.GetUrls.AddIfNotContains(new RequestUrl("http://10.21.15.28:30040"));
});
context.Services.AddAbpSwaggerGenWithOAuth( context.Services.AddAbpSwaggerGenWithOAuth(
authority: configuration["AuthServer:Authority"], authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string> scopes: new Dictionary<string, string>
@ -128,7 +142,7 @@ public class InternalApiGatewayModule : AbpModule
app.UseRewriter(new RewriteOptions().AddRedirect("^(|\\|\\s+)$", "/swagger")); app.UseRewriter(new RewriteOptions().AddRedirect("^(|\\|\\s+)$", "/swagger"));
app.UseRouting(); app.UseRouting();
app.UseEndpoints(endpoints => app.UseConfiguredEndpoints(endpoints =>
{ {
endpoints.MapReverseProxy(options => endpoints.MapReverseProxy(options =>
options.UseLoadBalancing()); options.UseLoadBalancing());

126
gateways/web/LY.MicroService.ApiGateway/InternalApiGatewayOptions.cs

@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
namespace LY.MicroService.ApiGateway
{
public class InternalApiGatewayOptions
{
public Aggregator Aggregator { get; set; }
public InternalApiGatewayOptions()
{
Aggregator = new Aggregator();
}
}
public class Aggregator
{
/// <summary>
/// 设置聚合路由
/// </summary>
/// <remarks>
/// 聚合路由:
/// /api/setting-management/settings
/// </remarks>
/// <example>
/// 宿主端路由:
/// Get: /api/setting-management/settings/by-global
/// Set: /api/setting-management/settings/change-global
/// </example>
/// <example>
/// 租户端路由:
/// Get: /api/setting-management/settings/by-current-tenant
/// Set: /api/setting-management/settings/change-current-tenant
/// </example>
/// <example>
/// 用户端路由:
/// Get: /api/setting-management/settings/by-current-user
/// Set: /api/setting-management/settings/change-current-user
/// </example>
public AggregatorUrl SettingUrl { get; set; }
/// <summary>
/// 应用配置聚合路由
/// </summary>
/// <remarks>
/// 聚合路由:
/// /api/abp/application-configuration
/// </remarks>
public AggregatorUrl ConfigurationUrl { get; set; }
/// <summary>
/// Api接口定义配置聚合路由
/// </summary>
/// <remarks>
/// 聚合路由:
/// /api/abp/api-definition
/// </remarks>
public AggregatorUrl ApiDefinitionUrl { get; set; }
public Aggregator()
{
SettingUrl = new AggregatorUrl();
ConfigurationUrl = new AggregatorUrl();
ApiDefinitionUrl = new AggregatorUrl();
}
}
public class AggregatorUrl
{
public string ClientName { get; set; }
public HttpHandlerOptions HttpHandler { get; set; }
/// <summary>
/// 查询聚合路由列表
/// </summary>
public List<RequestUrl> GetUrls { get; set; }
/// <summary>
/// 变更路由
/// </summary>
public RequestUrl SetUrl { get; set; }
/// <summary>
/// 默认超时时间
/// </summary>
/// <remarks>
/// default: 30s
/// </remarks>
public TimeSpan? DefaultTimeout { get; set; }
public AggregatorUrl()
{
HttpHandler = new HttpHandlerOptions();
GetUrls = new List<RequestUrl>();
DefaultTimeout = TimeSpan.FromSeconds(30);
}
}
public class RequestUrl
{
public HttpMethod Method { get; set; }
public string Url { get; set; }
public RequestUrl()
{
Method = HttpMethod.Get;
}
public RequestUrl(string url)
: this(HttpMethod.Get, url)
{
}
public RequestUrl(
HttpMethod method,
string url)
{
Method = method;
Url = url;
}
}
public class HttpHandlerOptions
{
public bool AllowAutoRedirect { get; set; }
public bool UseCookieContainer { get; set; }
public bool UseTracing { get; set; }
public bool UseProxy { get; set; }
public int MaxConnectionsPerServer { get; set; }
}
}

9
gateways/web/LY.MicroService.ApiGateway/Properties/launchSettings.json

@ -8,7 +8,7 @@
} }
}, },
"profiles": { "profiles": {
"PackageName.CompanyName.ProjectName.HttpApi.Host": { "LY.MicroService.ApiGateway": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": false, "launchBrowser": false,
"environmentVariables": { "environmentVariables": {
@ -16,13 +16,6 @@
}, },
"applicationUrl": "http://localhost:5000", "applicationUrl": "http://localhost:5000",
"dotnetRunMessages": "true" "dotnetRunMessages": "true"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
} }
} }
} }

6
gateways/web/LY.MicroService.ApiGateway/yarp.json

@ -19,12 +19,6 @@
"Path": "/api/identity-server/{**everything}" "Path": "/api/identity-server/{**everything}"
} }
}, },
"BackendAdmin": {
"ClusterId": "backendAdminCluster",
"Match": {
"Path": "/api/abp/{**everything}"
}
},
"feature-management-route": { "feature-management-route": {
"ClusterId": "feature-management-cluster", "ClusterId": "feature-management-cluster",
"Match": { "Match": {

Loading…
Cancel
Save