修改功能
This commit is contained in:
@@ -13,6 +13,15 @@
|
||||
})(typeof globalThis !== 'undefined' ? globalThis : window, function (root) {
|
||||
'use strict';
|
||||
|
||||
function confirmAction(message) {
|
||||
if (root.ProfileUI && typeof root.ProfileUI.confirmAction === 'function') {
|
||||
return root.ProfileUI.confirmAction(message);
|
||||
}
|
||||
return Promise.resolve(!root['confirm'] || root['confirm'](message));
|
||||
}
|
||||
|
||||
var MediaDisplay = root.MediaDisplay || (typeof require === 'function' ? require('./media-display.js') : null);
|
||||
|
||||
var documentRef = root.document;
|
||||
var articlesById = Object.create(null);
|
||||
var writePending = false;
|
||||
@@ -119,7 +128,7 @@
|
||||
var articleId = normalizeId(item && item.articleId);
|
||||
var genealogyId = normalizeId(item && item.genealogyId);
|
||||
var categoryId = normalizeNullableId(item && item.categoryId);
|
||||
var coverOssId = normalizeNullableId(item && item.coverOssId);
|
||||
var coverFile = MediaDisplay && MediaDisplay.normalizeFileAccess(item && item.coverFile);
|
||||
var articleTitle = stringValue(item && item.articleTitle).trim();
|
||||
var articleContent = stringValue(item && item.articleContent).trim();
|
||||
var viewCount = optionalSafeInteger(item && item.viewCount);
|
||||
@@ -129,7 +138,7 @@
|
||||
|
||||
if (!articleId || !genealogyId || !articleTitle || !articleContent) return null;
|
||||
if (item.categoryId !== undefined && item.categoryId !== null && item.categoryId !== '' && !categoryId) return null;
|
||||
if (item.coverOssId !== undefined && item.coverOssId !== null && item.coverOssId !== '' && !coverOssId) return null;
|
||||
if (item.coverFile !== undefined && item.coverFile !== null && !coverFile) return null;
|
||||
if (item.viewCount !== undefined && item.viewCount !== null && item.viewCount !== '' && viewCount === undefined) return null;
|
||||
if (item.sortOrder !== undefined && item.sortOrder !== null && item.sortOrder !== '' && sortOrder === undefined) return null;
|
||||
if (status !== '0' && status !== '1') return null;
|
||||
@@ -151,7 +160,7 @@
|
||||
remark: stringValue(item.remark)
|
||||
};
|
||||
if (categoryId) article.categoryId = categoryId;
|
||||
if (coverOssId) article.coverOssId = coverOssId;
|
||||
if (coverFile) article.coverFile = coverFile;
|
||||
if (viewCount !== undefined) article.viewCount = viewCount;
|
||||
if (sortOrder !== undefined) article.sortOrder = sortOrder;
|
||||
return article;
|
||||
@@ -207,10 +216,12 @@
|
||||
if (canEditContent) {
|
||||
actions = '<div class="bottom-actions"><a class="btn ghost" href="' +
|
||||
escapeHtml(buildEditUrl(article.genealogyId, article.articleId)) + '">编辑谱文</a>' +
|
||||
'<button class="btn ghost" type="button" data-article-delete-id="' +
|
||||
'<button class="btn danger" type="button" data-article-delete-id="' +
|
||||
escapeHtml(article.articleId) + '">删除谱文</button></div>';
|
||||
}
|
||||
return '<div class="form-like article-detail">' +
|
||||
return (MediaDisplay ? MediaDisplay.renderImage(article.coverFile, {
|
||||
alt: article.articleTitle + '封面', className: 'article-cover-media'
|
||||
}) : '') + '<div class="form-like article-detail">' +
|
||||
detailValue('标题', article.articleTitle) +
|
||||
detailValue('摘要', article.articleSummary) +
|
||||
detailValue('正文', article.articleContent) +
|
||||
@@ -556,7 +567,7 @@
|
||||
var article = articlesById[articleId];
|
||||
|
||||
if (writePending || !canEditContent || !genealogyId || !normalizeId(articleId) || redirectUnauthorized(api)) return;
|
||||
if (root.confirm && !root.confirm('确认删除“' + (article ? article.articleTitle : '该谱文') + '”吗?删除后不可恢复。')) return;
|
||||
if (!await confirmAction('确认删除“' + (article ? article.articleTitle : '该谱文') + '”吗?删除后不可恢复。')) return;
|
||||
setWritePending(true);
|
||||
try {
|
||||
await api.deleteArticle(genealogyId, articleId);
|
||||
|
||||
Reference in New Issue
Block a user