修改功能
This commit is contained in:
+25
-11
@@ -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 albumsById = Object.create(null);
|
||||
var photosById = Object.create(null);
|
||||
@@ -180,7 +189,7 @@
|
||||
function normalizeAlbum(item) {
|
||||
var albumId = normalizeId(item && item.albumId);
|
||||
var genealogyId = normalizeId(item && item.genealogyId);
|
||||
var coverOssId = normalizeNullableId(item && item.coverOssId);
|
||||
var coverFile = MediaDisplay && MediaDisplay.normalizeFileAccess(item && item.coverFile);
|
||||
var albumName = stringValue(item && item.albumName).trim();
|
||||
var photoCount = optionalSafeInteger(item && item.photoCount);
|
||||
var sortOrder = optionalSafeInteger(item && item.sortOrder);
|
||||
@@ -188,7 +197,7 @@
|
||||
var album;
|
||||
|
||||
if (!albumId || !genealogyId || !albumName) 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.photoCount !== undefined && item.photoCount !== null && item.photoCount !== '' && photoCount === undefined) return null;
|
||||
if (item.sortOrder !== undefined && item.sortOrder !== null && item.sortOrder !== '' && sortOrder === undefined) return null;
|
||||
if (status !== '0' && status !== '1') return null;
|
||||
@@ -203,7 +212,7 @@
|
||||
status: status,
|
||||
remark: stringValue(item.remark)
|
||||
};
|
||||
if (coverOssId) album.coverOssId = coverOssId;
|
||||
if (coverFile) album.coverFile = coverFile;
|
||||
if (photoCount !== undefined) album.photoCount = photoCount;
|
||||
if (sortOrder !== undefined) album.sortOrder = sortOrder;
|
||||
return album;
|
||||
@@ -213,12 +222,12 @@
|
||||
var photoId = normalizeId(item && item.photoId);
|
||||
var genealogyId = normalizeId(item && item.genealogyId);
|
||||
var albumId = normalizeId(item && item.albumId);
|
||||
var ossId = normalizeId(item && item.ossId);
|
||||
var photoFile = MediaDisplay && MediaDisplay.normalizeFileAccess(item && item.photoFile);
|
||||
var sortOrder = optionalSafeInteger(item && item.sortOrder);
|
||||
var status = stringValue(item && item.status);
|
||||
var photo;
|
||||
|
||||
if (!photoId || !genealogyId || !albumId || !ossId) return null;
|
||||
if (!photoId || !genealogyId || !albumId || !photoFile) return null;
|
||||
if (item.sortOrder !== undefined && item.sortOrder !== null && item.sortOrder !== '' && sortOrder === undefined) return null;
|
||||
if (status !== '0' && status !== '1') return null;
|
||||
photo = {
|
||||
@@ -229,7 +238,7 @@
|
||||
surname: stringValue(item.surname),
|
||||
albumId: albumId,
|
||||
albumName: stringValue(item.albumName),
|
||||
ossId: ossId,
|
||||
photoFile: photoFile,
|
||||
photoTitle: stringValue(item.photoTitle),
|
||||
photoDesc: stringValue(item.photoDesc),
|
||||
photographer: stringValue(item.photographer),
|
||||
@@ -299,10 +308,12 @@
|
||||
if (canEditContent) {
|
||||
actions = '<div class="bottom-actions"><a class="btn ghost" href="' +
|
||||
escapeHtml(buildEditUrl(album.genealogyId, album.albumId)) + '">编辑相册</a>' +
|
||||
'<button class="btn ghost" type="button" data-album-delete-id="' +
|
||||
'<button class="btn danger" type="button" data-album-delete-id="' +
|
||||
escapeHtml(album.albumId) + '">删除相册</button></div>';
|
||||
}
|
||||
return '<div class="form-like album-detail">' +
|
||||
return (MediaDisplay ? MediaDisplay.renderImage(album.coverFile, {
|
||||
alt: album.albumName + '封面', className: 'album-cover-media'
|
||||
}) : '') + '<div class="form-like album-detail">' +
|
||||
detailValue('相册名称', album.albumName) +
|
||||
detailValue('相册说明', album.albumDesc) +
|
||||
detailValue('照片数量', album.photoCount === undefined ? '' : album.photoCount) +
|
||||
@@ -334,7 +345,10 @@
|
||||
? '<button class="pill is-danger" type="button" data-album-photo-delete-id="' +
|
||||
escapeHtml(photo.photoId) + '">删除</button>'
|
||||
: '';
|
||||
return '<article class="module-row album-photo-row"><div><h3>' +
|
||||
return '<article class="module-row album-photo-row">' +
|
||||
(MediaDisplay ? MediaDisplay.renderImage(photo.photoFile, {
|
||||
alt: photo.photoTitle || '家族照片', className: 'album-photo-media'
|
||||
}) : '') + '<div><h3>' +
|
||||
escapeHtml(photo.photoTitle || '未命名照片') + '</h3><p>' +
|
||||
escapeHtml([photo.photoDesc, photo.photographer, photo.shootTime].filter(Boolean).join(' · ') || '文件已上传') +
|
||||
'</p></div><div class="row-actions">' + action + '</div></article>';
|
||||
@@ -706,7 +720,7 @@
|
||||
var album = albumsById[albumId] || currentAlbum;
|
||||
|
||||
if (writePending || !canEditContent || !genealogyId || !normalizeId(albumId) || redirectUnauthorized(api)) return;
|
||||
if (root.confirm && !root.confirm('确认删除“' + (album ? album.albumName : '该相册') + '”及其中全部照片吗?删除后不可恢复。')) return;
|
||||
if (!await confirmAction('确认删除“' + (album ? album.albumName : '该相册') + '”及其中全部照片吗?删除后不可恢复。')) return;
|
||||
setWritePending(true);
|
||||
try {
|
||||
await api.deleteAlbum(genealogyId, albumId);
|
||||
@@ -727,7 +741,7 @@
|
||||
var photo = photosById[photoId];
|
||||
|
||||
if (writePending || !canEditContent || !genealogyId || !albumId || !normalizeId(photoId) || redirectUnauthorized(api)) return;
|
||||
if (root.confirm && !root.confirm('确认删除“' + (photo && photo.photoTitle || '该照片') + '”吗?删除后不可恢复。')) return;
|
||||
if (!await confirmAction('确认删除“' + (photo && photo.photoTitle || '该照片') + '”吗?删除后不可恢复。')) return;
|
||||
setWritePending(true);
|
||||
try {
|
||||
await api.deleteAlbumPhoto(genealogyId, albumId, photoId);
|
||||
|
||||
Reference in New Issue
Block a user