HistoryVersion_Admin.cshtml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. @using Masuit.MyBlogs.Core.Common
  2. @using Masuit.MyBlogs.Core.Models.DTO
  3. @using Masuit.MyBlogs.Core.Models.Entity
  4. @using Masuit.MyBlogs.Core.Models.ViewModel
  5. @using Masuit.Tools.Core.Net
  6. @model Masuit.MyBlogs.Core.Models.Entity.PostHistoryVersion
  7. @{
  8. ViewBag.Title = Model.Post.Title + "于" + Model.ModifyDate.ToTimeZoneF(Context.Session.Get<string>(SessionKey.TimeZone)) + "的历史版本:" + Model.Title;
  9. Layout = "~/Views/Shared/_Layout.cshtml";
  10. string[] colors = { "success", "info", "primary", "warning", "danger", "default", "primary" };
  11. AdvertisementDto ad = ViewBag.Ads;
  12. }
  13. <environment names="Development">
  14. <link href="~/Assets/jquery.tocify/jquery.tocify.css" rel="stylesheet" />
  15. <link href="~/Assets/UEditor/third-party/SyntaxHighlighter/styles/shCore.css" rel="stylesheet" />
  16. <script src="/Assets/UEditor/third-party/SyntaxHighlighter/scripts/shCore.js"></script>
  17. <script src="/Assets/UEditor/third-party/SyntaxHighlighter/scripts/bundle.min.js"></script>
  18. <script src="/Assets/jquery.tocify/jquery.tocify.js"></script>
  19. <script src="/Scripts/global/article.js"></script>
  20. </environment>
  21. <environment names="Stage,Production">
  22. @await Styles.RenderAsync("/bundles/article.css")
  23. @await Scripts.RenderAsync("/bundles/article.js")
  24. </environment>
  25. <div class="container">
  26. <ol class="cd-breadcrumb triangle">
  27. <li><a asp-controller="Home" asp-action="Index">首页</a></li>
  28. <li><a asp-controller="Home" asp-action="Post">文章列表</a></li>
  29. @if(Model.Category.ParentId>0) {
  30. if(Model.Category.Parent.ParentId>0) {
  31. <li><a asp-controller="Home" asp-action="Category" asp-route-id="@Model.Category.Parent.ParentId">@Model.Category.Parent.Parent.Name</a></li>
  32. }
  33. <li><a asp-controller="Home" asp-action="Category" asp-route-id="@Model.Category.ParentId">@Model.Category.Parent.Name</a></li>
  34. }
  35. <li><a asp-controller="Home" asp-action="Category" asp-route-id="@Model.CategoryId">@Model.Category.Name</a></li>
  36. <li>@Html.ActionLink(Model.Post.Title.Length > 20 ? Model.Post.Title.Substring(0, 20) + "..." : Model.Post.Title, "Details", "Post", new { id = Model.PostId }, null)</li>
  37. <li><a asp-controller="Post" asp-action="History" asp-route-id="@Model.PostId">历史版本</a></li>
  38. <li class="current"><em>@(Model.Title.Length > 35 ? Model.Title.Substring(0, 35) + "..." : Model.Title)</em></li>
  39. </ol>
  40. <div class="wrapper-content article">
  41. <div class="ibox">
  42. <div class="ibox-content animated fadeIn">
  43. <main>
  44. <section class="history">
  45. <header class="page-header">
  46. <div class="text-center">
  47. <a>
  48. <h2 class="padding-bot10">
  49. @Model.Title
  50. </h2>
  51. </a>
  52. </div>
  53. <div class="row">
  54. <div class="col-sm-7">
  55. <div class="padding-bot10">
  56. <span class="label label-@colors[new Random().Next() % colors.Length]">@Model.Modifier</span>修改于<a asp-controller="Home" asp-action="Archieve" asp-route-yyyy="@Model.ModifyDate.Year" asp-route-mm="@Model.ModifyDate.Month" asp-route-dd="@Model.ModifyDate.Day" asp-route-mode="@nameof(Model.ModifyDate)"><time class="text-success">@Model.ModifyDate.ToTimeZoneF(Context.Session.Get<string>(SessionKey.TimeZone))</time></a> |
  57. 原分类:<i class="icon-map-pin"></i><a asp-controller="Home" asp-action="Category" asp-route-id="@Model.CategoryId" class="label label-@colors[new Random().Next() % colors.Length]">@Model.Category.Name</a>
  58. @if (Model.Seminar.Any())
  59. {
  60. <span> | 原所属专题:</span>
  61. var seminars = Model.Seminar;
  62. foreach (var s in seminars)
  63. {
  64. <a asp-controller="Seminar" asp-action="Index" asp-route-id="@s.Id" class="label label-@colors[new Random().Next() % colors.Length]">@s.Title</a><text> </text>
  65. }
  66. }
  67. <div class="btn-group">
  68. <button class="btn btn-danger btn-sm" id="del">删除此版本</button>
  69. <button class="btn btn-info btn-sm" id="revert">还原到此版本</button>
  70. </div>
  71. </div>
  72. </div>
  73. @{
  74. if (!string.IsNullOrEmpty(Model.Label))
  75. {
  76. <div class="pull-right margin-right20">
  77. <div>
  78. @foreach (string s in Model.Label.Split(',', ',', ' '))
  79. {
  80. if (!string.IsNullOrEmpty(s))
  81. {
  82. <a asp-controller="Home" asp-action="Tag" asp-route-tag="@s">
  83. <span class="label label-@colors[new Random().Next() % colors.Length]">@s</span>
  84. </a>
  85. }
  86. }
  87. </div>
  88. </div>
  89. }
  90. }
  91. </div>
  92. <p class="text-focus text-center">您目前正在查看该文章的历史版本,文章的历史版本可能无法为您提供最准确及时的资讯,不具备任何参考价值,<a asp-controller="Post" asp-action="Details" asp-route-id="@Model.PostId">点击前往</a>该文章的最新版本。</p>
  93. </header>
  94. <article class="article" id="article">
  95. @Html.Raw(Model.Content)
  96. @Html.Raw(Model.ProtectContent)
  97. </article>
  98. <div id="cyReward" role="cylabs" data-use="reward"></div>
  99. </section>
  100. </main>
  101. <hr />
  102. <section class="wow fadeInUp row size16">
  103. <div class="col-xs-6">
  104. 前一版本:
  105. @{
  106. PostHistoryVersion prev = ViewBag.Prev;
  107. if (prev != null)
  108. {
  109. <a asp-controller="Post" asp-action="HistoryVersion" asp-route-id="@prev.PostId" asp-route-hid="@prev.Id">@prev.Title</a>
  110. }
  111. else
  112. {
  113. <a>没有了</a>
  114. }
  115. }
  116. </div>
  117. <div class="col-xs-6 text-right">
  118. 下一版本:
  119. @{
  120. PostHistoryVersion next = ViewBag.Next;
  121. if (next != null)
  122. {
  123. <a asp-controller="Post" asp-action="HistoryVersion" asp-route-id="@next.PostId" asp-route-hid="@next.Id">@next.Title</a>
  124. }
  125. else
  126. {
  127. <a>没有了</a>
  128. }
  129. }
  130. </div>
  131. </section>
  132. <hr class="margin-top10 marginbot10" />
  133. @if (ad != null)
  134. {
  135. await Html.RenderPartialAsync("_ArticleListAdvertisement", ad);
  136. }
  137. </div>
  138. </div>
  139. </div>
  140. </div>
  141. <script>
  142. $(function() {
  143. $("#toc").show();
  144. var toc = $("#toc").tocify({
  145. selectors: ".ibox-content h3,.ibox-content h4,.ibox-content h5"
  146. }).data("toc-tocify");
  147. $(".tocify>.close").on("click", function(e) {
  148. $(this).parent().hide();
  149. });
  150. SyntaxHighlighter.all();
  151. SyntaxHighlighter.defaults['toolbar'] = false;
  152. $("#del").on("click", function (e) {
  153. swal({
  154. title: "确认删除这个版本吗?",
  155. text: '@Model.Title',
  156. showCancelButton: true,
  157. confirmButtonColor: "#DD6B55",
  158. confirmButtonText: "确定",
  159. cancelButtonText: "取消",
  160. showLoaderOnConfirm: true,
  161. animation: true,
  162. allowOutsideClick: false
  163. }).then(function () {
  164. $.post("/post/DeleteHistory", {
  165. id: @Model.Id
  166. }, function (data) {
  167. window.notie.alert({
  168. type: 1,
  169. text: data.Message,
  170. time: 4
  171. });
  172. location.href="/@Model.PostId/history";
  173. });
  174. }, function () {
  175. });
  176. });
  177. $("#revert").on("click", function (e) {
  178. swal({
  179. title: "确认还原到这个版本吗?",
  180. text: '@Model.Title',
  181. showCancelButton: true,
  182. confirmButtonColor: "#DD6B55",
  183. confirmButtonText: "确定",
  184. cancelButtonText: "取消",
  185. showLoaderOnConfirm: true,
  186. animation: true,
  187. allowOutsideClick: false
  188. }).then(function () {
  189. $.post("/post/revert", {
  190. id: @Model.Id
  191. }, function (data) {
  192. window.notie.alert({
  193. type: 1,
  194. text: data.Message,
  195. time: 4
  196. });
  197. location.href="/@Model.PostId";
  198. });
  199. }, function () {
  200. });
  201. });
  202. })
  203. </script>