Browse Source

放弃新浪图床

懒得勤快 6 years ago
parent
commit
51c0a5fa2e

+ 28 - 243
src/Masuit.MyBlogs.Core/Common/CommonHelper.cs

@@ -5,9 +5,12 @@ using System.IO;
 using System.Linq;
 using System.Net.Http;
 using System.Net.Http.Headers;
+using Aliyun.OSS;
 using Hangfire;
+using Masuit.MyBlogs.Core.Configs;
 using Masuit.Tools;
 using Masuit.Tools.Html;
+using Masuit.Tools.Systems;
 #if !DEBUG
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools.Models;
@@ -16,6 +19,7 @@ using Microsoft.AspNetCore.Http;
 using Microsoft.Net.Http.Headers;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
+using Polly;
 using ContentDispositionHeaderValue = System.Net.Http.Headers.ContentDispositionHeaderValue;
 
 namespace Common
@@ -177,131 +181,31 @@ namespace Common
         }
 
         /// <summary>
-        /// 上传图片到新浪图床
+        /// OSS客户端
         /// </summary>
-        /// <returns></returns>
-        public static (string, bool) UploadImage(string file)
-        {
-            string api = "https://api.yum6.cn/sinaimg.php?type=multipart";
-            string url = string.Empty;
-            using (HttpClient httpClient = new HttpClient())
-            {
-                httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Mozilla/5.0"));
-                httpClient.DefaultRequestHeaders.Referrer = new Uri(api);
-                using (var fs = File.OpenRead(file))
-                {
-                    using (var bc = new StreamContent(fs))
-                    {
-                        bc.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
-                        {
-                            FileName = Path.GetFileName(file),
-                            Name = "file"
-                        };
-                        using (var content = new MultipartFormDataContent
-                        {
-                            bc
-                        })
-                        {
-                            var code = httpClient.PostAsync(api, content).ContinueWith(t =>
-                            {
-                                if (t.IsCanceled || t.IsFaulted)
-                                {
-                                    return 0;
-                                }
-
-                                var res = t.Result;
-                                if (res.IsSuccessStatusCode)
-                                {
-                                    try
-                                    {
-                                        string s = res.Content.ReadAsStringAsync().Result;
-                                        var token = JObject.Parse(s);
-                                        s = (string)token["code"];
-                                        if (s.Equals("200"))
-                                        {
-                                            url = ((string)token["url"]).Replace("thumb150", "large");
-                                            return url.Length > 40 ? 1 : 2;
-                                        }
-                                    }
-                                    catch
-                                    {
-                                        return 2;
-                                    }
-                                }
-
-                                return 2;
-                            }).Result;
-                            if (code == 1)
-                            {
-                                var success = true;
-                                return (url.Replace("/thumb150/", "/large/"), success);
-                            }
-
-                            Console.WriteLine("https://api.yum6.cn 图床接口都挂掉了,重试人民网图床");
-                            return UploadPeople(file);
-                        }
-                    }
-                }
-            }
-        }
+        public static OssClient OssClient { get; set; } = new OssClient(AppConfig.AliOssConfig.EndPoint, AppConfig.AliOssConfig.AccessKeyId, AppConfig.AliOssConfig.AccessKeySecret);
 
