镜像自地址
https://github.com/lhly/cloud-drive-renamer.git
已同步 2026-10-21 06:01:51 +08:00
fix(content): 改进文件名提取逻辑并过滤UI噪音文本
添加isNoiseTitle函数来识别并过滤UI噪音文本,优化文件名提取范围选择 更新版本号至0.4.1
这个提交包含在:
父节点
15eb5c8ffa
当前提交
4a9ac4cf42
@ -2,7 +2,7 @@
|
||||
"manifest_version": 3,
|
||||
"default_locale": "zh_CN",
|
||||
"name": "__MSG_extName__",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"description": "__MSG_extDescription__",
|
||||
"permissions": [
|
||||
"storage",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cloud-drive-renamer",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"description": "批量重命名工具,支持夸克网盘、阿里云盘、百度网盘",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@ -646,6 +646,23 @@ function isValidFileRow(row: Element, platform?: string): boolean {
|
||||
return !!(hasFilename && fileId && !fileId.startsWith('unknown-'));
|
||||
}
|
||||
|
||||
function isNoiseTitle(title: string): boolean {
|
||||
const normalized = title.trim();
|
||||
if (!normalized) return true;
|
||||
|
||||
// Pure punctuation / ellipsis-like titles are almost certainly UI noise.
|
||||
if (/^[\s._\-—–…·•|/\\()()[\]【】]+$/.test(normalized)) return true;
|
||||
|
||||
// Common UI labels across platforms (CN + EN).
|
||||
if (/^(选择|操作|更多|下载|分享|删除|上传|移动|复制|重命名|详情|打开|关闭)$/.test(normalized)) return true;
|
||||
if (/^(Select|Actions?|More|Download|Share|Delete|Upload|Move|Copy|Rename|Details|Open|Close)$/i.test(normalized)) return true;
|
||||
|
||||
// Quark-specific UI labels / statuses that sometimes appear inside the name cell.
|
||||
if (/^(上传到当前目录|上传到同级目录|下载中|处理中|转码中|同步中)$/.test(normalized)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quark平台专用的文件提取逻辑
|
||||
*/
|
||||
@ -693,10 +710,14 @@ function getSelectedFilesForQuark(): FileItem[] {
|
||||
|
||||
// 提取文件名
|
||||
let filename = '';
|
||||
const titleElements = (row as Element).querySelectorAll('[title]');
|
||||
const nameScope =
|
||||
(row as Element).querySelector(
|
||||
'.filename-text, [class*="filename"]:not([class*="wrapper"]), [class*="file-name"]:not([class*="wrapper"]), [class*="file-title"]'
|
||||
) || (row as Element);
|
||||
const titleElements = nameScope.querySelectorAll('[title]');
|
||||
for (const titleEl of Array.from(titleElements)) {
|
||||
const title = (titleEl as HTMLElement).getAttribute('title')?.trim();
|
||||
if (title && title.length > 3 && !title.match(/^(选择|操作|更多|下载|分享|删除)$/)) {
|
||||
if (title && !isNoiseTitle(title)) {
|
||||
filename = title;
|
||||
break;
|
||||
}
|
||||
@ -727,7 +748,7 @@ function getSelectedFilesForQuark(): FileItem[] {
|
||||
}
|
||||
|
||||
// 清理文件名中的无关前缀
|
||||
filename = filename.replace(/^(上传到同级目录|下载中|处理中|转码中|同步中)\s*/g, '');
|
||||
filename = filename.replace(/^(上传到当前目录|上传到同级目录|下载中|处理中|转码中|同步中)\s*/g, '');
|
||||
|
||||
// 解析扩展名
|
||||
const lastDotIndex = filename.lastIndexOf('.');
|
||||
@ -1049,7 +1070,7 @@ async function getSelectedFilesFromDOMForAliyun(): Promise<FileItem[]> {
|
||||
const titleElements = row.querySelectorAll('[title]');
|
||||
for (const titleEl of Array.from(titleElements)) {
|
||||
const title = (titleEl as HTMLElement).getAttribute('title')?.trim();
|
||||
if (title && title.length > 3 && !title.match(/^(选择|操作|更多|下载|分享|删除)$/)) {
|
||||
if (title && !isNoiseTitle(title)) {
|
||||
filename = title;
|
||||
break;
|
||||
}
|
||||
@ -1079,7 +1100,7 @@ async function getSelectedFilesFromDOMForAliyun(): Promise<FileItem[]> {
|
||||
}
|
||||
|
||||
// 清理文件名
|
||||
filename = filename.replace(/^(上传到同级目录|下载中|处理中|转码中|同步中)\s*/g, '');
|
||||
filename = filename.replace(/^(上传到当前目录|上传到同级目录|下载中|处理中|转码中|同步中)\s*/g, '');
|
||||
|
||||
// 解析扩展名
|
||||
const lastDotIndex = filename.lastIndexOf('.');
|
||||
@ -1176,10 +1197,14 @@ function getSelectedFilesForBaidu(): FileItem[] {
|
||||
|
||||
// 提取文件名
|
||||
let filename = '';
|
||||
const titleElements = (row as Element).querySelectorAll('[title]');
|
||||
const nameScope =
|
||||
(row as Element).querySelector(
|
||||
'.filename-text, [class*="filename"]:not([class*="wrapper"]), [class*="file-name"]:not([class*="wrapper"]), [class*="file-title"]'
|
||||
) || (row as Element);
|
||||
const titleElements = nameScope.querySelectorAll('[title]');
|
||||
for (const titleEl of Array.from(titleElements)) {
|
||||
const title = (titleEl as HTMLElement).getAttribute('title')?.trim();
|
||||
if (title && title.length > 3 && !title.match(/^(选择|操作|更多|下载|分享|删除)$/)) {
|
||||
if (title && !isNoiseTitle(title)) {
|
||||
filename = title;
|
||||
break;
|
||||
}
|
||||
@ -1210,7 +1235,7 @@ function getSelectedFilesForBaidu(): FileItem[] {
|
||||
}
|
||||
|
||||
// 清理文件名
|
||||
filename = filename.replace(/^(上传到同级目录|下载中|处理中|转码中|同步中)\s*/g, '');
|
||||
filename = filename.replace(/^(上传到当前目录|上传到同级目录|下载中|处理中|转码中|同步中)\s*/g, '');
|
||||
|
||||
// 解析扩展名
|
||||
const lastDotIndex = filename.lastIndexOf('.');
|
||||
|
||||
@ -10,19 +10,19 @@
|
||||
* 1. Edit version in package.json
|
||||
* 2. Run: npm run sync:version (or automatically via prebuild/predev)
|
||||
*
|
||||
* Generated at: 2025-12-25T06:17:37.504Z
|
||||
* Generated at: 2025-12-25T07:54:45.271Z
|
||||
*/
|
||||
|
||||
/**
|
||||
* Application version number (e.g., "0.1.0")
|
||||
*/
|
||||
export const APP_VERSION = '0.4.0' as const;
|
||||
export const APP_VERSION = '0.4.1' as const;
|
||||
|
||||
/**
|
||||
* Application version with 'v' prefix (e.g., "v0.1.0")
|
||||
* Commonly used for display purposes
|
||||
*/
|
||||
export const APP_VERSION_WITH_PREFIX = 'v0.4.0' as const;
|
||||
export const APP_VERSION_WITH_PREFIX = 'v0.4.1' as const;
|
||||
|
||||
/**
|
||||
* Parse version into components
|
||||
@ -30,5 +30,5 @@ export const APP_VERSION_WITH_PREFIX = 'v0.4.0' as const;
|
||||
export const VERSION_PARTS = {
|
||||
major: 0,
|
||||
minor: 4,
|
||||
patch: 0,
|
||||
patch: 1,
|
||||
} as const;
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户