perf: 新建文章以后直接进入到编辑文章页面

This commit is contained in:
zhanzhenping 2024-07-03 11:40:10 +08:00
parent 38c15ae91e
commit 97bcf03125

View File

@ -20,7 +20,7 @@
</head> </head>
<body> <body>
<div class="manual-reader"> <div class="manual-reader">
{{template "widgets/header.tpl" .}} {{template "widgets/header.tpl" .}}
<div class="container manual-body"> <div class="container manual-body">
<div class="row"> <div class="row">
<div class="page-left"> <div class="page-left">
@ -104,7 +104,7 @@
</div> </div>
</div> </div>
</div> </div>
{{template "widgets/footer.tpl" .}} {{template "widgets/footer.tpl" .}}
</div> </div>
@ -114,6 +114,7 @@
<script src="{{cdnjs "/static/js/main.js"}}" type="text/javascript"></script> <script src="{{cdnjs "/static/js/main.js"}}" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
const blogId = Number($("#blogId").val());
$("#gloablEditForm").ajaxForm({ $("#gloablEditForm").ajaxForm({
beforeSubmit : function () { beforeSubmit : function () {
var title = $.trim($("#title").val()); var title = $.trim($("#title").val());
@ -126,6 +127,10 @@
if($res.errcode === 0) { if($res.errcode === 0) {
showSuccess("{{i18n .Lang "message.success"}}"); showSuccess("{{i18n .Lang "message.success"}}");
$("#blogId").val($res.data.blog_id); $("#blogId").val($res.data.blog_id);
if (blogId === 0) {
// 优化新增文章后直接跳转到编辑页面
window.location.href = {{urlfor "BlogController.ManageEdit" ":id" "xxx"}}.replace("xxx", $res.data.blog_id)
}
}else{ }else{
showError($res.message); showError($res.message);
} }
@ -135,12 +140,12 @@
$("#btnSaveBlogInfo").button("reset"); $("#btnSaveBlogInfo").button("reset");
} }
}).find("input[name='status']").change(function () { }).find("input[name='status']").change(function () {
var $status = $(this).val(); var $status = $(this).val();
if($status === "password"){ if($status === "password"){
$("#blogPassword").show(); $("#blogPassword").show();
}else{ }else{
$("#blogPassword").hide(); $("#blogPassword").hide();
} }
}); });
$("#gloablEditForm").find("input[name='blog_type']").change(function () { $("#gloablEditForm").find("input[name='blog_type']").change(function () {
var $link = $(this).val(); var $link = $(this).val();