网站首页 网站源码
website
站点相关全部源代码,隐藏了一些关于服务器的信息
@using Microsoft.Extensions.Configuration
@model Dpz.Core.Public.ViewModel.VmTimeline

@inject IConfiguration _configuration
@{
    Layout = null;
    var baseAddress = _configuration["CDNBaseAddress"];
}
<!DOCTYPE html>

<html>
<head>
    <title>保存时间轴</title>
    <link rel="stylesheet" href="@baseAddress/lib/editor.md/css/editormd.min.css"/>
    <link href="@baseAddress/lib/layui/css/layui.css" rel="stylesheet"/>
    <link href="@(_configuration["CDNBaseAddress"])/css/frame-dark.css" rel="stylesheet"/>
    <script src="@baseAddress/lib/jquery/jquery.min.js"></script>
    <script src="@baseAddress/lib/layui/layui.js"></script>
    <script src="@baseAddress/lib/editor.md/editormd.min.js"></script>
</head>
<body>
<form class="layui-form" method="post" asp-action="Publish" id="timelineForm" autocomplete="off" style="padding: 20px">
    <div class="layui-form-item">
        <label asp-for="Title" class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input asp-for="Title" placeholder="请输入标题" required lay-verify="required" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label asp-for="More" class="layui-form-label">更多链接</label>
        <div class="layui-input-block">
            <input asp-for="More" placeholder="请输入更多链接" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label asp-for="Date" class="layui-form-label">日期</label>
        <div class="layui-input-block">
            @if (Model != null)
            {
                <input asp-for="Date" placeholder="请选择日期" value="@Model.Date.ToString("yyyy-MM-dd")" class="layui-input" type="text" required lay-verify="required" readonly>
            }
            else
            {
                <input asp-for="Date" placeholder="请选择日期" class="layui-input" type="text" required lay-verify="required" readonly>
            }
        </div>
    </div>
    <div id="editor">
        <textarea asp-for="Content" rows="10" placeholder="请输入内容" style="display: none"></textarea>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block" style="margin:0">
            @Html.HiddenFor(x => x.Id)
            <button type="button" class="layui-btn" lay-submit lay-filter="timeline">提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
        var closeOrSuccess = 0; // default close value is 0,success values is 1;
        layui.use(["layer", "form", "laydate"], function () {
            let parentIndex = parent.layer.getFrameIndex(window.name);
            let layer = layui.layer,
                form = layui.form,
                layDate = layui.laydate;
            layDate.render({
                elem: '#Date'
            });
            editormd("editor",{
                width: "100%",
                height: $(document).height() - 20 - 38 - $("#timelineForm").height(),
                saveHTMLToTextarea: true,
                imageUpload: true,
                placeholder: "请输入内容",
                imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
                imageUploadURL: "/Timeline/Upload",
                path: "@(_configuration["CDNBaseAddress"])/lib/editor.md/lib/",
                onload: function () {
                    if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
                        this.setTheme("dark");
                        this.setEditorTheme("blackboard");
                        this.setPreviewTheme("dark");
                    }
                },
                toolbarIcons: function () {
                    return [
                        "undo", "redo", "|", "bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|",
                        "h1", "h2", "h3", "h4", "h5", "h6", "|", "list-ul", "list-ol", "hr", "|", "link",
                        "reference-link", "image", "code", "preformatted-text", "code-block", "table", "datetime",
                        "html-entities", "pagebreak", "|", "goto-line", "watch", "preview",
                        "clear", "search"
                    ];
                }
            });
            form.on("submit(timeline)", function (data) {
                let index = layer.load(1);
                $.ajax({
                    url: "/Timeline/Publish",
                    data: data.field,
                    type: "post"
                }).done(function (result) {
                    if (!result.success) {
                        layer.msg(result.msg, { icon: 2, anim: 6 });
                    } else {
                        closeOrSuccess = 1;
                        parent.layer.close(parentIndex);
                    }
                }).fail(function (data) {
                    if (data && data.responseJSON && data.responseJSON.success === false) {
                        layer.alert(data.responseJSON.msg);
                    }
                }).always(function () {
                    layer.close(index);
                });
                return false;
            });
        });

    </script>
</body>
</html>
loading