浏览代码

增加码云图床

懒得勤快 6 年之前
父节点
当前提交
b1d762f185

+ 93 - 25
src/Masuit.MyBlogs.Core/Common/CommonHelper.cs

@@ -186,31 +186,76 @@ namespace Masuit.MyBlogs.Core.Common
 #endif
         }
 
+        #region 图床相关
+
         /// <summary>
         /// OSS客户端
         /// </summary>
         public static OssClient OssClient { get; set; } = new OssClient(AppConfig.AliOssConfig.EndPoint, AppConfig.AliOssConfig.AccessKeyId, AppConfig.AliOssConfig.AccessKeySecret);
 
         /// <summary>
-        /// 阿里云Oss图床
+        /// 上传图片
         /// </summary>
         /// <param name="file"></param>
         /// <returns></returns>
         public static (string url, bool success) UploadImage(string file)
         {
-            if (!AppConfig.AliOssConfig.Enabled)
+            if (AppConfig.GiteeConfig.Enabled)
+            {
+                return UploadGitee(file);
+            }
+
+            if (AppConfig.GitlabConfig.Enabled)
             {
                 return UploadGitlab(file);
             }
 
-            var objectName = DateTime.Now.ToString("yyyyMMdd") + "/" + SnowFlake.NewId + Path.GetExtension(file);
-            var result = Policy.Handle<Exception>().Retry(5, (e, i) =>
-             {
-                 Console.ForegroundColor = ConsoleColor.Red;
-                 Console.WriteLine(e.Message);
-                 Console.ResetColor();
-             }).Execute(() => OssClient.PutObject(AppConfig.AliOssConfig.BucketName, objectName, file));
-            return result.HttpStatusCode == HttpStatusCode.OK ? (AppConfig.AliOssConfig.BucketDomain + "/" + objectName, true) : UploadSmms(file);
+            if (AppConfig.AliOssConfig.Enabled)
+            {
+                return UploadOss(file);
+            }
+
+            return UploadSmms(file);
+        }
+
+        /// <summary>
+        /// 码云图床
+        /// </summary>
+        /// <param name="file"></param>
+        /// <returns></returns>
+        public static (string url, bool success) UploadGitee(string file)
+        {
+            if (!file.Contains(new[] { ".jpg", ".jpeg", ".gif", ".png", ".bmp" }))
+            {
+                return (null, false);
+            }
+
+            using (Image image = Image.FromFile(file))
+            {
+                using (MemoryStream m = new MemoryStream())
+                {
+                    image.Save(m, image.RawFormat);
+                    string base64String = Convert.ToBase64String(m.ToArray());
+                    using (HttpClient httpClient = new HttpClient())
+                    {
+                        string path = $"{DateTime.Now:yyyyMMdd}/{Path.GetFileName(file)}";
+                        using (var resp = httpClient.PostAsJsonAsync(AppConfig.GiteeConfig.ApiUrl + path, new
+                        {
+                            access_token = AppConfig.GiteeConfig.AccessToken,
+                            content = base64String,
+                            message = "上传一张图片"
+                        }).Result)
+                        {
+                            if (resp.IsSuccessStatusCode || resp.Content.ReadAsStringAsync().Result.Contains("already exists"))
+                            {
+                                return (AppConfig.GiteeConfig.RawUrl + path, true);
+                            }
+                        }
+                    }
+
+                    return UploadSmms(file);
+                }
+            }
         }
 
         /// <summary>