-        /// <summary>
-        /// 上传图片到人民网图床
-        /// </summary>
-        /// <returns></returns>
-        public static (string url, bool success) UploadPeople(string file)
+        public static (string url, bool success) UploadOss(string file)
         {
-            var success = false;
-            using (var httpClient = new HttpClient())
+            if (!AppConfig.AliOssConfig.Enabled)
             {
-                httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Chrome/72.0.3626.96"));
-                using (var fs = File.OpenRead(file))
-                {
-                    using (var sc = new StreamContent(fs))
-                    {
-                        using (var mc = new MultipartFormDataContent
-                        {
-                            { sc, "Filedata", Path.GetFileName(file) },
-                            { new StringContent(Path.GetExtension(file)), "filetype" }
-                        })
-                        {
-                            var s = httpClient.PostAsync("http://bbs1.people.com.cn/postImageUpload.do", mc).ContinueWith(t =>
-                            {
-                                if (t.IsCompletedSuccessfully)
-                                {
-                                    var res = t.Result;
-                                    if (res.IsSuccessStatusCode)
-                                    {
-                                        string result = res.Content.ReadAsStringAsync().Result;
-                                        string url = "http://bbs1.people.com.cn" + (string)JObject.Parse(result)["imageUrl"];
-                                        if (url.EndsWith(Path.GetExtension(file)))
-                                        {
-                                            success = true;
-                                            return url;
-                                        }
-                                    }
-                                }
-
-                                return "";
-                            }).Result;
-                            if (!success)
-                            {
-                                Console.WriteLine("人民网图床上传接口都挂掉了,重试sm.ms图床");
-                                return UploadSmmsImage(file);
-                            }
-
-                            return (s, success);
-                        }
-                    }
-                }
+                return ("", false);
             }
+
+            var objectName = DateTime.Now.ToString("yyyyMMdd") + "/" + SnowFlake.NewId + Path.GetExtension(file);
+            var policy = Policy<(string, bool)>.Handle<Exception>().Retry(3);
+            return policy.Execute(() =>
+             {
+                 OssClient.PutObject(AppConfig.AliOssConfig.BucketName, objectName, file);
+                 return (AppConfig.AliOssConfig.BucketDomain + "/" + objectName, true);
+             });
         }
 
         /// <summary>
         /// 上传图片到sm图床
         /// </summary>
         /// <returns></returns>
-        private static (string, bool) UploadSmmsImage(string file)
+        public static (string url, bool success) UploadImage(string file)
         {
             string url = string.Empty;
             bool success = false;
@@ -317,10 +221,7 @@ namespace Common
                             FileName = Path.GetFileName(file),
                             Name = "smfile"
                         };
