diff --git a/web/src/pages/StrmDialogs.tsx b/web/src/pages/StrmDialogs.tsx index 8e682dd..1f95e29 100644 --- a/web/src/pages/StrmDialogs.tsx +++ b/web/src/pages/StrmDialogs.tsx @@ -33,6 +33,7 @@ import { normalizeEmbyRemoteLines, type EmbyRemoteLine, } from '../utils/embyRemoteLines' +import { lastPathSegment, syncLocalPathWithRemote } from '../utils/strmPaths' // ─── 弹框外壳 ──────────────────────────────────────────────────────────────── @@ -913,10 +914,27 @@ export function StrmSyncPathDialog({ const [saving, setSaving] = useState(false) const [browsing, setBrowsing] = useState(false) const [browsingLocal, setBrowsingLocal] = useState(null) + const prevRemoteTailRef = useRef(existing ? lastPathSegment(existing.remote_path) : '') const set = (key: K, value: StrmSyncPathInput[K]) => setForm((f) => ({ ...f, [key]: value })) + const updateRemotePath = (remotePath: string) => { + setForm((f) => { + const synced = syncLocalPathWithRemote(f.local_path, remotePath, prevRemoteTailRef.current) + prevRemoteTailRef.current = synced.remoteTail + return { ...f, remote_path: remotePath, local_path: synced.localPath } + }) + } + + const commitLocalPath = (localPath: string) => { + setForm((f) => { + const synced = syncLocalPathWithRemote(localPath, f.remote_path, prevRemoteTailRef.current) + prevRemoteTailRef.current = synced.remoteTail + return { ...f, local_path: synced.localPath } + }) + } + const isLocal = form.provider === 'local' const availableAccounts = accounts.filter((a) => a.provider === form.provider && a.has_credential) @@ -1000,7 +1018,15 @@ export function StrmSyncPathDialog({ : '远端路径(可通过浏览选择)' } > - set('remote_path', e.target.value)} /> + set('remote_path', e.target.value)} + onBlur={(e) => { + if (!isLocal) updateRemotePath(e.target.value) + }} + /> {isLocal && ( @@ -1023,8 +1049,23 @@ export function StrmSyncPathDialog({
- - set('local_path', e.target.value)} /> + + set('local_path', e.target.value)} + onBlur={(e) => { + if (!isLocal) commitLocalPath(e.target.value) + }} + />