@@ -220,9 +265,9 @@ namespace Masuit.MyBlogs.Core.Common
         /// <returns></returns>
         public static (string url, bool success) UploadGitlab(string file)
         {
-            if (!AppConfig.GitlabConfig.Enabled)
+            if (!file.Contains(new[] { ".jpg", ".jpeg", ".gif", ".png", ".bmp" }))
             {
-                return UploadSmms(file);
+                return (null, false);
             }
 
             using (Image image = Image.FromFile(file))
@@ -231,20 +276,25 @@ namespace Masuit.MyBlogs.Core.Common
                 {
                     image.Save(m, image.RawFormat);
                     string base64String = Convert.ToBase64String(m.ToArray());
-                    HttpClient httpClient = new HttpClient();
-                    httpClient.DefaultRequestHeaders.Add("PRIVATE-TOKEN", AppConfig.GitlabConfig.AccessToken);
-                    var resp = httpClient.PostAsJsonAsync(AppConfig.GitlabConfig.ApiUrl + Path.GetFileName(file), new
-                    {
-                        branch = AppConfig.GitlabConfig.Branch,
-                        author_email = "[email protected]",
-                        author_name = "ldqk",
-                        encoding = "base64",
-                        content = base64String,
-                        commit_message = "上传一张图片"
-                    }).Result;
-                    if (resp.IsSuccessStatusCode)
+                    using (HttpClient httpClient = new HttpClient())
                     {
-                        return (AppConfig.GitlabConfig.RawUrl + Path.GetFileName(file), true);
+                        httpClient.DefaultRequestHeaders.Add("PRIVATE-TOKEN", AppConfig.GitlabConfig.AccessToken);
+                        string path = $"{DateTime.Now:yyyyMMdd}/{Path.GetFileName(file)}";
+                        using (var resp = httpClient.PostAsJsonAsync(AppConfig.GitlabConfig.ApiUrl + path, new
+                        {
+                            branch = AppConfig.GitlabConfig.Branch,
+                            author_email = "[email protected]",
+                            author_name = "ldqk",
+                            encoding = "base64",
+                            content = base64String,
+                            commit_message = "上传一张图片"
+                        }).Result)
+                        {
+                            if (resp.IsSuccessStatusCode || resp.Content.ReadAsStringAsync().Result.Contains("already exists"))
+                            {
+                                return (AppConfig.GitlabConfig.RawUrl + path, true);
+                            }
+                        }
                     }
 
                     return UploadSmms(file);
@@ -252,6 +302,23 @@ namespace Masuit.MyBlogs.Core.Common
             }
         }
 
+        /// <summary>
+        /// 阿里云Oss图床
+        /// </summary>
+        /// <param name="file"></param>
+        /// <returns></returns>
+        public static (string url, bool success) UploadOss(string file)
+        {
+            var objectName = DateTime.Now.ToString("yyyyMMdd") + "/" + SnowFlake.NewId + Path.GetExtension(file);
+            var result = Policy.Handle<Exception>().Retry(5, (e, i) =>
+            {
+                Console.ForegroundColor = ConsoleColor.Red;
+                Console.WriteLine(e.Message);
+                Console.ResetColor();
+            }).Execute(() => OssClient.PutObject(AppConfig.AliOssConfig.BucketName, objectName, file));
+            return result.HttpStatusCode == HttpStatusCode.OK ? (AppConfig.AliOssConfig.BucketDomain + "/" + objectName, true) : UploadSmms(file);
+        }
+
         /// <summary>
         /// 上传图片到sm图床
         /// </summary>
@@ -358,6 +425,7 @@ namespace Masuit.MyBlogs.Core.Common
             }
         }
 
+        #endregion
         /// <summary>
         /// 替换img标签的src属性
         /// </summary>

+ 5 - 0
src/Masuit.MyBlogs.Core/Configs/AppConfig.cs

@@ -32,6 +32,11 @@ namespace Masuit.MyBlogs.Core.Configs
         /// </summary>
         public static GitlabConfig GitlabConfig { get; set; } = new GitlabConfig();
 
+        /// <summary>
+        /// 码云图床配置
+        /// </summary>
+        public static GitlabConfig GiteeConfig { get; set; } = new GitlabConfig();
+
         /// <summary>
         /// 图床域名
         /// </summary>

+ 5 - 15
src/Masuit.MyBlogs.Core/Controllers/AdminController.cs

@@ -1,4 +1,5 @@
-using Masuit.MyBlogs.Core.Configs;
+using Masuit.MyBlogs.Core.Common;
+using Masuit.MyBlogs.Core.Configs;
 using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.DTO;
