mirror of
https://github.com/VirtualHotBar/NetMount.git
synced 2026-06-08 23:52:34 +08:00
feat: #68 添加日志目录和传输目录设置
This commit is contained in:
@@ -158,6 +158,12 @@
|
||||
"the_path_is_illegal": "The path is illegal",
|
||||
"same_source_and_target": "Source and target are the same",
|
||||
"bisync": "Bidirectional Sync",
|
||||
"filter_rules": "Filter Rules",
|
||||
"filter_rules_placeholder": "One rule per line, for example:\n+ *.jpg\n+ *.png\n- *.tmp\n- *.log",
|
||||
"filter_rules_help": "Rclone filter rules: + to include, - to exclude. Supports wildcards * and ?. Leave empty for no filtering.",
|
||||
"resync": "Resync",
|
||||
"force_resync": "Force Resync",
|
||||
"force_resync_tip": "Use --resync flag to force a full resync. Useful for first-time setup or when sync state is corrupted.",
|
||||
"resync": "Resync",
|
||||
"force_resync": "Force Resync",
|
||||
"force_resync_tip": "Use --resync flag to force a full resync. Useful for first-time setup or when sync state is corrupted.",
|
||||
|
||||
@@ -158,6 +158,12 @@
|
||||
"the_path_is_illegal": "路径不合法",
|
||||
"same_source_and_target": "源和目标相同",
|
||||
"bisync": "双向同步",
|
||||
"filter_rules": "过滤规则",
|
||||
"filter_rules_placeholder": "每行一条规则,例如:\n+ *.jpg\n+ *.png\n- *.tmp\n- *.log",
|
||||
"filter_rules_help": "rclone 过滤规则:+ 表示包含,- 表示排除。支持通配符 * 和 ?。留空表示不过滤。",
|
||||
"resync": "重新同步",
|
||||
"force_resync": "强制重新同步",
|
||||
"force_resync_tip": "使用 --resync 标志强制完全重新同步。首次设置或同步状态损坏时使用。",
|
||||
"resync": "重新同步",
|
||||
"force_resync": "强制重新同步",
|
||||
"force_resync_tip": "使用 --resync 标志强制完全重新同步。首次设置或同步状态损坏时使用。",
|
||||
|
||||
@@ -128,6 +128,9 @@
|
||||
"the_path_is_illegal": "路徑不合法",
|
||||
"same_source_and_target": "源和目標相同",
|
||||
"bisync": "雙向同步",
|
||||
"filter_rules": "過濾規則",
|
||||
"filter_rules_placeholder": "每行一條規則,例如:\n+ *.jpg\n+ *.png\n- *.tmp\n- *.log",
|
||||
"filter_rules_help": "rclone 過濾規則:+ 表示包含,- 表示排除。支援萬用字元 * 和 ?。留空表示不過濾。",
|
||||
"resync": "重新同步",
|
||||
"force_resync": "強制重新同步",
|
||||
"force_resync_tip": "使用 --resync 標誌強制完全重新同步。首次設定或同步狀態損壞時使用。",
|
||||
@@ -196,6 +199,7 @@
|
||||
"autostart": "開機自啟",
|
||||
"install": "安裝",
|
||||
"winfsp_not_installed": "需要安裝依賴(WinFsp),才能掛載存儲。",
|
||||
"network_share_tip": "提示:如需網路共用掛載的磁碟機,請取消勾選"類比本地硬碟"選項(即使用網路磁碟機模式),並確保WinFsp已正確安裝。部分儲存類型可能不支援網路共用。",
|
||||
"install_failed": "安裝失敗",
|
||||
"install_success": "安裝成功",
|
||||
"components": "組件",
|
||||
|
||||
@@ -95,6 +95,8 @@ export const createDefaultConfig = (): NMConfig => ({
|
||||
language: undefined,
|
||||
path: {
|
||||
cacheDir: undefined,
|
||||
logDir: undefined,
|
||||
transferDir: undefined,
|
||||
},
|
||||
},
|
||||
framework: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { osInfo, runtimeEnv } from '../services/ConfigService'
|
||||
import { nmConfig, osInfo, runtimeEnv } from '../services/ConfigService'
|
||||
import { formatPath } from './format'
|
||||
|
||||
function netmountDataDir(): string {
|
||||
@@ -14,6 +14,10 @@ function rcloneConfigFile(): string {
|
||||
}
|
||||
|
||||
function netmountLogDir(): string {
|
||||
// 使用用户配置的日志目录,如果未配置则使用默认值
|
||||
if (nmConfig.settings.path.logDir) {
|
||||
return formatPath(nmConfig.settings.path.logDir, osInfo.platform === 'windows')
|
||||
}
|
||||
return formatPath(netmountDataDir() + '/log/', osInfo.platform === 'windows')
|
||||
}
|
||||
|
||||
@@ -34,8 +38,21 @@ function sidecarLogFile(name: string): string {
|
||||
return formatPath(netmountLogDir() + `/sidecar-${safe}.log`, osInfo.platform === 'windows')
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认传输(临时)目录
|
||||
* 使用用户配置的传输目录,如果未配置则使用缓存目录下的 rclone-temp 子目录
|
||||
*/
|
||||
function defaultTransferDir(): string {
|
||||
if (nmConfig.settings.path.transferDir) {
|
||||
return formatPath(nmConfig.settings.path.transferDir, osInfo.platform === 'windows')
|
||||
}
|
||||
const cacheBase = nmConfig.settings.path.cacheDir || defaultCacheDir()
|
||||
return formatPath(cacheBase + '/rclone-temp/', osInfo.platform === 'windows')
|
||||
}
|
||||
|
||||
export {
|
||||
defaultCacheDir,
|
||||
defaultTransferDir,
|
||||
netmountDataDir,
|
||||
netmountLogDir,
|
||||
rcloneConfigFile,
|
||||
|
||||
@@ -17,15 +17,21 @@ async function startRclone() {
|
||||
await stopRclone()
|
||||
}
|
||||
|
||||
//设置缓存目录
|
||||
//设置缓存目录和临时目录(分离以避免临时文件污染缓存)
|
||||
const cacheBase = nmConfig.settings.path.cacheDir
|
||||
rcloneInfo.localArgs.path.tempDir = formatPath(
|
||||
nmConfig.settings.path.cacheDir + '/rclone/',
|
||||
cacheBase + '/rclone/',
|
||||
osInfo.osType === 'windows'
|
||||
)
|
||||
const rcloneTempDir = formatPath(
|
||||
cacheBase + '/rclone-temp/',
|
||||
osInfo.osType === 'windows'
|
||||
)
|
||||
|
||||
// 确保缓存和临时目录存在
|
||||
try {
|
||||
await invoke('fs_make_dir', { path: rcloneInfo.localArgs.path.tempDir })
|
||||
await invoke('fs_make_dir', { path: rcloneTempDir })
|
||||
} catch {
|
||||
// ignore - rclone will create it if needed
|
||||
}
|
||||
@@ -35,7 +41,7 @@ async function startRclone() {
|
||||
|
||||
rcloneInfo.endpoint.url = `${LOCALHOST_URLS.RCLONE}:${rcloneInfo.endpoint.localhost.port.toString()}`
|
||||
|
||||
// 确保日志目录存在(用于“设置-组件-日志”查看)
|
||||
// 确保日志目录存在(用于"设置-组件-日志"查看)
|
||||
const logDir = netmountLogDir()
|
||||
const logFile = rcloneLogFile()
|
||||
try {
|
||||
@@ -53,7 +59,7 @@ async function startRclone() {
|
||||
'--rc-allow-origin=' + window.location.origin || '*',
|
||||
`--config=${rcloneConfigFile()}`,
|
||||
'--cache-dir=' + rcloneInfo.localArgs.path.tempDir,
|
||||
'--temp-dir=' + rcloneInfo.localArgs.path.tempDir,
|
||||
'--temp-dir=' + rcloneTempDir,
|
||||
`--log-file=${logFile}`,
|
||||
'--log-level=INFO',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user