修改功能
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
})(typeof globalThis !== 'undefined' ? globalThis : window, function (root) {
|
||||
'use strict';
|
||||
|
||||
var MediaDisplay = root.MediaDisplay || (typeof require === 'function' ? require('./media-display.js') : null);
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value === undefined || value === null ? '' : value)
|
||||
.replace(/&/g, '&')
|
||||
@@ -52,14 +54,19 @@
|
||||
var source = item || {};
|
||||
var promotionId = normalizeId(source.promotionId);
|
||||
var promotionTitle = text(source.promotionTitle);
|
||||
var coverFile = MediaDisplay && MediaDisplay.normalizeFileAccess(source.coverFile);
|
||||
var promotion;
|
||||
|
||||
if (!promotionId || !promotionTitle || String(source.status) !== '0') return null;
|
||||
return {
|
||||
if (source.coverFile !== undefined && source.coverFile !== null && !coverFile) return null;
|
||||
promotion = {
|
||||
promotionId: promotionId,
|
||||
promotionTitle: promotionTitle,
|
||||
promotionDesc: text(source.promotionDesc),
|
||||
targetUrl: normalizeTargetUrl(source.targetUrl)
|
||||
};
|
||||
if (coverFile) promotion.coverFile = coverFile;
|
||||
return promotion;
|
||||
}
|
||||
|
||||
function normalizePromotionList(data) {
|
||||
@@ -71,7 +78,9 @@
|
||||
}
|
||||
|
||||
function renderPromotionCard(item) {
|
||||
var content = '<div><h3>' + escapeHtml(item.promotionTitle) + '</h3>' +
|
||||
var content = (MediaDisplay ? MediaDisplay.renderImage(item.coverFile, {
|
||||
alt: item.promotionTitle + '封面', className: 'promotion-cover-media'
|
||||
}) : '') + '<div><h3>' + escapeHtml(item.promotionTitle) + '</h3>' +
|
||||
'<p>' + escapeHtml(item.promotionDesc) + '</p></div>';
|
||||
|
||||
if (!item.targetUrl) {
|
||||
@@ -138,7 +147,7 @@
|
||||
setPromotionState(list, 'empty', '当前暂无应用推广。');
|
||||
return;
|
||||
}
|
||||
list.innerHTML = renderPromotionList(items);
|
||||
list.innerHTML = items.map(renderPromotionCard).join('');
|
||||
} catch (error) {
|
||||
if (isUnauthorized(error)) {
|
||||
if (api.clearToken) api.clearToken();
|
||||
|
||||
Reference in New Issue
Block a user