Browse Source

Merge pull request #1230 from colinin/fix-single

fix(single): 修复单体项目Mvc页面数据错误
pull/1238/head
yx lin 1 year ago
committed by GitHub
parent
commit
ada4f0ae22
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 14
      aspnet-core/services/LY.MicroService.Applications.Single/Bundling/SingleGlobalScriptContributor.cs
  2. 7
      aspnet-core/services/LY.MicroService.Applications.Single/GlobalUsings.cs
  3. 89
      aspnet-core/services/LY.MicroService.Applications.Single/Messages/PlatformEmailSettingsAppService.cs
  4. 15
      aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs
  5. 10
      aspnet-core/services/LY.MicroService.Applications.Single/gulpfile.js
  6. 11
      aspnet-core/services/LY.MicroService.Applications.Single/wwwroot/scripts/abp-wrapper.js

14
aspnet-core/services/LY.MicroService.Applications.Single/Bundling/SingleGlobalScriptContributor.cs

@ -0,0 +1,14 @@
using Volo.Abp.AspNetCore.Mvc.UI.Packages.JQuery;
namespace LY.MicroService.Applications.Single.Bundling;
[DependsOn(typeof(JQueryScriptContributor))]
public class SingleGlobalScriptContributor : BundleContributor
{
public override Task ConfigureBundleAsync(BundleConfigurationContext context)
{
context.Files.Add("/scripts/abp-wrapper.js");
return Task.CompletedTask;
}
}

7
aspnet-core/services/LY.MicroService.Applications.Single/GlobalUsings.cs

@ -52,6 +52,7 @@ global using LINGYUN.Abp.Identity.AspNetCore.Session;
global using LINGYUN.Abp.Identity.EntityFrameworkCore;
global using LINGYUN.Abp.Identity.Notifications;
global using LINGYUN.Abp.Identity.OrganizaztionUnits;
global using LINGYUN.Abp.Identity.QrCode;
global using LINGYUN.Abp.Identity.Session;
global using LINGYUN.Abp.Identity.Session.AspNetCore;
global using LINGYUN.Abp.Identity.WeChat;
@ -126,6 +127,7 @@ global using LINGYUN.Platform.HttpApi;
global using LINGYUN.Platform.Localization;
global using LINGYUN.Platform.Settings.VueVbenAdmin;
global using LINGYUN.Platform.Theme.VueVbenAdmin;
global using LY.MicroService.Applications.Single.Bundling;
global using LY.MicroService.Applications.Single.EntityFrameworkCore.MySql;
//global using LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer;
global using LY.MicroService.Applications.Single.Messages;
@ -134,14 +136,17 @@ global using Medallion.Threading.Redis;
global using Microsoft.AspNetCore.Authentication.JwtBearer;
global using Microsoft.AspNetCore.Cors;
global using Microsoft.AspNetCore.DataProtection;
global using Microsoft.AspNetCore.Extensions.DependencyInjection;
global using Microsoft.AspNetCore.Identity;
global using Microsoft.AspNetCore.Server.Kestrel.Core;
global using Microsoft.Extensions.Caching.StackExchangeRedis;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.IdentityModel.Logging;
global using Microsoft.OpenApi.Models;
global using MiniExcelLibs.Attributes;
global using OpenIddict.Server;
global using OpenIddict.Server.AspNetCore;
global using OpenIddict.Validation.AspNetCore;
global using Quartz;
global using StackExchange.Redis;
global using System.Security.Cryptography;
@ -155,12 +160,14 @@ global using Volo.Abp.AspNetCore.Mvc.AntiForgery;
global using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
//global using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
global using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite;
global using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling;
global using Volo.Abp.AspNetCore.Serilog;
global using Volo.Abp.Auditing;
global using Volo.Abp.Authorization.Permissions;
global using Volo.Abp.Autofac;
global using Volo.Abp.BlobStoring;
global using Volo.Abp.BlobStoring.FileSystem;
global using Volo.Abp.BlobStoring.Minio;
global using Volo.Abp.Caching;
global using Volo.Abp.Caching.StackExchangeRedis;
global using Volo.Abp.Data;

89
aspnet-core/services/LY.MicroService.Applications.Single/Messages/PlatformEmailSettingsAppService.cs

