fix lot of thing

This commit is contained in:
2025-11-01 20:14:35 +08:00
parent 39dfb62cbf
commit f006729311
16 changed files with 23303 additions and 3996 deletions

View File

@@ -95,14 +95,26 @@ class FileCard(CardWidget):
full_path = f"cloudreve://my/{self.fileName}"
else:
# 子目录情况,确保正确拼接路径
# 清理路径,避免重复的斜杠
# 清理路径,避免重复的斜杠和前缀
clean_path = self.filePath.lstrip("/")
# 确保路径中不包含cloudreve://my前缀
clean_path = clean_path.replace("cloudreve://my/", "")
full_path = f"cloudreve://my/{clean_path}/{self.fileName}"
# 确保路径格式正确,没有重复的部分
# 确保路径格式正确,移除重复的前缀
full_path = full_path.replace("cloudreve://my/cloudreve://my", "cloudreve://my")
# 确保没有重复的文件名
if f"/{self.fileName}/{self.fileName}" in full_path:
full_path = full_path.replace(f"/{self.fileName}/{self.fileName}", f"/{self.fileName}")
# 更健壮地处理重复文件名的情况
# 分割路径并去重
path_parts = full_path.split('/')
if len(path_parts) > 1:
# 检查最后一个部分是否是文件名
if path_parts[-1] == self.fileName:
# 检查倒数第二个部分是否也是文件名
if len(path_parts) > 2 and path_parts[-2] == self.fileName:
# 移除重复的文件名部分
path_parts.pop(-2)
full_path = '/'.join(path_parts)
signalBus.addDownloadFileTask.emit(
f"own.{self.suffix}", self.fileName, full_path
@@ -158,7 +170,34 @@ class FileCard(CardWidget):
parent=self.window(),
)
if w.exec():
self.deleteThread = DeleteFileThread(self._id, self.fileType)
# 构建Cloudreve V4 API所需的正确路径格式
if self.filePath == "/":
# 根目录情况
full_path = f"cloudreve://my/{self.fileName}"
else:
# 子目录情况,确保正确拼接路径
# 清理路径,避免重复的斜杠和前缀
clean_path = self.filePath.lstrip("/")
# 确保路径中不包含cloudreve://my前缀
clean_path = clean_path.replace("cloudreve://my/", "")
full_path = f"cloudreve://my/{clean_path}/{self.fileName}"
# 确保路径格式正确,移除重复的前缀
full_path = full_path.replace("cloudreve://my/cloudreve://my", "cloudreve://my")
# 更健壮地处理重复文件名的情况
# 分割路径并去重
path_parts = full_path.split('/')
if len(path_parts) > 1:
# 检查最后一个部分是否是文件名
if path_parts[-1] == self.fileName:
# 检查倒数第二个部分是否也是文件名
if len(path_parts) > 2 and path_parts[-2] == self.fileName:
# 移除重复的文件名部分
path_parts.pop(-2)
full_path = '/'.join(path_parts)
self.deleteThread = DeleteFileThread(full_path, self.fileType)
self.deleteThread.successDelete.connect(self.deleteSuccess)
self.deleteThread.errorDelete.connect(self.deleteError)
self.deleteThread.start()
@@ -200,6 +239,16 @@ class FileCard(CardWidget):
def contextMenuEvent(self, e):
"""重写上下文菜单事件,确保只有右键点击才会触发"""
pass
def mouseDoubleClickEvent(self, event):
"""重写鼠标双击事件,双击文件夹时进入文件夹"""
if self.fileType == "dir":
self.dirClicked()
# 阻止事件继续传播,避免可能的干扰
event.accept()
else:
# 非文件夹时调用父类处理
super().mouseDoubleClickEvent(event)
class ShareFileCard(CardWidget):
@@ -360,3 +409,13 @@ class SharedFolderFileCard(CardWidget):
)
menu.exec(pos, aniType=MenuAnimationType.DROP_DOWN)
def mouseDoubleClickEvent(self, event):
"""重写鼠标双击事件,双击文件夹时进入文件夹"""
if self.fileType == "dir":
self.dirClicked()
# 阻止事件继续传播,避免可能的干扰
event.accept()
else:
# 非文件夹时调用父类处理
super().mouseDoubleClickEvent(event)

View File

@@ -68,8 +68,37 @@ class LinkageSwitchingBase(ScrollArea):
fileDate = data.get("created_at", data.get("date", ""))
fileSize = data.get("size", 0)
# 构建符合Cloudreve V4 API要求的正确URI格式
if filePath == "/" or filePath == "":
# 根目录情况
full_uri = f"cloudreve://my/{fileName}"
else:
# 子目录情况,确保正确拼接路径
# 清理路径,避免重复的斜杠和前缀
clean_path = filePath.lstrip("/")
# 确保路径中不包含cloudreve://my前缀
clean_path = clean_path.replace("cloudreve://my/", "")
full_uri = f"cloudreve://my/{clean_path}/{fileName}"
# 确保路径格式正确,移除重复的前缀
full_uri = full_uri.replace("cloudreve://my/cloudreve://my", "cloudreve://my")
# 更健壮地处理重复文件名的情况
# 分割路径并去重
path_parts = full_uri.split('/')
if len(path_parts) > 1:
# 检查最后一个部分是否是文件名
if path_parts[-1] == fileName:
# 检查倒数第二个部分是否也是文件名
if len(path_parts) > 2 and path_parts[-2] == fileName:
# 移除重复的文件名部分
path_parts.pop(-2)
full_uri = '/'.join(path_parts)
logger.debug(f"构建文件URI: {full_uri}")
fileCard = FileCard(
fileId,
full_uri, # 传递完整的URI而不是文件ID
fileName,
fileType,
filePath,