From 2ac5263363a925d4a1e76cd91fd8a3b636d5bb57 Mon Sep 17 00:00:00 2001 From: Samler Date: Mon, 30 Jun 2025 21:33:27 +0800 Subject: [PATCH] feat: Added the base64-encoded url for magic vars --- public/locales/en-US/dashboard.json | 1 + public/locales/ja-JP/dashboard.json | 1 + public/locales/zh-CN/dashboard.json | 1 + .../Filesystem/ViewerSetting/FileViewerEditDialog.tsx | 5 +++++ src/redux/thunks/viewer.ts | 1 + 5 files changed, 9 insertions(+) diff --git a/public/locales/en-US/dashboard.json b/public/locales/en-US/dashboard.json index 9d091c6..6ca3e8c 100644 --- a/public/locales/en-US/dashboard.json +++ b/public/locales/en-US/dashboard.json @@ -192,6 +192,7 @@ "maxSizeDes": "The maximum file size supported by this application. 0 means no limit. If the file exceeds this size, it will still be opened, but users will be warned.", "srcEncodedVar": "URL-encoded file Blob temporary access URL", "srcVar": "File blob temporary access URL", + "srcBase64Var": "Base64-encoded File blob temporary access URL", "nameEncodedVar": "URL-encoded file name", "versionEntityVar": "The Blob ID of the opened file version, empty means the latest version.", "fileIdVar": "File ID", diff --git a/public/locales/ja-JP/dashboard.json b/public/locales/ja-JP/dashboard.json index 83bba97..80b3711 100644 --- a/public/locales/ja-JP/dashboard.json +++ b/public/locales/ja-JP/dashboard.json @@ -192,6 +192,7 @@ "maxSizeDes": "このアプリがサポートする最大ファイルサイズです。「0」と入力すると制限なしになります。サイズ超過の場合もファイルを開こうとしますが、警告が表示されます。", "srcEncodedVar": "URLエンコード済みのファイルBlob一時アクセスアドレス", "srcVar": "ファイルBlob一時アクセスアドレス", + "srcBase64Var": "Base64エンコード済みのファイルBlob一時アクセスアドレス", "nameEncodedVar": "URLエンコード済みのファイル名", "versionEntityVar": "開いているファイルバージョンのBlob ID(空欄の場合は最新バージョンが開かれています)。", "fileIdVar": "ファイルID", diff --git a/public/locales/zh-CN/dashboard.json b/public/locales/zh-CN/dashboard.json index 16c603f..87bd488 100644 --- a/public/locales/zh-CN/dashboard.json +++ b/public/locales/zh-CN/dashboard.json @@ -192,6 +192,7 @@ "maxSizeDes": "此应用支持的最大文件大小,填写 0 表示不限制,超出大小时仍会尝试打开文件,但会警告用户。", "srcEncodedVar": "经过 URL 编码后的文件 Blob 临时访问地址", "srcVar": "文件 Blob 临时访问地址", + "srcBase64Var": "经过 Base64 编码后的文件 Blob 临时访问地址", "nameEncodedVar": "经过 URL 编码后的文件名", "versionEntityVar": "打开的文件版本 Blob ID,为空时表示打开的是最新版本。", "fileIdVar": "文件 ID", diff --git a/src/component/Admin/Settings/Filesystem/ViewerSetting/FileViewerEditDialog.tsx b/src/component/Admin/Settings/Filesystem/ViewerSetting/FileViewerEditDialog.tsx index d6c31f7..d18bdcf 100644 --- a/src/component/Admin/Settings/Filesystem/ViewerSetting/FileViewerEditDialog.tsx +++ b/src/component/Admin/Settings/Filesystem/ViewerSetting/FileViewerEditDialog.tsx @@ -59,6 +59,11 @@ const magicVars: MagicVar[] = [ value: "settings.srcVar", example: "https://cloudreve.org/api/v4/file/content/zOie/0/text.txt?sign=xxx", }, + { + name: "{$src_raw_base64}", + value: "settings.srcBase64Var", + example: "aHR0cHM6Ly9jbG91ZHJldmUub3JnL2FwaS92NC9maWxlL2NvbnRlbnQvek9pZS8wL3RleHQudHh0P3NpZ249eHh4", + }, { name: "{$name}", value: "settings.nameEncodedVar", diff --git a/src/redux/thunks/viewer.ts b/src/redux/thunks/viewer.ts index 91abbe2..50de8dc 100644 --- a/src/redux/thunks/viewer.ts +++ b/src/redux/thunks/viewer.ts @@ -273,6 +273,7 @@ export function openCustomViewer(file: FileResponse, viewer: Viewer, preferredVe const vars: { [key: string]: string } = { src: encodeURIComponent(entityUrl.urls[0].url), src_raw: entityUrl.urls[0].url, + src_raw_base64: btoa(entityUrl.urls[0].url), name: encodeURIComponent(file.name), version: preferredVersion ? preferredVersion : "", id: file.id,