@ -0,0 +1,89 @@
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Emailing;
using SendTestEmailInput = Volo.Abp.SettingManagement.SendTestEmailInput;
using SettingManagementPermissions = Volo.Abp.SettingManagement.SettingManagementPermissions;
namespace LY.MicroService.Applications.Single.Messages;
[Authorize(SettingManagementPermissions.Emailing)]
public class PlatformEmailSettingsAppService : SettingManagementAppServiceBase, IEmailSettingsAppService
{
protected ISettingManager SettingManager { get; }
protected IEmailSender EmailSender { get; }
public PlatformEmailSettingsAppService(ISettingManager settingManager, IEmailSender emailSender)
{
SettingManager = settingManager;
EmailSender = emailSender;
}
public virtual async Task<EmailSettingsDto> GetAsync()
{
await CheckFeatureAsync();
var settingsDto = new EmailSettingsDto
{
SmtpHost = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Host),
SmtpPort = Convert.ToInt32(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Port)),
SmtpUserName = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.UserName),
SmtpDomain = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Domain),
SmtpEnableSsl = Convert.ToBoolean(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.EnableSsl)),
SmtpUseDefaultCredentials = Convert.ToBoolean(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.UseDefaultCredentials)),
DefaultFromAddress = await SettingProvider.GetOrNullAsync(EmailSettingNames.DefaultFromAddress),
DefaultFromDisplayName = await SettingProvider.GetOrNullAsync(EmailSettingNames.DefaultFromDisplayName),
};
if (CurrentTenant.IsAvailable)
{
settingsDto.SmtpHost = await SettingManager.GetOrNullForTenantAsync(EmailSettingNames.Smtp.Host, CurrentTenant.GetId(), false);
settingsDto.SmtpUserName = await SettingManager.GetOrNullForTenantAsync(EmailSettingNames.Smtp.UserName, CurrentTenant.GetId(), false);
settingsDto.SmtpDomain = await SettingManager.GetOrNullForTenantAsync(EmailSettingNames.Smtp.Domain, CurrentTenant.GetId(), false);
}
return settingsDto;
}
public virtual async Task UpdateAsync(UpdateEmailSettingsDto input)
{
await CheckFeatureAsync();
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Host, input.SmtpHost);
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Port, input.SmtpPort.ToString());
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.UserName, input.SmtpUserName);
if (!input.SmtpPassword.IsNullOrWhiteSpace())
{
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Password, input.SmtpPassword);
}
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.Domain, input.SmtpDomain);
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.EnableSsl, input.SmtpEnableSsl.ToString());
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.Smtp.UseDefaultCredentials, input.SmtpUseDefaultCredentials.ToString().ToLowerInvariant());
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.DefaultFromAddress, input.DefaultFromAddress);
await SettingManager.SetForTenantOrGlobalAsync(CurrentTenant.Id, EmailSettingNames.DefaultFromDisplayName, input.DefaultFromDisplayName);
}
[Authorize(SettingManagementPermissions.EmailingTest)]
public virtual async Task SendTestEmailAsync(SendTestEmailInput input)
{
await CheckFeatureAsync();
try
{
await EmailSender.SendAsync(input.SenderEmailAddress, input.TargetEmailAddress, input.Subject, input.Body);
}
catch (Exception e)
{
Logger.LogError("Error sending test email: " + e);
throw new UserFriendlyException(L["MailSendingFailed"]);
}
}
protected virtual async Task CheckFeatureAsync()
{
await FeatureChecker.CheckEnabledAsync(SettingManagementFeatures.Enable);
if (CurrentTenant.IsAvailable)
{
await FeatureChecker.CheckEnabledAsync(SettingManagementFeatures.AllowChangingEmailSettings);
}
}
}

15
aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs

@ -1,9 +1,3 @@
using LINGYUN.Abp.Identity.QrCode;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using OpenIddict.Validation.AspNetCore;
using Volo.Abp.BlobStoring.Minio;
using VoloAbpExceptionHandlingOptions = Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingOptions;
namespace LY.MicroService.Applications.Single;
@ -773,6 +767,15 @@ public partial class MicroServiceApplicationsSingleModule
private void ConfigureSingleModule(IServiceCollection services, bool isDevelopment)
{
Configure<AbpBundlingOptions>(options =>
{
options.ScriptBundles
.Configure(StandardBundles.Styles.Global, bundle =>
{
bundle.AddContributors(typeof(SingleGlobalScriptContributor));
});
});
Configure<AbpAspNetCoreMvcOptions>(options =>
{
// 允许第三方调用集成服务

10
aspnet-core/services/LY.MicroService.Applications.Single/gulpfile.js

@ -1,10 +0,0 @@
"use strict";
var gulp = require("gulp"),
path = require('path'),
copyResources = require('./node_modules/@abp/aspnetcore.mvc.ui/gulp/copy-resources.js');
exports.default = function(done){
copyResources(path.resolve('./'));
done();
};

11
aspnet-core/services/LY.MicroService.Applications.Single/wwwroot/scripts/abp-wrapper.js

@ -0,0 +1,11 @@
var abp = abp || {};
(function ($) {
if (!abp.ajax || !abp.ajax.defaultOpts) {
throw "abp/jquery library requires the jquery library included to the page!";
}
var headers = abp.ajax.defaultOpts.headers || {};
headers['_abpdontwrapresult'] = 'true';
})(jQuery);
Loading…
Cancel
Save