具体的な変更内容は図に示されています:

具体的には、何秒間保存されたか!
文章の文字数を同時に表示するため、ユーザーが自身の記事を簡単に確認できるようになっています!
チュートリアルの編集:
ファイルを開く:/admin/views/article_write.phpコードを検索:
<label>文章摘要:</label>約18行です!
このコード段落に次のコードを追加してください:
<span id="save_info2"></span><br>編集後のスクリーンショット:

第2段階:修正
ファイルを開く/admin/views/js/common.js関数を検索するautosave
関数を以下のように置き換えてください:
function autosave(act) {
const nodeid = "as_logid";
const timeout = 60000;
const url = "article_save.php?action=autosave";
const alias = $.trim($("#alias").val());
const content = Editor.getMarkdown();
let ishide = $.trim($("#ishide").val());
if (ishide === "") {
$("#ishide").val("y")
}
if (alias != '' && 0 != isalias(alias)) {
$("#msg").show().html("链接别名错误,自动保存失败");
if (act == 0) {
setTimeout("autosave(1)", timeout);
}
return;
}
// 编辑发布状态的文章时不自动保存
if (act == 1 && ishide == 'n') {
return;
}
// 内容为空时不自动保存
if (act == 1 && content == "") {
setTimeout("autosave(1)", timeout);
return;
}
// 距离上次保存成功时间小于一秒时不允许手动保存
if ((new Date().getTime() - Cookies.get('em_saveLastTime')) < 1000 && act != 1) {
alert("请勿频繁操作!");
return;
}
const btname = $("#savedf").val();
$("#savedf").val("正在保存中...");
$('title').text('[保存中] ' + titleText);
$("#savedf").attr("disabled", "disabled");
$.post(url, $("#addlog").serialize(), function (data) {
data = $.trim(data);
var isresponse = /.*autosave\_gid\:\d+\_.*/;
if (isresponse.test(data)) {
const getvar = data.match(/_gid:([\d]+)_/);
const logid = getvar[1];
const d = new Date();
const h = d.getHours();
const m = d.getMinutes();
const s = d.getSeconds();
const tm = (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":" + (s < 10 ? "0" + s : s); // 添加秒数
const contentWithoutNewlines = content.replace(/\n/g, ""); // 移除换行符
const wordCount = contentWithoutNewlines.length; // 统计文章字数
$("#save_info").html("保存于:" + tm + ",字数:" + wordCount + " <a href=\"../?post=" + logid + "\" target=\"_blank\">预览文章</a>");
$("#save_info2").html("保存于:" + tm + ",字数:" + wordCount + " <a href=\"../?post=" + logid + "\" target=\"_blank\">预览文章</a>");
$('title').text('[保存成功] ' + titleText);
articleTextRecord = $("#addlog textarea[name=logcontent]").val(); // 保存成功后,将原文本记录值替换为现在的文本
Cookies.set('em_saveLastTime', new Date().getTime()); // 把保存成功时间戳记录(或更新)到 cookie 中
$("#" + nodeid).val(logid);
$("#savedf").attr("disabled", false).val(btname);
} else {
$("#savedf").attr("disabled", false).val(btname);
$("#save_info").html("保存失败,可能文章不可编辑或达到每日发文限额").addClass("alert-danger");
$('title').text('[保存失败] ' + titleText);
}
});
if (act == 1) {
setTimeout("autosave(1)", timeout);
}
}置換後、保存してください!