@@ -8,11 +9,8 @@ using Masuit.Tools.Security;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Filters;
-using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
-using System.Text;
-using Masuit.MyBlogs.Core.Common;
 
 namespace Masuit.MyBlogs.Core.Controllers
 {
@@ -37,18 +35,13 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <returns></returns>
         public ActionResult ResultData(object data, bool success = true, string message = "", bool isLogin = true)
         {
-            return Content(JsonConvert.SerializeObject(new
+            return Ok(new
             {
                 IsLogin = isLogin,
                 Success = success,
                 Message = message,
                 Data = data
-            }, new JsonSerializerSettings
-            {
-                MissingMemberHandling = MissingMemberHandling.Ignore,
-                NullValueHandling = NullValueHandling.Ignore,
-                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
-            }), "application/json", Encoding.UTF8);
+            });
         }
 
         /// <summary>
@@ -60,10 +53,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <returns></returns>
         public ActionResult PageResult(object data, int pageCount, int total)
         {
-            return Content(JsonConvert.SerializeObject(new PageDataModel(data, pageCount, total), new JsonSerializerSettings
-            {
-                MissingMemberHandling = MissingMemberHandling.Ignore
-            }), "application/json", Encoding.UTF8);
+            return Ok(new PageDataModel(data, pageCount, total));
         }
 
         /// <summary>在调用操作方法前调用。</summary>

+ 5 - 15
src/Masuit.MyBlogs.Core/Controllers/BaseController.cs

@@ -11,12 +11,10 @@ using Masuit.Tools.Security;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc.Filters;
-using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Net;
-using System.Text;
 
 namespace Masuit.MyBlogs.Core.Controllers
 {
@@ -50,21 +48,16 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="isLogin">登录状态</param>
         /// <param name="code">http响应码</param>
         /// <returns></returns>
-        public ContentResult ResultData(object data, bool success = true, string message = "", bool isLogin = true, HttpStatusCode code = HttpStatusCode.OK)
+        public ActionResult ResultData(object data, bool success = true, string message = "", bool isLogin = true, HttpStatusCode code = HttpStatusCode.OK)
         {
-            return Content(JsonConvert.SerializeObject(new
+            return Ok(new
             {
                 IsLogin = isLogin,
                 Success = success,
                 Message = message,
                 Data = data,
                 code
-            }, new JsonSerializerSettings
-            {
-                MissingMemberHandling = MissingMemberHandling.Ignore,
-                NullValueHandling = NullValueHandling.Ignore,
-                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
-            }), "application/json", Encoding.UTF8);
+            });
         }
 
         /// <summary>
@@ -74,12 +67,9 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="pageCount">总页数</param>
         /// <param name="total">总条数</param>
         /// <returns></returns>
-        public ContentResult PageResult(object data, int pageCount, int total)
+        public ActionResult PageResult(object data, int pageCount, int total)
         {
-            return Content(JsonConvert.SerializeObject(new PageDataModel(data, pageCount, total), new JsonSerializerSettings
-            {
-                MissingMemberHandling = MissingMemberHandling.Ignore
-            }), "application/json", Encoding.UTF8);
+            return Ok(new PageDataModel(data, pageCount, total));
         }
 
         /// <summary>在调用操作方法前调用。</summary>

+ 7 - 3
src/Masuit.MyBlogs.Core/Controllers/SearchController.cs

@@ -56,15 +56,16 @@ namespace Masuit.MyBlogs.Core.Controllers
             {
                 return RedirectToAction("Search");
             }
-            var start = DateTime.Today.AddDays(-7);
+
             string key = "Search:" + HttpContext.Session.Id;
             if (RedisHelper.Exists(key) && !RedisHelper.Get(key).Equals(wd))
             {
-                var hotSearches = RedisHelper.Get<List<KeywordsRankOutputDto>>("SearchRank:Week");
+                var hotSearches = RedisHelper.Get<List<KeywordsRankOutputDto>>("SearchRank:Week").Take(10).ToList();
                 ViewBag.hotSearches = hotSearches;
                 ViewBag.ErrorMsg = "10秒内只能搜索1次!";
                 return View(nul);
             }
