diff --git a/public/locales/en-US/dashboard.json b/public/locales/en-US/dashboard.json index 1c525b6..605df74 100644 --- a/public/locales/en-US/dashboard.json +++ b/public/locales/en-US/dashboard.json @@ -140,8 +140,8 @@ "transitParallelNumDes": "Maximum number of parallel co-processes for transfer tasks.", "tempFolder": "Temp folder", "tempFolderDes": "Used to store temporary files generated by tasks such as decompression, compression, etc.", - "textEditMaxSize": "Max size of editable text files", - "textEditMaxSizeDes": "The maximum size of a text file that can be edited online, files beyond this size cannot be edited online.", + "textEditMaxSize": "Max size of editable document files", + "textEditMaxSizeDes": "The maximum size of a document file that can be edited online, files beyond this size cannot be edited online. This setting applies to plain text, code and Office documents (WOPI).", "failedChunkRetry": "Max chunk error retries", "failedChunkRetryDes": "Maximum number of retries after a failed chunk, only for server-side uploads or transferring.", "cacheChunks": "Cache chunk for retries", @@ -260,7 +260,15 @@ "tCaptchaSecretKey": "App Secret Key", "tCaptchaSecretKeyDes": "You can find it at <0>Captcha Management Page.", "staticResourceCache": "Public static resources cache", - "staticResourceCacheDes": "Max age of cache for public accessible static resources (e.g. local policy source link, download link)." + "staticResourceCacheDes": "Max age of cache for public accessible static resources (e.g. local policy source link, download link).", + "wopiClient": "WOPI Client", + "wopiClientDes": "Extend Cloudreve's document online preview and editing capabilities by interfacing with online document processing systems that support the WOPI protocol. For more information, please refer to <0>Official Documentation.", + "wopiDocLink": "https://docs.cloudreve.org/v/en/use/wopi", + "enableWopi": "Enable WOPI", + "wopiEndpoint": "WOPI Discovery Endpoint", + "wopiEndpointDes": "Endpoint URL of WOPI Discovery API.", + "wopiSessionTtl": "Edit session TTL (seconds)", + "wopiSessionTtlDes": "The user opens an online editing document session with an expiration date, beyond which the session cannot continue to save new changes." }, "policy": { "sharp": "#", diff --git a/public/locales/zh-CN/dashboard.json b/public/locales/zh-CN/dashboard.json index e33eb0b..457419d 100644 --- a/public/locales/zh-CN/dashboard.json +++ b/public/locales/zh-CN/dashboard.json @@ -140,8 +140,8 @@ "transitParallelNumDes": "任务队列中转任务传输时,最大并行协程数", "tempFolder": "临时目录", "tempFolderDes": "用于存放解压缩、压缩等任务产生的临时文件的目录路径", - "textEditMaxSize": "文本文件在线编辑大小", - "textEditMaxSizeDes": "文本文件可在线编辑的最大大小,超出此大小的文件无法在线编辑", + "textEditMaxSize": "文档在线编辑最大尺寸", + "textEditMaxSizeDes": "文档文件可在线编辑的最大大小,超出此大小的文件无法在线编辑。此项设置适用于纯文本文件、代码文件、Office 文档 (WOPI)", "failedChunkRetry": "分片错误重试", "failedChunkRetryDes": "分片上传失败后重试的最大次数,只适用于服务端上传或中转", "cacheChunks": "缓存流式分片文件以用于重试", @@ -260,7 +260,15 @@ "tCaptchaSecretKey": "App Secret Key", "tCaptchaSecretKeyDes": "<0>图形验证页面 获取到的的 App Secret Key", "staticResourceCache": "静态公共资源缓存", - "staticResourceCacheDes": "公共可访问的静态资源(如:本机策略直链、文件下载链接)的缓存有效期" + "staticResourceCacheDes": "公共可访问的静态资源(如:本机策略直链、文件下载链接)的缓存有效期", + "wopiClient": "WOPI 客户端", + "wopiClientDes": "通过对接支持 WOPI 协议的在线文档处理系统,扩展 Cloudreve 的文档在线预览和编辑能力。详情请参考 <0>官方文档。", + "wopiDocLink": "https://docs.cloudreve.org/use/wopi", + "enableWopi": "使用 WOPI", + "wopiEndpoint": "WOPI Discovery Endpoint", + "wopiEndpointDes": "WOPI 客户端发现 API 的端点地址", + "wopiSessionTtl": "编辑会话有效期(秒)", + "wopiSessionTtlDes": "用户打开在线编辑文档会话的有效期,超出此期限的会话无法继续保存新更改" }, "policy": { "sharp": "#", diff --git a/public/locales/zh-TW/dashboard.json b/public/locales/zh-TW/dashboard.json index 098d919..de047db 100644 --- a/public/locales/zh-TW/dashboard.json +++ b/public/locales/zh-TW/dashboard.json @@ -140,8 +140,8 @@ "transitParallelNumDes": "任務隊列中轉任務傳輸時,最大並行協程數", "tempFolder": "臨時目錄", "tempFolderDes": "用於存放解壓縮、壓縮等任務產生的臨時文件的目錄路徑", - "textEditMaxSize": "文本文件線上編輯大小", - "textEditMaxSizeDes": "文本文件可線上編輯的最大大小,超出此大小的文件無法線上編輯", + "textEditMaxSize": "文檔在線編輯最大尺寸", + "textEditMaxSizeDes": "文檔文件可在線編輯的最大大小,超出此大小的文件無法在線編輯。此項設置適用於純文本文件、代碼文件、Office 文檔 (WOPI)", "failedChunkRetry": "分片錯誤重試", "failedChunkRetryDes": "分片上傳失敗後重試的最大次數,只適用於服務端上傳或中轉", "cacheChunks": "快取流式分片文件以用於重試", @@ -260,7 +260,15 @@ "tCaptchaSecretKey": "App Secret Key", "tCaptchaSecretKeyDes": "<0>圖形驗證頁面 獲取到的的 App Secret Key", "staticResourceCache": "靜態公共資源快取", - "staticResourceCacheDes": "公共可訪問的靜態資源(如:本機策略直鏈、文件下載連接)的快取有效期" + "staticResourceCacheDes": "公共可訪問的靜態資源(如:本機策略直鏈、文件下載連接)的快取有效期", + "wopiClient": "WOPI 客戶端", + "wopiClientDes": "通過對接支持 WOPI 協議的在線文檔處理系統,擴展 Cloudreve 的文檔在線預覽和編輯能力。詳情請參考 <0>官方文檔。", + "wopiDocLink": "https://docs.cloudreve.org/use/wopi", + "enableWopi": "使用 WOPI", + "wopiEndpoint": "WOPI Discovery Endpoint", + "wopiEndpointDes": "WOPI 客戶端發現 API 的端點地址", + "wopiSessionTtl": "編輯會話有效期(秒)", + "wopiSessionTtlDes": "用戶打開在線編輯文檔會話的有效期,超出此期限的會話無法繼續保存新更改" }, "policy": { "sharp": "#", diff --git a/src/component/Admin/Setting/Image.js b/src/component/Admin/Setting/Image.js index 140d9cf..d39c785 100644 --- a/src/component/Admin/Setting/Image.js +++ b/src/component/Admin/Setting/Image.js @@ -13,7 +13,8 @@ import SizeInput from "../Common/SizeInput"; import Alert from "@material-ui/lab/Alert"; import FormControlLabel from "@material-ui/core/FormControlLabel"; import Switch from "@material-ui/core/Switch"; -import { useTranslation } from "react-i18next"; +import { Trans, useTranslation } from "react-i18next"; +import Link from "@material-ui/core/Link"; const useStyles = makeStyles((theme) => ({ root: { @@ -53,6 +54,10 @@ export default function ImageSetting() { thumb_encode_method: "", thumb_gc_after_gen: "0", thumb_encode_quality: "", + maxEditSize: "", + wopi_enabled: "0", + wopi_endpoint: "", + wopi_session_timeout: "0", }); const handleChange = (name) => (event) => { @@ -82,6 +87,17 @@ export default function ImageSetting() { // eslint-disable-next-line }, []); + const reload = () => { + API.get("/admin/reload/wopi") + // eslint-disable-next-line @typescript-eslint/no-empty-function + .then(() => {}) + .catch((error) => { + ToggleSnackbar("top", "right", error.message, "error"); + }) + // eslint-disable-next-line @typescript-eslint/no-empty-function + .then(() => {}); + }; + const submit = (e) => { e.preventDefault(); setLoading(true); @@ -97,6 +113,7 @@ export default function ImageSetting() { }) .then(() => { ToggleSnackbar("top", "right", t("saved"), "success"); + reload(); }) .catch((error) => { ToggleSnackbar("top", "right", error.message, "error"); @@ -236,7 +253,7 @@ export default function ImageSetting() {
- + {t("officePreviewService")} @@ -261,6 +278,109 @@ export default function ImageSetting() {
+ +
+ + {options.maxEditSize !== "" && ( + + )} + + + {t("textEditMaxSizeDes")} + + +
+
+ + +
+ + {t("wopiClient")} + + +
+
+ + , + ]} + /> + +
+ +
+ + + } + label={t("enableWopi")} + /> + +
+ + {options.wopi_enabled === "1" && ( + <> +
+ + + {t("wopiEndpoint")} + + + + {t("wopiEndpointDes")} + + +
+ +
+ + + {t("wopiSessionTtl")} + + + + {t("wopiSessionTtlDes")} + + +
+ + )}
diff --git a/src/component/Admin/Setting/UploadDownload.js b/src/component/Admin/Setting/UploadDownload.js index c972b08..7a5ca9f 100644 --- a/src/component/Admin/Setting/UploadDownload.js +++ b/src/component/Admin/Setting/UploadDownload.js @@ -41,7 +41,6 @@ export default function UploadDownload() { max_worker_num: "1", max_parallel_transfer: "1", temp_path: "", - maxEditSize: "", chunk_retries: "0", archive_timeout: "0", download_timeout: "0", @@ -190,25 +189,6 @@ export default function UploadDownload() { -
- - {options.maxEditSize !== "" && ( - - )} - - - {t("textEditMaxSizeDes")} - - -
-
diff --git a/src/i18n.ts b/src/i18n.ts index 935fa64..26e3134 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -23,7 +23,10 @@ i18n.use(ChainedBackend) escapeValue: false, }, backend: { - backends: [LocalStorageBackend, Backend], + backends: + process.env.NODE_ENV === "development" + ? [Backend] + : [LocalStorageBackend, Backend], backendOptions: [ { expirationTime: 7 * 24 * 60 * 60 * 1000, // 7 days