Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dist
!/src/lang/en/
.DS_Store
.idea
.test
.test
.codebuddy
30 changes: 30 additions & 0 deletions src/lang/en/home.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,36 @@
"cancel_select": "Cancel Select",
"offline_download": "Offline download",
"offline_download-tips": "One URL per line",
"offline_download_torrent": "BT Offline Download",
"offline_download_enhanced": {
"tab_link": "Link Download",
"tab_bt": "BT Download",
"link_placeholder": "Enter download links, one per line\nSupports: HTTP/HTTPS, magnet:?, ed2k://",
"link_tips": "Supports HTTP/HTTPS URLs, magnet links, and ed2k links. One link per line.",
"drop_torrent": "Drop .torrent file here",
"click_to_select": "Or click to select a .torrent file",
"parsing": "Parsing torrent file...",
"torrent_too_large": "Torrent file is too large (max 10MB)",
"parse_failed": "Failed to parse torrent file",
"files_count": "files",
"select_all": "Select All",
"save_path": "Save Path",
"download_tool": "Download Tool",
"delete_policy": "Delete Policy",
"start_download": "Start Download",
"rapid_upload_and_download": "Try Rapid Upload",
"rapid_upload_success": "Rapid upload succeeded!",
"cas_supported": "CAS Rapid Upload",
"cas_hint": "This torrent contains CAS info, will try rapid upload to Cloud189 first.",
"cas_rapid_upload_mode": "CAS info detected. Will directly use Cloud189 rapid upload (no download tool needed).",
"cas_rapid_upload_failed": "CAS rapid upload failed. Please check if the save path is a Cloud189 storage, or try downloading manually.",
"cas_failed_fallback_hint": "CAS rapid upload failed. You can now select a download tool and start a normal offline download.",
"no_cas_hint": "No CAS info found. Files will be downloaded first, then uploaded.",
"reselect": "Reselect",
"simplehttp_not_supported": "SimpleHttp does not support BT/magnet downloads. Please select aria2 or another tool.",
"ed2k_tool_hint": "ed2k links detected. aria2/qBittorrent do not support ed2k protocol. The system will automatically try Thunder tools, or you can manually select Thunder/ThunderX/ThunderBrowser.",
"file_selection_hint": "Note: The torrent file list is for reference only. Partial file selection is not yet supported — all files in the torrent will be downloaded."
},
"delete_policy": {
"delete_on_upload_succeed": "Delete on upload succeed",
"delete_on_upload_failed": "Delete on upload failed",
Expand Down
48 changes: 47 additions & 1 deletion src/pages/home/folder/context-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "solid-contextmenu/dist/style.css"
import { HStack, Icon, Text, useColorMode, Image } from "@hope-ui/solid"
import { operations } from "../toolbar/operations"
import { For, Show } from "solid-js"
import { bus, convertURL, notify } from "~/utils"
import { bus, convertURL, notify, torrentParse } from "~/utils"
import { ObjType, UserMethods } from "~/types"
import {
getSettingBool,
Expand All @@ -18,6 +18,7 @@ import {
import { players } from "../previews/video_box"
import { BsPlayCircleFill } from "solid-icons/bs"
import { isArchive } from "~/store/archive"
import axios from "axios"

const ItemContent = (props: { name: string }) => {
const t = useT()
Expand Down Expand Up @@ -88,6 +89,51 @@ export const ContextMenu = () => {
>
<ItemContent name="decompress" />
</Item>
<Item
hidden={() => {
return (
isShare() ||
!userCan("offline_download") ||
!objStore.write ||
!oneChecked() ||
selectedObjs().some((o) => o.is_dir) ||
!selectedObjs().every((o) =>
o.name.toLowerCase().endsWith(".torrent"),
)
)
Comment on lines +93 to +103
}}
onClick={async () => {
const obj = selectedObjs()[0]
if (!obj) return
try {
// 获取 torrent 文件的下载链接并下载内容
const link = rawLink(obj, false)
const resp = await axios.get(link, { responseType: "arraybuffer" })
const buffer = resp.data as ArrayBuffer
const bytes = new Uint8Array(buffer)
let binary = ""
for (let i = 0; i < bytes.byteLength; i++) {
binary += String.fromCharCode(bytes[i])
}
const base64Data = btoa(binary)

// 调用解析 API
const parseResp = await torrentParse(base64Data)
if (parseResp.code === 200) {
bus.emit("torrent_parsed", {
torrentData: base64Data,
info: parseResp.data,
})
} else {
notify.error(parseResp.message || "解析 torrent 失败")
}
} catch (err) {
notify.error(`解析 torrent 失败: ${err}`)
}
}}
>
<ItemContent name="offline_download_torrent" />
</Item>
<Show when={oneChecked()}>
<Item
onClick={({ props }) => {
Expand Down
Loading