+
             wd = wd.Trim().Replace("+", " ");
             if (!string.IsNullOrWhiteSpace(wd) && !wd.Contains("锟斤拷"))
             {
@@ -78,6 +79,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                     });
                     HttpContext.Session.Set("search:" + wd, wd.ToByteArray());
                 }
+
                 var posts = _postService.SearchPage(page, size, wd);
                 ViewBag.Elapsed = posts.Elapsed;
                 ViewBag.Total = posts.Total;
@@ -87,10 +89,12 @@ namespace Masuit.MyBlogs.Core.Controllers
                     RedisHelper.Set(key, wd);
                     RedisHelper.Expire(key, TimeSpan.FromSeconds(10));
                 }
+
                 ViewBag.hotSearches = new List<KeywordsRankOutputDto>();
                 return View(posts.Results);
             }
-            ViewBag.hotSearches = RedisHelper.Get<List<KeywordsRankOutputDto>>("SearchRank:Week");
+
+            ViewBag.hotSearches = RedisHelper.Get<List<KeywordsRankOutputDto>>("SearchRank:Week").Take(10).ToList();
             return View(nul);
         }
 

+ 68 - 3
src/Masuit.MyBlogs.Core/Controllers/SubscribeController.cs

@@ -1,11 +1,14 @@
-using Hangfire;
+using EFSecondLevelCache.Core;
+using Hangfire;
 using Masuit.MyBlogs.Core.Common;
 using Masuit.MyBlogs.Core.Configs;
 using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
+using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools.DateTimeExt;
+using Masuit.Tools.Html;
 using Masuit.Tools.Logging;
 using Masuit.Tools.Security;
 using Microsoft.AspNetCore.Hosting;
@@ -13,13 +16,15 @@ using Microsoft.AspNetCore.Mvc;
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Net;
+using WilderMinds.RssSyndication;
 
 namespace Masuit.MyBlogs.Core.Controllers
 {
     /// <summary>
     /// 订阅服务
     /// </summary>
-    public class SubscribeController : BaseController
+    public class SubscribeController : Controller
     {
         /// <summary>
         /// 邮箱广播
@@ -46,6 +51,66 @@ namespace Masuit.MyBlogs.Core.Controllers
             _hostingEnvironment = hostingEnvironment;
         }
 
+        /// <summary>
+        /// 响应数据
+        /// </summary>
+        /// <param name="data">数据</param>
+        /// <param name="success">响应状态</param>
+        /// <param name="message">响应消息</param>
+        /// <param name="isLogin">登录状态</param>
+        /// <param name="code">http响应码</param>
+        /// <returns></returns>
+        public ActionResult ResultData(object data, bool success = true, string message = "", bool isLogin = true, HttpStatusCode code = HttpStatusCode.OK)
+        {
+            return Ok(new
+            {
+                IsLogin = isLogin,
+                Success = success,
+                Message = message,
+                Data = data,
+                code
+            });
+        }
+
+        /// <summary>
+        /// RSS订阅
+        /// </summary>
+        /// <returns></returns>
+        [Route("/rss"), ResponseCache(Duration = 600)]
+        public IActionResult Rss()
+        {
+            var time = DateTime.Today.AddDays(-1);
+            string scheme = Request.Scheme;
+            var host = Request.Host;
+            var posts = PostService.LoadEntitiesNoTracking(p => p.Status == Status.Pended && p.ModifyDate >= time, p => p.ModifyDate, false).Select(p => new Item()
+            {
+                Author = new Author
+                {
+                    Name = p.Author,
+                    Email = p.Email
+                },
+                Body = p.Content.RemoveHtmlTag(300),
+                Categories = new List<string>
+                {
+                    p.Category.Name
+                },
+                Link = new Uri(scheme + "://" + host + "/" + p.Id),
+                PublishDate = p.ModifyDate,
+                Title = p.Title,
+                Permalink = scheme + "://" + host + "/" + p.Id
+            }).Cacheable().ToList();
+            var feed = new Feed()
+            {
+                Title = CommonHelper.SystemSettings["Title"],
+                Description = CommonHelper.SystemSettings["Description"],
+                Link = new Uri(scheme + "://" + host + "/rss"),
+                Copyright = "(c) 2019"
+            };
+            feed.Items.AddRange(posts.ToArray());
+            var rss = feed.Serialize();
+            return Content(rss, "text/xml");
+        }
+
         /// <summary>
         /// 邮箱订阅
         /// </summary>
@@ -267,7 +332,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 list = BroadcastService.LoadPageEntitiesFromL2CacheNoTracking(page, size, out total, b => b.Email.Contains(search), b => b.UpdateTime, false).ToList();
             }
             var pageCount = Math.Ceiling(total * 1.0 / size).ToInt32();