-                        using (var content = new MultipartFormDataContent
-                        {
-                            bc
-                        })
+                        using (var content = new MultipartFormDataContent { bc })
                         {
                             var code = httpClient.PostAsync("https://sm.ms/api/upload?inajax=1&ssl=1", content).ContinueWith(t =>
                             {
@@ -332,73 +233,17 @@ namespace Common
                                 var res = t.Result;
                                 if (res.IsSuccessStatusCode)
                                 {
-                                    string s = res.Content.ReadAsStringAsync().Result;
-                                    var token = JObject.Parse(s);
-                                    url = (string)token["data"]["url"];
-                                    return 1;
-                                }
-
-                                return 2;
-                            }).Result;
-                            if (code == 1)
-                            {
-                                success = true;
-                            }
-                        }
-                    }
-                }
-            }
-
-            if (success)
-            {
-                return (url, success);
-            }
-
-            return UploadImageFallback(file);
-        }
-
-        /// <summary>
-        /// 上传图片到upload.cc图床
-        /// </summary>
-        /// <returns></returns>
-        private static (string, bool) UploadImageFallback(string file)
-        {
-            string url = string.Empty;
-            bool success = false;
-            using (HttpClient httpClient = new HttpClient())
-            {
-                using (var fs = File.OpenRead(file))
-                {
-                    httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Mozilla/5.0"));
-                    using (var bc = new StreamContent(fs))
-                    {
-                        bc.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
-                        {
-                            FileName = Path.GetFileName(file),
-                            Name = "uploaded_file[]"
-                        };
-                        using (var content = new MultipartFormDataContent
-                        {
-                            bc
-                        })
-                        {
-                            var code = httpClient.PostAsync("https://upload.cc/image_upload", content).ContinueWith(t =>
-                            {
-                                if (t.IsCanceled || t.IsFaulted)
-                                {
-                                    return 0;
-                                }
-
-                                var res = t.Result;
-                                if (res.IsSuccessStatusCode)
-                                {
-                                    string s = res.Content.ReadAsStringAsync().Result;
-                                    var token = JObject.Parse(s);
-                                    if ((int)token["code"] == 100)
+                                    try
                                     {
-                                        url = "https://upload.cc/" + (string)token["success_image"][0]["url"];
+                                        string s = res.Content.ReadAsStringAsync().Result;
+                                        var token = JObject.Parse(s);
+                                        url = (string)token["data"]["url"];
                                         return 1;
                                     }
+                                    catch
+                                    {
+                                        return 2;
+                                    }
                                 }
 
                                 return 2;
@@ -412,67 +257,7 @@ namespace Common
                 }
             }
 
-            if (success)
-            {
-                return (url, success);
-            }
-
-            return UploadImageFallback2(file);
-        }
-
-        /// <summary>
-        /// 上传图片到upload.otar.im图床
-        /// </summary>
-        /// <returns></returns>
-        private static (string, bool) UploadImageFallback2(string file)
-        {
-            string url = string.Empty;
-            bool success = false;
-            using (var fs = File.OpenRead(file))
-            {
-                using (HttpClient httpClient = new HttpClient())
-                {
-                    httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Mozilla/5.0"));
-                    using (var bc = new StreamContent(fs))
-                    {
-                        bc.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
-                        {
-                            FileName = Path.GetFileName(file),
-                            Name = "img"
-                        };
-                        using (var content = new MultipartFormDataContent
-                        {
-                            bc
-                        })
-                        {
-                            var code = httpClient.PostAsync("http://upload.otar.im/api/upload/imgur", content).ContinueWith(t =>
-                            {
-                                if (t.IsCanceled || t.IsFaulted)
-                                {
-                                    return 0;
-                                }
-
-                                var res = t.Result;
-                                if (res.IsSuccessStatusCode)
-                                {
-                                    string s = res.Content.ReadAsStringAsync().Result;
-                                    var token = JObject.Parse(s);
-                                    url = (string)token["url"];
-                                    return 1;
-                                }
-
-                                return 2;
-                            }).Result;
-                            if (code == 1)
-                            {
-                                success = true;
-                            }
-                        }
-                    }
-                }
-            }
-
-            return (url, success);
+            return success ? (url, true) : UploadOss(file);
         }
 
         /// <summary>

+ 12 - 0
src/Masuit.MyBlogs.Core/Configs/AliOssConfig.cs

@@ -0,0 +1,12 @@
+namespace Masuit.MyBlogs.Core.Configs
+{
+    public class AliOssConfig
+    {
+        public bool Enabled { get; set; }
+        public string EndPoint { get; set; }
+        public string BucketDomain { get; set; }
+        public string AccessKeyId { get; set; }
+        public string AccessKeySecret { get; set; }
+        public string BucketName { get; set; }
+    }
+}

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

@@ -19,5 +19,10 @@
         /// Redis连接字符串
         /// </summary>
         public static string Redis { get; set; }
+
+        /// <summary>
+        /// OSS配置
+        /// </summary>
+        public static AliOssConfig AliOssConfig { get; set; } = new AliOssConfig();
     }
 }

+ 3 - 2
src/Masuit.MyBlogs.Core/Controllers/FileController.cs

@@ -168,10 +168,11 @@ namespace Masuit.MyBlogs.Core.Controllers
                     break;
                 case "rename":
                 case "move":
-                    path = Path.Combine(root, req.Item.TrimStart('\\', '/'));
-                    var newpath = Path.Combine(root, req.NewItemPath);
+                    string newpath;
                     if (!string.IsNullOrEmpty(req.Item))
                     {
+                        newpath = Path.Combine(root, req.NewItemPath?.TrimStart('\\', '/'));
+                        path = Path.Combine(root, req.Item.TrimStart('\\', '/'));
                         try
                         {
                             System.IO.File.Move(path, newpath);

+ 15 - 14
src/Masuit.MyBlogs.Core/Controllers/PostController.cs

@@ -41,15 +41,11 @@ namespace Masuit.MyBlogs.Core.Controllers
         private ICategoryService CategoryService { get; set; }
         private IBroadcastService BroadcastService { get; set; }
         private ISeminarService SeminarService { get; set; }
+        private IPostHistoryVersionService PostHistoryVersionService { get; set; }
 
         private readonly IHostingEnvironment _hostingEnvironment;
         private readonly ISearchEngine<DataContext> _searchEngine;
 
-        /// <summary>
-        /// 
-        /// </summary>
-        public IPostHistoryVersionService PostHistoryVersionService { get; set; }
-
         /// <summary>
         /// 文章管理
         /// </summary>
@@ -779,7 +775,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         [HttpPost, Authority]
         public ActionResult Edit(PostInputDto post, bool notify = true, bool reserve = true)
         {
-            post.Content = CommonHelper.ReplaceImgSrc(Regex.Replace(post.Content.Trim(), @"<img\s+[^>]*\s*src\s*=\s*['""]?(\S+\.\w{3,4})['""]?[^/>]*/>", "<img src=\"$1\"/>")).Replace("/thumb150/", "/large/");
+            post.Content = CommonHelper.ReplaceImgSrc(Regex.Replace(post.Content.Trim(), @"<img\s+[^>]*\s*src\s*=\s*['""]?(\S+\.\w{3,4})['""]?[^/>]*/>", "<img src=\"$1\"/>"));
             if (!CategoryService.Any(c => c.Id == post.CategoryId && c.Status == Status.Available))
             {
                 return ResultData(null, message: "请选择一个分类");
@@ -963,14 +959,19 @@ namespace Masuit.MyBlogs.Core.Controllers
                     cast.ForEach(c =>
                     {
                         var ts = DateTime.Now.GetTotalMilliseconds();
-                        string content = System.IO.File.ReadAllText(_hostingEnvironment.WebRootPath + "/template/broadcast.html").Replace("{{link}}", link + "?email=" + c.Email).Replace("{{time}}", post.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss")).Replace("{{title}}", post.Title).Replace("{{author}}", post.Author).Replace("{{content}}", post.Content.RemoveHtmlTag(150)).Replace("{{cancel}}", Url.Action("Subscribe", "Subscribe", new
-                        {
-                            c.Email,
-                            act = "cancel",
-                            validate = c.ValidateCode,
-                            timespan = ts,
-                            hash = (c.Email + "cancel" + c.ValidateCode + ts).AESEncrypt(AppConfig.BaiduAK)
-                        }, Request.Scheme));
+                        string content = System.IO.File.ReadAllText(_hostingEnvironment.WebRootPath + "/template/broadcast.html")
+                            .Replace("{{link}}", link + "?email=" + c.Email)
+                            .Replace("{{time}}", post.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss"))
+                            .Replace("{{title}}", post.Title).Replace("{{author}}", post.Author)
+                            .Replace("{{content}}", post.Content.RemoveHtmlTag(150))
+                            .Replace("{{cancel}}", Url.Action("Subscribe", "Subscribe", new
+                            {
+                                c.Email,
+                                act = "cancel",
+                                validate = c.ValidateCode,
+                                timespan = ts,
+                                hash = (c.Email + "cancel" + c.ValidateCode + ts).AESEncrypt(AppConfig.BaiduAK)
+                            }, Request.Scheme));
                         BackgroundJob.Schedule(() => CommonHelper.SendMail(CommonHelper.SystemSettings["Title"] + "博客有新文章发布了", content, c.Email), (p.ModifyDate - DateTime.Now));
                     });
                 }

+ 0 - 43
src/Masuit.MyBlogs.Core/Controllers/SubscribeController.cs

@@ -1,7 +1,5 @@
 using Common;
-using EFSecondLevelCache.Core;
 using Hangfire;
-using Masuit.LuceneEFCore.SearchEngine.Extensions;
 using Masuit.MyBlogs.Core.Configs;
 using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
@@ -12,11 +10,9 @@ using Masuit.Tools.Logging;
 using Masuit.Tools.Security;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.Net.Http.Headers;
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using WilderMinds.RssSyndication;
 
 namespace Masuit.MyBlogs.Core.Controllers
 {
@@ -50,45 +46,6 @@ namespace Masuit.MyBlogs.Core.Controllers
             _hostingEnvironment = hostingEnvironment;
         }
 
-        /// <summary>
-        /// RSS订阅
-        /// </summary>
-        /// <returns></returns>
-        [Route("rss"), ResponseCache(Duration = 600, VaryByHeader = HeaderNames.Cookie)]
-        public IActionResult Rss()
-        {
-            var time = DateTime.Now.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(),
-                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),
-                Copyright = "(c) 2019"
-            };
-            feed.Items.AddRange(posts.ToArray());
-            var rss = feed.Serialize();
-            return Content(rss);
-        }
-
         /// <summary>
         /// 邮箱订阅
         /// </summary>

+ 9 - 8
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -61,27 +61,28 @@
 
 
   <ItemGroup>
+    <PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.9.1" />
     <PackageReference Include="Aspose.Words" Version="18.11.0" />
     <PackageReference Include="Autofac" Version="4.9.2" />
     <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.4.0" />
-    <PackageReference Include="AutoMapper" Version="8.0.0" />
+    <PackageReference Include="AutoMapper" Version="8.1.0" />
     <PackageReference Include="CacheManager.Microsoft.Extensions.Caching.Memory" Version="1.2.0" />
     <PackageReference Include="CacheManager.Serialization.Json" Version="1.2.0" />
-    <PackageReference Include="CSRedisCore" Version="3.0.48" />
-    <PackageReference Include="EFSecondLevelCache.Core" Version="1.7.1" />
-    <PackageReference Include="Hangfire" Version="1.7.0" />
+    <PackageReference Include="CSRedisCore" Version="3.0.53" />
+    <PackageReference Include="EFSecondLevelCache.Core" Version="1.7.2" />
+    <PackageReference Include="Hangfire" Version="1.7.1" />
     <PackageReference Include="Hangfire.Autofac" Version="2.3.1" />
     <PackageReference Include="Hangfire.MemoryStorage" Version="1.6.0" />
     <PackageReference Include="Hangfire.Redis.StackExchange" Version="1.8.0" />
     <PackageReference Include="htmldiff.net-core" Version="1.3.6" />
     <PackageReference Include="Microsoft.AspNetCore.App" />
-    <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.3" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.4" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
     <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.2.1" />
-    <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="1.8.24" />
+    <PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="2.2.4" />
+    <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="1.8.26" />
     <PackageReference Include="Z.ExtensionMethods" Version="2.1.1" />
   </ItemGroup>
 

+ 8 - 33
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.xml

@@ -87,36 +87,17 @@
             <param name="content">内容</param>
             <param name="tos">收件人</param>
         </member>
-        <member name="M:Common.CommonHelper.UploadImage(System.String)">
+        <member name="P:Common.CommonHelper.OssClient">
             <summary>
-            上传图片到新浪图床
+            OSS客户端
             </summary>
-            <returns></returns>
-        </member>
-        <member name="M:Common.CommonHelper.UploadPeople(System.String)">
-            <summary>
-            上传图片到人民网图床
-            </summary>
-            <returns></returns>
         </member>
-        <member name="M:Common.CommonHelper.UploadSmmsImage(System.String)">
+        <member name="M:Common.CommonHelper.UploadSmms(System.String)">
             <summary>
             上传图片到sm图床
             </summary>
             <returns></returns>
         </member>
-        <member name="M:Common.CommonHelper.UploadImageFallback(System.String)">
-            <summary>
-            上传图片到upload.cc图床
-            </summary>
-            <returns></returns>
-        </member>
-        <member name="M:Common.CommonHelper.UploadImageFallback2(System.String)">
-            <summary>
-            上传图片到upload.otar.im图床
-            </summary>
-            <returns></returns>
-        </member>
         <member name="M:Common.CommonHelper.ReplaceImgSrc(System.String)">
             <summary>
             替换img标签的src属性
@@ -235,6 +216,11 @@
             Redis连接字符串
             </summary>
         </member>
+        <member name="P:Masuit.MyBlogs.Core.Configs.AppConfig.AliOssConfig">
+            <summary>
+            OSS配置
+            </summary>
+        </member>
         <member name="T:Masuit.MyBlogs.Core.Configs.HangfireJobInit">
             <summary>
             hangfire配置
@@ -1259,11 +1245,6 @@
             文章管理
             </summary>
         </member>
-        <member name="P:Masuit.MyBlogs.Core.Controllers.PostController.PostHistoryVersionService">
-            <summary>
-            
-            </summary>
-        </member>
         <member name="M:Masuit.MyBlogs.Core.Controllers.PostController.#ctor(Masuit.MyBlogs.Core.Infrastructure.Services.Interface.IPostService,Masuit.MyBlogs.Core.Infrastructure.Services.Interface.ICategoryService,Masuit.MyBlogs.Core.Infrastructure.Services.Interface.IBroadcastService,Masuit.MyBlogs.Core.Infrastructure.Services.Interface.ISeminarService,Masuit.MyBlogs.Core.Infrastructure.Services.Interface.IPostHistoryVersionService,Microsoft.AspNetCore.Hosting.IHostingEnvironment,Masuit.LuceneEFCore.SearchEngine.Interfaces.ISearchEngine{Masuit.MyBlogs.Core.Infrastructure.DataContext})">
             <summary>
             文章管理
@@ -1687,12 +1668,6 @@
             <param name="postService"></param>
             <param name="hostingEnvironment"></param>
         </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>
             邮箱订阅

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

@@ -67,7 +67,7 @@ namespace Masuit.MyBlogs.Core
             AppConfig.ConnString = configuration[nameof(AppConfig.ConnString)];
             AppConfig.BaiduAK = configuration[nameof(AppConfig.BaiduAK)];
             AppConfig.Redis = configuration[nameof(AppConfig.Redis)];
-            //AppConfig.EnableViewCompress = Convert.ToBoolean(configuration[nameof(AppConfig.EnableViewCompress)]);
+            configuration.Bind("AliyunOSS", AppConfig.AliOssConfig);
         }
 
         /// <summary>

+ 1 - 0
src/Masuit.MyBlogs.Core/Views/Dashboard/Index.cshtml

@@ -8,6 +8,7 @@
     <meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1">
+    <meta name="referrer" content="no-referrer">
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <meta http-equiv="X-UA-Compatible" content="IE=8">
     <meta http-equiv="Expires" content="0">

+ 1 - 2
src/Masuit.MyBlogs.Core/Views/Shared/_Layout.cshtml

@@ -4,7 +4,6 @@
 @using Masuit.MyBlogs.Core.Models.ViewModel
 @using Masuit.Tools
 @using Masuit.Tools.Core.Net
-@using Masuit.Tools.Win32
 @{
     string[] colors = { "success", "info", "warning", "danger", "default" };
     IList<MenuOutputDto> menus = ViewBag.menus;
@@ -18,6 +17,7 @@
     <meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
+    <meta name="referrer" content="no-referrer">
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <meta http-equiv="X-UA-Compatible" content="IE=8">
     <meta http-equiv="Expires" content="0">
@@ -44,7 +44,6 @@
     <link href="~/Content/microtip.min.css" rel="stylesheet" />
     <link href="~/Assets/breadcrumb/style.css" rel="stylesheet" />
     <link href="~/Assets/nav/css/style.css" rel="stylesheet" />
-    @*<link href="~/Assets/tab/styles.css" rel="stylesheet" />*@
     <link href="~/Assets/tippy/tippy.css" rel="stylesheet" />
 
     <script src="https://cdn.staticfile.org/bluebird/3.5.3/bluebird.min.js"></script>

+ 24 - 16
src/Masuit.MyBlogs.Core/appsettings.json

@@ -1,16 +1,24 @@
-锘縶
-    "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",
-    "BaiduAK": "鎮ㄧ殑BaiduAK",
-    "Redis": "127.0.0.1:6379,allowadmin=true,connectTimeout=20000,connectRetry=1,responseTimeout=20000,syncTimeout=10000"
-}
+{
+	"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",
+	"BaiduAK":"您的BaiduAK",
+	"Redis":"127.0.0.1:6379,allowadmin=true,connectTimeout=20000,connectRetry=1,responseTimeout=20000,syncTimeout=10000",
+    "AliyunOSS": {
+        "Enabled": true, // 是否启用阿里云OSS
+        "EndPoint": "阿里云OSS节点",
+        "BucketDomain": "阿里云OSS bucket节点访问地址",
+        "AccessKeyId": "OSS AccessKeyId",
+        "AccessKeySecret": "OSS AccessKeySecret",
+        "BucketName": "BucketName"
+    }
+}

+ 1 - 1
src/Masuit.MyBlogs.Core/ueconfig.json

@@ -38,7 +38,7 @@
     "snapscreenInsertAlign": "none", /* 插入的图片浮动方式 */
 
     /* 抓取远程图片配置 */
-    "catcherLocalDomain": [ "127.0.0.1", "localhost", "img.baidu.com","sinaimg.cn" ],
+    "catcherLocalDomain": [ "127.0.0.1", "localhost", "img.baidu.com", "sinaimg.cn", "aliyuncs.com","loli.net" ],
     "catcherActionName": "catchimage", /* 执行抓取远程图片的action名称 */
     "catcherFieldName": "source", /* 提交的图片列表表单名称 */
     "catcherPathFormat": "/upload/images/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */