|
|
@@ -1,216 +1,267 @@
|
|
|
@model PostMergeRequest
|
|
|
@using Masuit.MyBlogs.Core.Models.Entity
|
|
|
@{
|
|
|
- ViewBag.Title = "正在编辑:" + Model.Post.Title;
|
|
|
- Layout = "~/Views/Shared/_Layout.cshtml";
|
|
|
+ ViewBag.Title = "正在编辑:" + Model.Post.Title;
|
|
|
+ Layout = "~/Views/Shared/_Layout.cshtml";
|
|
|
}
|
|
|
-<link href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.min.css" rel="stylesheet">
|
|
|
<div class="container">
|
|
|
- <ol class="cd-breadcrumb triangle">
|
|
|
- <li><a asp-controller="Home" asp-action="Index">首页</a></li>
|
|
|
- <li><a asp-controller="Home" asp-action="Post">文章列表</a></li>
|
|
|
- @if(Model.Post.Category.ParentId>0) {
|
|
|
- if(Model.Post.Category.Parent.ParentId>0) {
|
|
|
- <li><a asp-controller="Home" asp-action="Category" asp-route-id="@Model.Post.Category.Parent.ParentId">@Model.Post.Category.Parent.Parent.Name</a></li>
|
|
|
- }
|
|
|
- <li><a asp-controller="Home" asp-action="Category" asp-route-id="@Model.Post.Category.ParentId">@Model.Post.Category.Parent.Name</a></li>
|
|
|
- }
|
|
|
- <li><a asp-controller="Home" asp-action="Category" asp-route-id="@Model.Post.CategoryId">@Model.Post.Category.Name</a></li>
|
|
|
- <li>@Html.ActionLink(Model.Post.Title.Length > 50 ? Model.Post.Title.Substring(0, 50) + "..." : Model.Post.Title, "Details", "Post", new { id = Model.Post.Id }, null)</li>
|
|
|
- <li class="current"><em>重新编辑合并请求</em></li>
|
|
|
- </ol>
|
|
|
- <hr />
|
|
|
- <form class="form-group" id="merge-form" method="post">
|
|
|
- @Html.AntiForgeryToken()
|
|
|
- <div class="input-group">
|
|
|
- <span class="input-group-addon size18"><label for="title">文章标题:</label></span>
|
|
|
- <input type="text" id="title" class="form-control input-lg" name="Title" required placeholder="请输入文章标题" value="@Model.Title">
|
|
|
- <input type="hidden" name="PostId" value="@Model.Post.Id">
|
|
|
- <input type="hidden" name="Id" value="@Model.Id">
|
|
|
- </div>
|
|
|
- <div class="form-group overlay animated bounceInDown">
|
|
|
- <textarea id="editor" style="height: calc(100vh - 350px);" class="ueditor" name="Content" type="text/plain">@Model.Content</textarea>
|
|
|
- </div>
|
|
|
- <div class="row">
|
|
|
- <div class="col-md-4 col-sm-4">
|
|
|
- <div class="input-group">
|
|
|
- <span class="input-group-addon"><label for="Modifier">提交人:</label></span>
|
|
|
- <input type="text" class="form-control" id="Modifier" name="Modifier" required placeholder="投稿人真名或网名(非常重要)">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="col-md-4 col-sm-4">
|
|
|
- <div class="input-group">
|
|
|
- <span class="input-group-addon"><label for="ModifierEmail">你的邮箱:</label></span>
|
|
|
- <input type="email" class="form-control" id="ModifierEmail" name="ModifierEmail" required placeholder="您的电子邮箱(非常重要)">
|
|
|
- <span class="input-group-btn">
|
|
|
- <button type="button" id="getcode" class="btn btn-danger">
|
|
|
- 获取验证码
|
|
|
- </button>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="col-md-4 col-sm-4">
|
|
|
- <div class="input-group">
|
|
|
- <span class="input-group-addon"><label for="Code">验证码:</label></span>
|
|
|
- <input type="text" class="form-control" id="Code" name="Code" required placeholder="验证码">
|
|
|
- <span class="input-group-btn">
|
|
|
- <button type="submit" id="submit" class="btn btn-info">
|
|
|
- <i class="icon-rocket2"></i>
|
|
|
- 马上投递
|
|
|
- </button>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </form>
|
|
|
+ <ol class="cd-breadcrumb triangle">
|
|
|
+ <li>
|
|
|
+ <a asp-action="Index" asp-controller="Home">首页</a>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <a asp-action="Post" asp-controller="Home">文章列表</a>
|
|
|
+ </li>
|
|
|
+ @if (Model.Post.Category.ParentId > 0) {
|
|
|
+ if (Model.Post.Category.Parent.ParentId > 0) {
|
|
|
+ <li>
|
|
|
+ <a asp-action="Category" asp-controller="Home" asp-route-id="@Model.Post.Category.Parent.ParentId">@Model.Post.Category.Parent.Parent.Name</a>
|
|
|
+ </li>
|
|
|
+ }
|
|
|
+
|
|
|
+ <li>
|
|
|
+ <a asp-action="Category" asp-controller="Home" asp-route-id="@Model.Post.Category.ParentId">@Model.Post.Category.Parent.Name</a>
|
|
|
+ </li>
|
|
|
+ }
|
|
|
+ <li>
|
|
|
+ <a asp-action="Category" asp-controller="Home" asp-route-id="@Model.Post.CategoryId">@Model.Post.Category.Name</a>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ @Html.ActionLink(Model.Post.Title.Length > 50 ? Model.Post.Title.Substring(0, 50) + "..." : Model.Post.Title, "Details", "Post", new {
|
|
|
+ id = Model.Post.Id
|
|
|
+ }, null)
|
|
|
+ </li>
|
|
|
+ <li class="current">
|
|
|
+ <em>重新编辑合并请求</em>
|
|
|
+ </li>
|
|
|
+ </ol>
|
|
|
+ <hr/>
|
|
|
+ <div class="form-group" id="mergeApp">
|
|
|
+ @Html.AntiForgeryToken()
|
|
|
+ <div class="input-group">
|
|
|
+ <span class="input-group-addon size18">
|
|
|
+ <label for="title">文章标题:</label>
|
|
|
+ </span>
|
|
|
+ <input class="form-control input-lg" id="title" placeholder="请输入文章标题" required type="text" v-model="post.Title">
|
|
|
+ <input type="hidden" v-model="post.PostId">
|
|
|
+ <input type="hidden" v-model="post.Id">
|
|
|
+ </div>
|
|
|
+ <div class="animated bounceInDown form-group overlay">
|
|
|
+ <textarea class="ueditor" id="editor" style="height: calc(100vh - 350px);" type="text/plain"></textarea>
|
|
|
+ </div>
|
|
|
+ <div class="row">
|
|
|
+ <div class="col-md-4 col-sm-4">
|
|
|
+ <div class="input-group">
|
|
|
+ <span class="input-group-addon">
|
|
|
+ <label for="Modifier">提交人:</label>
|
|
|
+ </span>
|
|
|
+ <input class="form-control" name="Modifier" placeholder="投稿人真名或网名(非常重要)" required type="text" v-model="post.Modifier">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-4 col-sm-4">
|
|
|
+ <div class="input-group">
|
|
|
+ <span class="input-group-addon">
|
|
|
+ <label for="ModifierEmail">你的邮箱:</label>
|
|
|
+ </span>
|
|
|
+ <input class="form-control" id="ModifierEmail" name="ModifierEmail" placeholder="您的电子邮箱(非常重要)" required type="email" v-model="post.ModifierEmail">
|
|
|
+ <span class="input-group-btn">
|
|
|
+ <button :disabled="disableGetcode" @@click="getcode(post.ModifierEmail)" class="btn btn-danger" type="button">
|
|
|
+ {{codeMsg}}
|
|
|
+ </button>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-4 col-sm-4">
|
|
|
+ <div class="input-group">
|
|
|
+ <span class="input-group-addon">
|
|
|
+ <label for="Code">验证码:</label>
|
|
|
+ </span>
|
|
|
+ <input class="form-control" id="Code" placeholder="验证码" required type="text" v-model="post.Code">
|
|
|
+ <span class="input-group-btn">
|
|
|
+ <button :disabled="!post.Code" @@click="submit" class="btn btn-info">
|
|
|
+ <i class="icon-rocket2"></i>
|
|
|
+ 马上投递
|
|
|
+ </button>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+<!-- Use style -->
|
|
|
+<link href="https://cdn.jsdelivr.net/npm/[email protected]/lib/style.min.css" rel="stylesheet">
|
|
|
+<link href="https://cdn.jsdelivr.net/npm/[email protected]/lib/style.min.css" rel="stylesheet">
|
|
|
+<!-- Use vue -->
|
|
|
+<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.global.prod.js"></script>
|
|
|
+<!-- Use vxe -->
|
|
|
+<script src="https://cdn.jsdelivr.net/npm/xe-utils/dist/xe-utils.umd.min.js"></script>
|
|
|
+<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/index.umd.min.js"></script>
|
|
|
+<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/index.umd.min.js"></script>
|
|
|
+<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
|
|
<script src="~/UEditorPlus/ueditor.config.front.js"></script>
|
|
|
-<script src="~/UEditorPlus/ueditor.all.js"></script>
|
|
|
-<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.min.js"></script>
|
|
|
+<script charset="utf-8" src="~/UEditorPlus/ueditor.all.js" type="text/javascript"></script>
|
|
|
+<script charset="utf-8" src="~/UEditorPlus/lang/zh-cn/zh-cn.js" type="text/javascript"></script>
|
|
|
<script>
|
|
|
- $(function () {
|
|
|
+const { createApp, ref, onMounted, watch, computed } = Vue;
|
|
|
+createApp({
|
|
|
+ setup() {
|
|
|
+ const post = ref({
|
|
|
+ Title: '@Model.Post.Title',
|
|
|
+ Content: `@Html.Raw(Model.Content)`,
|
|
|
+ Id: '@Model.Id',
|
|
|
+ PostId: '@Model.PostId'
|
|
|
+ });
|
|
|
+ const disableGetcode = ref(false);
|
|
|
+ const codeMsg = ref("获取验证码");
|
|
|
+ return {
|
|
|
+ post,
|
|
|
+ disableGetcode,
|
|
|
+ codeMsg
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async getcode(email) {
|
|
|
+ VxeUI.modal.notification({
|
|
|
+ content: '正在发送验证码,请稍候...',
|
|
|
+ status: 'info',
|
|
|
+ });
|
|
|
+ const data = await axios.create({
|
|
|
+ headers: {
|
|
|
+ 'RequestVerificationToken': document.querySelector('input[name="__RequestVerificationToken"]').value
|
|
|
+ }
|
|
|
+ }).post("/validate/sendcode", {
|
|
|
+ email: email
|
|
|
+ }).then(res => res.data);
|
|
|
+ if (data.Success) {
|
|
|
+ this.disableGetcode = true;
|
|
|
+ VxeUI.modal.notification({
|
|
|
+ content: '验证码发送成功,请注意查收邮件,若未收到,请检查你的邮箱地址或邮件垃圾箱!',
|
|
|
+ status: 'success',
|
|
|
+ });
|
|
|
+ localStorage.setItem("user", JSON.stringify({ NickName: this.post.Author, Email: this.post.Email }));
|
|
|
+ var count = 0;
|
|
|
+ var timer = setInterval(() => {
|
|
|
+ count++;
|
|
|
+ this.codeMsg = '重新发送(' + (120 - count) + ')';
|
|
|
+ if (count > 120) {
|
|
|
+ clearInterval(timer);
|
|
|
+ this.disableGetcode = false;
|
|
|
+ this.codeMsg = '重新发送';
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ VxeUI.modal.notification({
|
|
|
+ content: data.Message,
|
|
|
+ status: 'error',
|
|
|
+ });
|
|
|
+ this.disableGetcode = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+ if (this.post.Title.trim().length <= 2 || this.post.Title.trim().length > 128) {
|
|
|
+ VxeUI.modal.notification({
|
|
|
+ content: '文章标题必须在2到128个字符以内!',
|
|
|
+ status: 'error',
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.post.Modifier.trim().length <= 1 || this.post.Modifier.trim().length > 24) {
|
|
|
+ VxeUI.modal.notification({
|
|
|
+ content: '昵称不能少于2个字符或超过24个字符!',
|
|
|
+ status: 'error',
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!/^\w+([-+.]\w+)*@@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(this.post.ModifierEmail.trim())) {
|
|
|
+ VxeUI.modal.notification({
|
|
|
+ content: '请输入正确的邮箱格式!',
|
|
|
+ status: 'error',
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.post.Content.length < 20 || this.post.Content.length > 1000000) {
|
|
|
+ VxeUI.modal.notification({
|
|
|
+ content: '文章内容过短或者超长,请修改后再提交!',
|
|
|
+ status: 'error',
|
|
|
+ });
|
|
|
+ loadingDone();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ axios.create({
|
|
|
+ headers: {
|
|
|
+ 'RequestVerificationToken': document.querySelector('input[name="__RequestVerificationToken"]').value
|
|
|
+ }
|
|
|
+ }).post("/@Model.Id/pushmerge", this.post).then(res => {
|
|
|
+ const data = res.data;
|
|
|
+ if (data.Success) {
|
|
|
+ VxeUI.modal.notification({
|
|
|
+ content: data.Message,
|
|
|
+ status: 'success',
|
|
|
+ });
|
|
|
+ clearInterval(window.interval);
|
|
|
+ localStorage.removeItem("merge-post-draft-" [email protected]);
|
|
|
+ window.location.href = "/" + this.post.PostId;
|
|
|
+ } else {
|
|
|
+ VxeUI.modal.notification({
|
|
|
+ content: data.Message,
|
|
|
+ status: 'error',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+ created() {
|
|
|
if (window.UE) {
|
|
|
window.ue = UE.getEditor('editor', {
|
|
|
- initialFrameWidth: null
|
|
|
+ initialFrameWidth: null,
|
|
|
+ initialFrameHeight:document.body.offsetHeight-160
|
|
|
});
|
|
|
+
|
|
|
+ ue.addListener('ready',() => {
|
|
|
+ ue.setContent(this.post.Content);
|
|
|
+ });
|
|
|
}
|
|
|
- @if(Model.Post.DisableCopy) {
|
|
|
- <text>
|
|
|
+ @if (Model.Post.DisableCopy) {
|
|
|
+ <text>
|
|
|
CopyrightProtect();
|
|
|
CopyrightProtect4Editor();
|
|
|
</text>
|
|
|
- }
|
|
|
- var user = JSON.parse(localStorage.getItem("user"));
|
|
|
+ }
|
|
|
+ var user = JSON.parse(localStorage.getItem("user"));
|
|
|
if (user) {
|
|
|
- $("[name='Modifier']").val(user.NickName);
|
|
|
- $("[name='ModifierEmail']").val(user.Email);
|
|
|
+ this.post.Modifier=user.NickName;
|
|
|
+ this.post.ModifierEmail=user.Email;
|
|
|
}
|
|
|
|
|
|
//检查草稿
|
|
|
- if (localStorage.getItem("merge-post-draft-" [email protected])) {
|
|
|
- notie.confirm({
|
|
|
- text: "检查到上次有未提交的草稿,是否加载?",
|
|
|
- submitText: "确定",
|
|
|
- cancelText: "取消",
|
|
|
- position: "bottom",
|
|
|
- submitCallback: function () {
|
|
|
- var post = JSON.parse(localStorage.getItem("merge-post-draft-" [email protected]));
|
|
|
- $("#title").val(post.Title);
|
|
|
- ue.setContent(post.Content);
|
|
|
- window.interval = setInterval(function () {
|
|
|
- localStorage.setItem("merge-post-draft-"[email protected],JSON.stringify($("#merge-form").serializeObject()));
|
|
|
- },5000);
|
|
|
- },
|
|
|
- cancelCallback: function() {
|
|
|
- window.interval = setInterval(function () {
|
|
|
- localStorage.setItem("merge-post-draft-"[email protected],JSON.stringify($("#merge-form").serializeObject()));
|
|
|
- },5000);
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- window.interval = setInterval(function () {
|
|
|
- localStorage.setItem("merge-post-draft-"[email protected],JSON.stringify($("#merge-form").serializeObject()));
|
|
|
- },5000);
|
|
|
+ if (localStorage.getItem("merge-post-draft-" [email protected])) {
|
|
|
+ VxeUI.modal.confirm({
|
|
|
+ title: '草稿箱',
|
|
|
+ content: '检查到上次有未提交的草稿,是否加载?',
|
|
|
+ mask: false,
|
|
|
+ lockView: false
|
|
|
+ }).then(type => {
|
|
|
+ if (type == 'confirm') {
|
|
|
+ this.post = JSON.parse(localStorage.getItem("merge-post-draft-" [email protected]));
|
|
|
+ ue.setContent(this.post.Content);
|
|
|
+ window.interval = setInterval(() => {
|
|
|
+ this.post.Content = ue.getContent();
|
|
|
+ localStorage.setItem("merge-post-draft-" [email protected], JSON.stringify(this.post));
|
|
|
+ }, 5000);
|
|
|
+ } else {
|
|
|
+ window.interval = setInterval(() => {
|
|
|
+ this.post.Content = ue.getContent();
|
|
|
+ localStorage.setItem("merge-post-draft-" [email protected], JSON.stringify(this.post));
|
|
|
+ }, 5000);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ window.interval = setInterval(() => {
|
|
|
+ this.post.Content = ue.getContent();
|
|
|
+ localStorage.setItem("merge-post-draft-" [email protected], JSON.stringify(this.post));
|
|
|
+ }, 5000);
|
|
|
}
|
|
|
-
|
|
|
- $("#getcode").on("click", function (e) {
|
|
|
- e.preventDefault();
|
|
|
- layer.tips('正在发送验证码,请稍候...', '#getcode', {
|
|
|
- tips: [1, '#3595CC'],
|
|
|
- time: 30000
|
|
|
- });
|
|
|
- $("#getcode").attr('disabled', true);
|
|
|
- $.post("/validate/sendcode", {
|
|
|
- __RequestVerificationToken: $("[name=__RequestVerificationToken]").val(),
|
|
|
- email: $("#ModifierEmail").val()
|
|
|
- }, function (data) {
|
|
|
- if (data.Success) {
|
|
|
- layer.tips('验证码发送成功,请注意查收邮件,若未收到,请检查你的邮箱地址或邮件垃圾箱!', '#getcode', {
|
|
|
- tips: [1, '#3595CC'],
|
|
|
- time: 5000
|
|
|
- });
|
|
|
- user.NickName = $("[name='Modifier']").val();
|
|
|
- user.Email = $("[name='ModifierEmail']").val();
|
|
|
- localStorage.setItem("user", JSON.stringify(user));
|
|
|
- var count = 0;
|
|
|
- var timer = setInterval(function () {
|
|
|
- count++;
|
|
|
- $("#getcode").text('重新发送(' + (120 - count) + ')');
|
|
|
- if (count > 120) {
|
|
|
- clearInterval(timer);
|
|
|
- $("#getcode").attr('disabled', false);
|
|
|
- $("#getcode").text('重新发送');
|
|
|
- }
|
|
|
- }, 1000);
|
|
|
- } else {
|
|
|
- layer.tips(data.Message, '#getcode', {
|
|
|
- tips: [1, '#3595CC'],
|
|
|
- time: 5000
|
|
|
- });
|
|
|
- $("#getcode").attr('disabled', false);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- //异步提交表单开始
|
|
|
- $("#merge-form").on("submit", function (e) {
|
|
|
- e.preventDefault();
|
|
|
- loading();
|
|
|
- var formData = $(this).serializeObject();
|
|
|
- if (formData["Title"].trim().length <= 2 || formData["Title"].trim().length > 128) {
|
|
|
- window.notie.alert({
|
|
|
- type: 3,
|
|
|
- text: '文章标题必须在2到128个字符以内!',
|
|
|
- time: 4
|
|
|
- });
|
|
|
- loadingDone();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (formData["Modifier"].trim().length < 2 || formData["Modifier"].trim().length > 36) {
|
|
|
- window.notie.alert({
|
|
|
- type: 3,
|
|
|
- text: '修改人名字至少2个字,最多36个字!',
|
|
|
- time: 4
|
|
|
- });
|
|
|
- loadingDone();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!/^\w+([-+.]\w+)*@@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test($("#ModifierEmail").val().trim())) {
|
|
|
- window.notie.alert({
|
|
|
- type: 3,
|
|
|
- text: '请输入正确的邮箱格式!',
|
|
|
- time: 4
|
|
|
- });
|
|
|
- loadingDone();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (ue.getContent().length < 200 || ue.getContent().length > 1000000) {
|
|
|
- window.notie.alert({
|
|
|
- type: 3,
|
|
|
- text: '文章内容过短或者超长的,字数200-1000000字!',
|
|
|
- time: 4
|
|
|
- });
|
|
|
- loadingDone();
|
|
|
- return;
|
|
|
- }
|
|
|
- $.post("/@Model.Post.Id/pushmerge", $(this).serialize(), function(data) {
|
|
|
- loadingDone();
|
|
|
- if (data.Success) {
|
|
|
- window.notie.alert({
|
|
|
- type: 1,
|
|
|
- text: data.Message,
|
|
|
- time: 4
|
|
|
- });
|
|
|
- $("[name='Title']").val("");
|
|
|
- ue.setContent("");
|
|
|
- } else {
|
|
|
- window.notie.alert({
|
|
|
- type: 3,
|
|
|
- text: data.Message,
|
|
|
- time: 4
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
+ }
|
|
|
+}).mount('#mergeApp');
|
|
|
</script>
|