-            return PageResult(list, pageCount, total);
+            return Ok(new PageDataModel(list, pageCount, total));
         }
 
         #endregion

+ 1 - 0
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -82,6 +82,7 @@
     <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
     <PackageReference Include="Polly" Version="7.1.0" />
     <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
+    <PackageReference Include="WilderMinds.RssSyndication" Version="1.5.0" />
     <PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="2.3.5" />
     <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="1.9.0" />
     <PackageReference Include="Z.ExtensionMethods" Version="2.1.1" />

+ 50 - 1
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.xml

@@ -89,7 +89,14 @@
         </member>
         <member name="M:Masuit.MyBlogs.Core.Common.CommonHelper.UploadImage(System.String)">
             <summary>
-            阿里云Oss图床
+            上传图片
+            </summary>
+            <param name="file"></param>
+            <returns></returns>
+        </member>
+        <member name="M:Masuit.MyBlogs.Core.Common.CommonHelper.UploadGitee(System.String)">
+            <summary>
+            码云图床
             </summary>
             <param name="file"></param>
             <returns></returns>
@@ -101,6 +108,13 @@
             <param name="file"></param>
             <returns></returns>
         </member>
+        <member name="M:Masuit.MyBlogs.Core.Common.CommonHelper.UploadOss(System.String)">
+            <summary>
+            阿里云Oss图床
+            </summary>
+            <param name="file"></param>
+            <returns></returns>
+        </member>
         <member name="M:Masuit.MyBlogs.Core.Common.CommonHelper.UploadSmms(System.String)">
             <summary>
             上传图片到sm图床
@@ -242,6 +256,11 @@
             gitlab图床配置
             </summary>
         </member>
+        <member name="P:Masuit.MyBlogs.Core.Configs.AppConfig.GiteeConfig">
+            <summary>
+            码云图床配置
+            </summary>
+        </member>
         <member name="P:Masuit.MyBlogs.Core.Configs.AppConfig.ImgbedDomains">
             <summary>
             图床域名
@@ -1687,6 +1706,23 @@
             <param name="postService"></param>
             <param name="hostingEnvironment"></param>
         </member>
+        <member name="M:Masuit.MyBlogs.Core.Controllers.SubscribeController.ResultData(System.Object,System.Boolean,System.String,System.Boolean,System.Net.HttpStatusCode)">
+            <summary>
+            响应数据
+            </summary>
+            <param name="data">数据</param>
+            <param name="success">响应状态</param>
+            <param name="message">响应消息</param>
+            <param name="isLogin">登录状态</param>
+            <param name="code">http响应码</param>
+            <returns></returns>
+        </member>
+        <member name="M:Masuit.MyBlogs.Core.Controllers.SubscribeController.Rss">
+            <summary>
+            RSS订阅
+            </summary>
+            <returns></returns>
+        </member>
         <member name="M:Masuit.MyBlogs.Core.Controllers.SubscribeController.Subscribe(System.String)">
             <summary>
             邮箱订阅
