diff --git a/Server/Server/Bootstrapper.cs b/Server/Server/Bootstrapper.cs index ee6feb4b..ede3fd4a 100644 --- a/Server/Server/Bootstrapper.cs +++ b/Server/Server/Bootstrapper.cs @@ -25,7 +25,11 @@ protected override void ConfigureIoC(IStyletIoCBuilder builder) // 注册 IoC var userConfig = new UserConfig(); builder.Bind<UserConfig>().ToInstance(userConfig); - builder.Bind<LiteDBManager>().ToInstance(new LiteDBManager(userConfig)); + var liteDb = new LiteDBManager(userConfig); + builder.Bind<LiteDBManager>().ToInstance(liteDb); + + // 进行系统层面的初始化 + // 暂无 base.ConfigureIoC(builder); } diff --git a/Server/Server/Database/Models/SendBox.cs b/Server/Server/Database/Models/SendBox.cs index f7582cd1..cf84b662 100644 --- a/Server/Server/Database/Models/SendBox.cs +++ b/Server/Server/Database/Models/SendBox.cs @@ -14,13 +14,13 @@ public class SendBox : EmailInfo /// <summary> /// 发件箱设置 /// </summary> - public SendBoxSetting settings { get; set; } + public SendBoxSetting settings { get; set; } = new SendBoxSetting(); /// <summary> /// 递增发件量 /// </summary> /// <returns>true:可以继续发件;false:发件已达到最大数量</returns> - public bool IncreaseSentCount(LiteDBManager liteDb,Setting globalSetting) + public bool IncreaseSentCount(LiteDBManager liteDb, Setting globalSetting) { // 判断日期是否是今天,如果不是,则将当天发件数置 0 string date = DateTime.Now.ToString("yyyy-MM-dd"); @@ -53,7 +53,7 @@ public class SendBoxSetting public bool asSender { get; set; } = true; // 单日最大发件量 - public int maxEmailsPerDay { get; set; } + public int maxEmailsPerDay { get; set; } = 40; // 总发件量 // 系统自动增加 diff --git a/Server/Server/Database/Models/Setting.cs b/Server/Server/Database/Models/Setting.cs index 14cd73e0..9c052eb6 100644 --- a/Server/Server/Database/Models/Setting.cs +++ b/Server/Server/Database/Models/Setting.cs @@ -9,6 +9,9 @@ namespace Server.Database.Models { public class Setting:AutoObjectId { + /// <summary> + /// 用户名 + /// </summary> public string userId { get; set; } /// <summary> @@ -31,5 +34,23 @@ public class Setting:AutoObjectId // 单日最大发件量 public int maxEmailsPerDay { get; set; } + + /// <summary> + /// 生成默认配置 + /// </summary> + /// <param name="userId"></param> + /// <returns></returns> + public static Setting DefaultSetting(string userId) + { + return new Setting() + { + userId = userId, + maxEmailsPerDay = 40, + isAutoResend = true, + sendInterval_max = 8, + sendInterval_min = 3, + sendWithImageAndHtml = false, + }; + } } } diff --git a/Server/Server/Http/Controller/BaseControllerAsync.cs b/Server/Server/Http/Controller/BaseControllerAsync.cs index 1c90e474..026c9c5c 100644 --- a/Server/Server/Http/Controller/BaseControllerAsync.cs +++ b/Server/Server/Http/Controller/BaseControllerAsync.cs @@ -11,7 +11,7 @@ namespace Server.Http.Controller /// <summary> /// 具有异步的 controller 基类 /// </summary> - public class BaseControllerAsync : BaseController + public abstract class BaseControllerAsync : BaseController { // 异步发送数据 private async Task SendJObjectAsync(object obj) diff --git a/Server/Server/Http/Controller/Ctrler_Report.cs b/Server/Server/Http/Controller/Ctrler_Report.cs index 48d17af6..c16f2a8c 100644 --- a/Server/Server/Http/Controller/Ctrler_Report.cs +++ b/Server/Server/Http/Controller/Ctrler_Report.cs @@ -62,11 +62,21 @@ public async Task GetINboxTypeAndCount() var userId = Token.UserId; // 获取用户发送的历史组 var historyGroups = LiteDb.Fetch<HistoryGroup>(g => g.userId == userId).ToList(); - var defaultValueString = "[{'name':'未发件','value':0}]"; + var defaultResults = new JArray() + { + new JObject(){ { "name","未发件"},{ "value",0} } + }; if (historyGroups.Count < 1) { // 返回默认值 - await ResponseSuccessAsync(JObject.Parse(defaultValueString)); + try + { + await ResponseSuccessAsync(defaultResults); + } + catch (Exception e) + { + ; + } return; }; @@ -76,7 +86,7 @@ public async Task GetINboxTypeAndCount() if (sendItems.Count < 1) { // 返回1 - await ResponseSuccessAsync(JObject.Parse(defaultValueString)); + await ResponseSuccessAsync(defaultResults); return; } diff --git a/Server/Server/Http/Controller/Ctrler_User.cs b/Server/Server/Http/Controller/Ctrler_User.cs index b717027f..a19fa6b0 100644 --- a/Server/Server/Http/Controller/Ctrler_User.cs +++ b/Server/Server/Http/Controller/Ctrler_User.cs @@ -59,6 +59,9 @@ public async Task UserLogin() password = password, createDate = DateTime.Now }); + + // 新建用户后,同时给用户建立默认配置 + LiteDb.Insert(Setting.DefaultSetting(userId)); } else { diff --git a/Server/Server/Http/HttpServiceMain.cs b/Server/Server/Http/HttpServiceMain.cs index cdfcd488..bd6001f1 100644 --- a/Server/Server/Http/HttpServiceMain.cs +++ b/Server/Server/Http/HttpServiceMain.cs @@ -63,7 +63,7 @@ private WebServer CreateWebServer(string url) Type baseType = typeof(BaseController); List<Type> controllers = types.Where(t => { - return baseType == t.BaseType; + return !t.IsAbstract && baseType.IsAssignableFrom(t); }).ToList(); string baseRout = UserConfig.Instance.BaseRoute; server.WithWebApi(baseRout, m => { diff --git a/Server/Server/Properties/AssemblyInfo.cs b/Server/Server/Properties/AssemblyInfo.cs index 41948992..add61c8b 100644 --- a/Server/Server/Properties/AssemblyInfo.cs +++ b/Server/Server/Properties/AssemblyInfo.cs @@ -51,7 +51,7 @@ //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.4.3.0")] -[assembly: AssemblyFileVersion("0.4.3.0")] +[assembly: AssemblyVersion("0.4.4.0")] +[assembly: AssemblyFileVersion("0.4.4.0")] [assembly: log4net.Config.XmlConfigurator(ConfigFile = "Config\\log4net.config", Watch = true)] diff --git a/UI/src/views/dashboard/components/inboxTypes.vue b/UI/src/views/dashboard/components/inboxTypes.vue index d50695b2..18abcc68 100644 --- a/UI/src/views/dashboard/components/inboxTypes.vue +++ b/UI/src/views/dashboard/components/inboxTypes.vue @@ -6,7 +6,6 @@ import 'echarts-liquidfill' import * as echarts from 'echarts' import resize from '@/components/Echarts/mixins/resize' -import _ from 'lodash' import { getInboxCountOfTyes } from '@/api/report' export default {