进行了一些小修复

This commit is contained in:
2026-08-26 19:51:31 +08:00
parent 02cbff1ddf
commit fbada8bd6a
20 changed files with 294 additions and 191 deletions
-49
View File
@@ -3,7 +3,6 @@
*
* 提供前台编辑页面的增强功能:
* - 自动保存草稿
* - 字数统计
* - 标签建议
* - 快捷键支持
*
@@ -27,8 +26,6 @@
contentSelector: 'textarea[name="content"], textarea[name="topic_content"]',
tagsSelector: 'input[name="tags"], input[name="topic_tags"]',
autoSaveInterval: 30000, // 30秒
maxTitleLength: 200,
maxContentLength: 100000,
draftKey: '',
}, options || {});
@@ -47,9 +44,6 @@
this.contentTextarea = this.form.querySelector(this.options.contentSelector);
this.tagsInput = this.form.querySelector(this.options.tagsSelector);
// 字数统计
this.initWordCount();
// 自动保存草稿
this.initAutoSave();
@@ -73,49 +67,6 @@
});
};
PageEdit.prototype.initWordCount = function () {
var self = this;
// 创建字数统计显示
this.wordCountEl = document.createElement('div');
this.wordCountEl.className = 'aksrt-page-edit__word-count';
if (this.titleInput) {
var titleCount = document.createElement('span');
titleCount.className = 'aksrt-page-edit__title-count';
this.titleInput.parentNode.appendChild(titleCount);
this.titleInput.addEventListener('input', function () {
var len = self.titleInput.value.length;
titleCount.textContent = len + '/' + self.options.maxTitleLength;
titleCount.classList.toggle('aksrt-page-edit__count--warn', len > self.options.maxTitleLength * 0.9);
titleCount.classList.toggle('aksrt-page-edit__count--error', len > self.options.maxTitleLength);
});
}
if (this.contentTextarea) {
this.contentTextarea.parentNode.appendChild(this.wordCountEl);
this.updateWordCount();
this.contentTextarea.addEventListener('input', function () {
self.updateWordCount();
});
}
};
PageEdit.prototype.updateWordCount = function () {
if (!this.contentTextarea || !this.wordCountEl) return;
var text = this.contentTextarea.value;
var chars = text.length;
var words = text.trim() ? text.trim().split(/\s+/).length : 0;
var chinese = (text.match(/[一-鿿]/g) || []).length;
this.wordCountEl.textContent = '字数: ' + chars + ' | 词数: ' + words + ' | 中文: ' + chinese;
this.wordCountEl.classList.toggle('aksrt-page-edit__count--warn', chars > this.options.maxContentLength * 0.9);
this.wordCountEl.classList.toggle('aksrt-page-edit__count--error', chars > this.options.maxContentLength);
};
PageEdit.prototype.initAutoSave = function () {
var self = this;