<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
    <head th:replace="~{admin/include::head}">
    </head>
    <style>
    .layui-form {
        padding: 18px 50px 1px 10px;background:white;
        box-shadow: 0 10px 20px 0 rgba(236,236,236,.86);
        border-radius: 5px;
    }
    .layui-elem-quote-warning {
        border-left: 5px solid #d8a900;
    }
    .layui-form-mid {
        float: none;    
    }
    </style>
    <body style="background-color: #f2f2f2">
        <ul th:replace="~{admin/include::nav}"></ul>
        
        <div class="manage-body">
            <div>
            <h2 class="manage-title"><b>说说设置</b></h2>
            </div>
            <div class="layui-form" id="editCommentForm" lay-filter="editCommentForm">

                <div class="layui-form-item">
                    <label class="layui-form-label">启用说说</label>
                    <div class="layui-input-block">
                      <input type="checkbox" 
                        th:attr="checked=${@tweetConfig.tweetMode}? ''"
                        th:value="${@tweetConfig.tweetMode}"
                        name="tweetMode" lay-skin="switch" lay-filter="tweetModeSwitch" lay-text="ON|OFF">
                        <div class="layui-form-mid layui-word-aux">是否开启说说模块
                            <br>开启后，启动前端说说路由
                        </div>
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">说说名称<span>*</span></label>
                    <div class="layui-input-block">
                        <input class="layui-input" th:value="${@tweetConfig.name}" name="name" lay-verify="required"/>
                        <div class="layui-form-mid layui-word-aux">Wiki 的名称，一般用于页面 title 和主题显示
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">说说描述<span>*</span></label>
                    <div class="layui-input-block">
                        <input class="layui-input" th:value="${@tweetConfig.description}" name="description" lay-verify="required"/>
                        <div class="layui-form-mid layui-word-aux">一般将其提供给爬虫做 SEO，即首页 header meta description 的 content
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">关键词</label>
                    <div class="layui-input-block">
                        <input class="layui-input" th:value="${@tweetConfig.keywords}" name="keywords"/>
                        <div class="layui-form-mid layui-word-aux">多关键词用英文半角逗号分隔
                            <br>一般将其提供给爬虫做 SEO，即首页 header meta keywords 的 content
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">版权信息</label>
                    <div class="layui-input-block">
                        <input class="layui-input" th:value="${@tweetConfig.copyright}" name="copyright"/>
                        <div class="layui-form-mid layui-word-aux">
                            版权信息
                            <br>部分主题可能不需要设置该参数
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">每页说说数</label>
                    <div class="layui-input-block">
                        <input class="layui-input" th:value="${@tweetConfig.pageSize}" lay-verify="required|number|gt:0" name="pageSize"/>
	                    <div class="layui-form-mid layui-word-aux">
		                    在说说列表页，默认展示的单页说说数
	                    </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">默认评论数<span>*</span></label>
                    <div class="layui-input-block">
                        <input class="layui-input" th:value="${@tweetConfig.commentPageSize}" lay-verify="required|number|gt:0" name="commentPageSize"/>
	                    <div class="layui-form-mid layui-word-aux">
	                        在说说列表页，默认展示的评论数
	                    </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="submit">提交</button>
                    </div>
                </div>
            </div>
        </div>
        </div>
        <div th:replace="~{admin/include::feet}"></div>
        <th:block th:replace="~{admin/include::head-script}"></th:block>
        
        <script>
        layui.use(['form'], function(){
            var form = layui.form;
            form.on('switch(tweetModeSwitch)', function (data){
                var elem = $(data.elem);
                elem.val(!!elem.prop('checked'))
            });
            form.on('submit(submit)', function(data){
                $.ajax({
                    url: location.href,
                    data: JSON.stringify(data.field),
                    contentType: 'application/json',
                    method: 'POST',
                    success: function (result) {
                        layer.msg('保存成功', {time:1000}, function(){
                            location.reload();
                        });
                    },
                    error: function (res) {
                        var r = res.responseJSON;
                        layer.msg(r&&r.data||'服务器错误', {time:2000});
                    }
                });
            });
            form.render();
            
        })
        </script>
    </body>

</html>