🐛 加强文件名解码的空值处理
- 后端decodeHtmlEntities添加空字符串默认值 - 前端decodeHtmlEntities非字符串时返回空字符串 - getFileDisplayName增强类型检查 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2279,7 +2279,7 @@ app.get('/api/files', authMiddleware, async (req, res) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
name: item.name,
|
name: item.name,
|
||||||
displayName: decodeHtmlEntities(item.name),
|
displayName: decodeHtmlEntities(item.name || ''),
|
||||||
type: item.type === 'd' ? 'directory' : 'file',
|
type: item.type === 'd' ? 'directory' : 'file',
|
||||||
size: item.size,
|
size: item.size,
|
||||||
sizeFormatted: formatFileSize(item.size),
|
sizeFormatted: formatFileSize(item.size),
|
||||||
|
|||||||
@@ -2017,7 +2017,7 @@ handleDragLeave(e) {
|
|||||||
|
|
||||||
// HTML实体解码(前端兜底,防止已实体化的文件名显示乱码)
|
// HTML实体解码(前端兜底,防止已实体化的文件名显示乱码)
|
||||||
decodeHtmlEntities(str) {
|
decodeHtmlEntities(str) {
|
||||||
if (typeof str !== 'string') return str;
|
if (typeof str !== 'string') return '';
|
||||||
const entityMap = {
|
const entityMap = {
|
||||||
amp: '&',
|
amp: '&',
|
||||||
lt: '<',
|
lt: '<',
|
||||||
@@ -2052,9 +2052,11 @@ handleDragLeave(e) {
|
|||||||
|
|
||||||
getFileDisplayName(file) {
|
getFileDisplayName(file) {
|
||||||
if (!file) return '';
|
if (!file) return '';
|
||||||
const base = file.displayName || file.name || '';
|
const base = (typeof file.displayName === 'string' && file.displayName !== '')
|
||||||
|
? file.displayName
|
||||||
|
: (typeof file.name === 'string' ? file.name : '');
|
||||||
const decoded = this.decodeHtmlEntities(base);
|
const decoded = this.decodeHtmlEntities(base);
|
||||||
return decoded || base;
|
return decoded || base || '';
|
||||||
},
|
},
|
||||||
|
|
||||||
openShare(url) {
|
openShare(url) {
|
||||||
|
|||||||
Reference in New Issue
Block a user