@@ -1898,6 +1934,19 @@
             <param name="ip"></param>
             <returns></returns>
         </member>
+        <member name="M:Masuit.MyBlogs.Core.Controllers.TestController.Test">
+            <summary>
+            迁移图床
+            </summary>
+            <returns></returns>
+        </member>
+        <member name="M:Masuit.MyBlogs.Core.Controllers.TestController.UploadGitlab(System.IO.Stream,System.String)">
+            <summary>
+            gitlab图床
+            </summary>
+            <param name="file"></param>
+            <returns></returns>
+        </member>
         <member name="T:Masuit.MyBlogs.Core.Controllers.ToolsController">
             <summary>
             黑科技

+ 1 - 2
src/Masuit.MyBlogs.Core/Migrations/20190321050816_Init.Designer.cs

@@ -1,10 +1,9 @@
 // <auto-generated />
-using System;
 using Masuit.MyBlogs.Core.Infrastructure;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.EntityFrameworkCore.Infrastructure;
 using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using System;
 
 namespace Masuit.MyBlogs.Core.Migrations
 {

+ 2 - 3
src/Masuit.MyBlogs.Core/Models/Entity/Broadcast.cs

@@ -1,8 +1,7 @@
-using System;
-using System.ComponentModel.DataAnnotations.Schema;
-using Masuit.MyBlogs.Core.Models.Entity;
 using Masuit.MyBlogs.Core.Models.Enum;
 using Masuit.MyBlogs.Core.Models.Validation;
+using System;
+using System.ComponentModel.DataAnnotations.Schema;
 
 namespace Masuit.MyBlogs.Core.Models.Entity
 {

+ 1 - 2
src/Masuit.MyBlogs.Core/Models/Entity/Category.cs

@@ -1,8 +1,7 @@
+using Masuit.MyBlogs.Core.Models.Enum;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
-using Masuit.MyBlogs.Core.Models.Entity;
-using Masuit.MyBlogs.Core.Models.Enum;
 
 namespace Masuit.MyBlogs.Core.Models.Entity
 {

+ 0 - 1
src/Masuit.MyBlogs.Core/Models/Entity/Donate.cs

@@ -1,6 +1,5 @@
 using System;
 using System.ComponentModel.DataAnnotations.Schema;
-using Masuit.MyBlogs.Core.Models.Entity;
 
 namespace Masuit.MyBlogs.Core.Models.Entity
 {

+ 0 - 1
src/Masuit.MyBlogs.Core/Models/Entity/FastShare.cs

@@ -1,5 +1,4 @@
 using System.ComponentModel.DataAnnotations.Schema;
-using Masuit.MyBlogs.Core.Models.Entity;
 
 namespace Masuit.MyBlogs.Core.Models.Entity
 {

+ 0 - 1
src/Masuit.MyBlogs.Core/Models/Entity/InternalMessage.cs

@@ -1,6 +1,5 @@
 using System;
 using System.ComponentModel.DataAnnotations.Schema;
-using Masuit.MyBlogs.Core.Models.Entity;
 
 namespace Masuit.MyBlogs.Core.Models.Entity
 {

+ 0 - 1
src/Masuit.MyBlogs.Core/Models/Entity/Links.cs

@@ -1,7 +1,6 @@
 using Masuit.MyBlogs.Core.Models.Enum;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
-using Masuit.MyBlogs.Core.Models.Entity;
 
 namespace Masuit.MyBlogs.Core.Models.Entity
 {

+ 2 - 3
src/Masuit.MyBlogs.Core/Models/Entity/LoginRecord.cs

@@ -1,7 +1,6 @@
-using System;
+using Masuit.MyBlogs.Core.Models.Enum;
+using System;
 using System.ComponentModel.DataAnnotations.Schema;
-using Masuit.MyBlogs.Core.Models.Entity;
-using Masuit.MyBlogs.Core.Models.Enum;
 
 namespace Masuit.MyBlogs.Core.Models.Entity
 {

+ 1 - 2
src/Masuit.MyBlogs.Core/Models/Entity/Menu.cs

@@ -1,8 +1,7 @@
+using Masuit.MyBlogs.Core.Models.Enum;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
-using Masuit.MyBlogs.Core.Models.Entity;
-using Masuit.MyBlogs.Core.Models.Enum;
 
 namespace Masuit.MyBlogs.Core.Models.Entity
 {

+ 1 - 2
src/Masuit.MyBlogs.Core/Models/Entity/SystemSetting.cs

@@ -1,7 +1,6 @@
+using Masuit.MyBlogs.Core.Models.Enum;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
-using Masuit.MyBlogs.Core.Models.Entity;
-using Masuit.MyBlogs.Core.Models.Enum;
 
 namespace Masuit.MyBlogs.Core.Models.Entity
 {

+ 1 - 2
src/Masuit.MyBlogs.Core/Models/Entity/UserInfo.cs

@@ -1,9 +1,8 @@
+using Masuit.MyBlogs.Core.Models.Validation;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
-using Masuit.MyBlogs.Core.Models.Entity;
-using Masuit.MyBlogs.Core.Models.Validation;
 
 namespace Masuit.MyBlogs.Core.Models.Entity
 {

+ 1 - 1
src/Masuit.MyBlogs.Core/Startup.cs

@@ -69,6 +69,7 @@ namespace Masuit.MyBlogs.Core
             AppConfig.Redis = configuration[nameof(AppConfig.Redis)];
             configuration.Bind("Imgbed:AliyunOSS", AppConfig.AliOssConfig);
             configuration.Bind("Imgbed:Gitlab", AppConfig.GitlabConfig);
+            configuration.Bind("Imgbed:Gitee", AppConfig.GiteeConfig);
             configuration.Bind("Imgbed:ImgbedDomains", AppConfig.ImgbedDomains);
         }
 
@@ -152,7 +153,6 @@ namespace Masuit.MyBlogs.Core
             services.AddMvc().AddJsonOptions(opt =>
             {
                 opt.SerializerSettings.ContractResolver = new DefaultContractResolver();
-                //opt.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
                 opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
             }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2).AddControllersAsServices().AddViewComponentsAsServices().AddTagHelpersAsServices();
 

+ 8 - 8
src/Masuit.MyBlogs.Core/Views/Misc/Donate.cshtml

@@ -87,14 +87,14 @@
             </div>
             <img class="img-responsive img-thumbnail" style="width: 100%" src="@CommonHelper.SystemSettings["DonateJingdong"]" />
         </div>
-        <div class="col-md-3">
-            <div class="page-header margin-clear margin-top10">
-                <h2 class="size28">
-                    支付宝,领红包
-                </h2>
-            </div>
-            <img class="img-responsive img-thumbnail" style="width: 100%" src="http://wx1.sinaimg.cn/mw690/0060lm7Tly1fsnrd1z8shj31kw26ugsz.jpg" />
-        </div>
+        @*<div class="col-md-3">
+                <div class="page-header margin-clear margin-top10">
+                    <h2 class="size28">
+                        支付宝,领红包
+                    </h2>
+                </div>
+                <img class="img-responsive img-thumbnail" style="width: 100%" src="http://wx1.sinaimg.cn/mw690/0060lm7Tly1fsnrd1z8shj31kw26ugsz.jpg" />
+            </div>*@
     </div>
 </div>
 <div class="container margintop20">

+ 8 - 8
src/Masuit.MyBlogs.Core/Views/Misc/Donate_Admin.cshtml

@@ -89,14 +89,14 @@
             </div>
             <img class="img-responsive img-thumbnail" style="width: 100%" src="@CommonHelper.SystemSettings["DonateJingdong"]" />
         </div>
-        <div>
-            <div class="page-header margin-clear margin-top10">
-                <h2 class="size28">
-                    支付宝,领红包
-                </h2>
-            </div>
-            <img class="img-responsive img-thumbnail" style="width: 100%" src="http://wx1.sinaimg.cn/mw690/0060lm7Tly1fsnrd1z8shj31kw26ugsz.jpg" />
-        </div>
+        @*<div>
+                <div class="page-header margin-clear margin-top10">
+                    <h2 class="size28">
+                        支付宝,领红包
+                    </h2>
+                </div>
+                <img class="img-responsive img-thumbnail" style="width: 100%" src="http://wx1.sinaimg.cn/mw690/0060lm7Tly1fsnrd1z8shj31kw26ugsz.jpg" />
+            </div>*@
     </div>
 </div>
 <div class="container margintop20">

+ 31 - 22
src/Masuit.MyBlogs.Core/appsettings.json

@@ -1,19 +1,19 @@
 {
-    "Logging": {
-        "LogLevel": {
-            "Default": "Error"
-        }
-    },
-    "AllowedHosts": "*",
+	"Logging":{
+		"LogLevel":{
+			"Default":"Error"
+		}
+	},
+	"AllowedHosts":"*",
     "cert": {
         "path": "App_Data/cert/server.pfx",
         "password": "cEHlnUGu"
     },
-    "ConnString": "Server=127.0.0.1;Port=3306;Database=MyBlogs;Uid=root;Pwd=;Charset=utf8mb4",
-    //"ConnString": "Data Source=.;Initial Catalog=MyBlogs;Integrated Security=True",
+	"ConnString":"Server=127.0.0.1;Port=3306;Database=MyBlogs;Uid=root;Pwd=;Charset=utf8mb4",
+	//"ConnString": "Data Source=.;Initial Catalog=MyBlogs;Integrated Security=True",
     "BaiduAK": "你的BaiduAK",
-    "Redis": "127.0.0.1:6379,allowadmin=true,connectTimeout=20000,connectRetry=1,responseTimeout=20000,syncTimeout=10000",
-    "Imgbed": { // 图床相关配置
+	"Redis":"127.0.0.1:6379,allowadmin=true,connectTimeout=20000,connectRetry=1,responseTimeout=20000,syncTimeout=10000",
+	"Imgbed":{// 图床相关配置
         "AliyunOSS": {
             "Enabled": false,
             "EndPoint": "Oss节点域名",
@@ -22,6 +22,13 @@
             "AccessKeySecret": "AccessKeySecret",
             "BucketName": "BucketName"
         },
+		"Gitee": {
+			"Enabled": false,
+			"ApiUrl": "https://gitee.com/api/v5/repos/<用户名>/<项目仓库名>/contents/", // 码云上传API地址
+			"RawUrl": "https://gitee.com/<用户名>/<项目仓库名>/raw/master/",
+			"AccessToken": "你的access_token", //access_token在码云个人中心获取,https://gitee.com/profile/personal_access_tokens
+			"Branch": "master"
+		},
         "Gitlab": {
             "Enabled": false,
             "ApiUrl": "https://gitlab.com/api/v4/projects/<你的项目id>/repository/files/", // /api/v4/projects/<项目id>/repository/files/,使用前请先获取private_token,然后根private_token据来获取项目id,/api/v4/projects?private_token=<你的private_token>&search=<项目仓库名>
@@ -29,16 +36,18 @@
             "AccessToken": "你的private_token",
             "Branch": "master"
         },
-        "ImgbedDomains": [
-            "git.imweb.io",
-            "gitlab.com",
-            "github.com",
-            "git.lug.ustc.edu.cn",
-            "loli.net",
-            "sinaimg.cn",
-            "alicdn.com",
-            "kuaizhan.com",
-            "qpic.cn"
-        ]
-    }
+		"ImgbedDomains": [
+			"git.imweb.io",
+			"gitee.com",
+			"gitlab.com",
+			"github.com",
+			"gitclub.cn",
+			"git.lug.ustc.edu.cn",
+			"loli.net",
+			"sinaimg.cn",
+			"alicdn.com",
+			"kuaizhan.com",
+			"qpic.cn"
+		]
+	}
 }