/** * 目录操作树:鼠标悬浮 title 文案(与 IntelliRschAsst/proj_prps.html 一致) */ (function (global) { 'use strict'; function isDirectoryItem(item) { const t = item && item.type; return t === 'directory' || t === 'dir'; } /** 树节点在列内的展示路径(与 proj_prps renderTreeItems 中 fullPath 一致) */ function buildTreeDisplayPath(item, basePath) { const base = String(basePath || '').replace(/\\/g, '/'); const name = (item && item.name) || ''; if (!base) return name; if (!name) return base; return base + '/' + name; } function buildDirectoryHoverTitle(fullPath, item) { const path = String(fullPath || '').replace(/\\/g, '/'); const dirParts = [path]; const modified = item && item.modified_time; if (modified) dirParts.push('修改时间: ' + modified); dirParts.push('类型: 目录'); return dirParts.join('\n'); } function buildFileHoverTitle(fullPath, item) { const path = String(fullPath || '').replace(/\\/g, '/'); const name = (item && item.name) || ''; const fileParts = ['路径: ' + path, '文件名: ' + name]; const modified = item && item.modified_time; if (modified) fileParts.push('修改时间: ' + modified); const ext = item && item.extension; fileParts.push('类型: ' + (String(ext || '').replace('.', '') || '文件')); const size = item && item.size_formatted; if (size) fileParts.push('大小: ' + size); return fileParts.join('\n'); } function buildHoverTitle(fullPath, item) { if (!item) return String(fullPath || ''); return isDirectoryItem(item) ? buildDirectoryHoverTitle(fullPath, item) : buildFileHoverTitle(fullPath, item); } function applyHoverTitle(li, fullPath, item) { if (!li || !item) return; li.setAttribute('title', buildHoverTitle(fullPath, item)); } /** @deprecated 请使用 buildTreeDisplayPath */ function resolveFullPath(item, basePath) { return buildTreeDisplayPath(item, basePath); } global.IARDirTreeHoverInfo = { isDirectoryItem: isDirectoryItem, buildTreeDisplayPath: buildTreeDisplayPath, buildDirectoryHoverTitle: buildDirectoryHoverTitle, buildFileHoverTitle: buildFileHoverTitle, buildHoverTitle: buildHoverTitle, applyHoverTitle: applyHoverTitle, resolveFullPath: resolveFullPath, }; })(typeof window !== 'undefined' ? window : this);