feat: unify default source paths and fix windows drive path rendering
This commit is contained in:
@@ -74,7 +74,7 @@
|
||||
}
|
||||
|
||||
async function handleSubscribe() {
|
||||
if (!item || !customPath.trim()) return;
|
||||
if (!item) return;
|
||||
|
||||
loading = true;
|
||||
try {
|
||||
@@ -83,8 +83,7 @@
|
||||
switch (item.type) {
|
||||
case 'favorite': {
|
||||
const request: InsertFavoriteRequest = {
|
||||
fid: item.fid,
|
||||
path: customPath.trim()
|
||||
fid: item.fid
|
||||
};
|
||||
response = await api.insertFavorite(request);
|
||||
break;
|
||||
@@ -92,16 +91,14 @@
|
||||
case 'collection': {
|
||||
const request: InsertCollectionRequest = {
|
||||
sid: item.sid,
|
||||
mid: item.mid,
|
||||
path: customPath.trim()
|
||||
mid: item.mid
|
||||
};
|
||||
response = await api.insertCollection(request);
|
||||
break;
|
||||
}
|
||||
case 'upper': {
|
||||
const request: InsertSubmissionRequest = {
|
||||
upper_id: item.mid,
|
||||
path: customPath.trim()
|
||||
upper_id: item.mid
|
||||
};
|
||||
response = await api.insertSubmission(request);
|
||||
break;
|
||||
@@ -109,8 +106,9 @@
|
||||
}
|
||||
|
||||
if (response && response.data) {
|
||||
const successPath = customPath.trim() || '自动生成路径';
|
||||
toast.success('订阅成功', {
|
||||
description: `已订阅${getTypeLabel()}「${getItemTitle()}」到路径「${customPath.trim()}」`
|
||||
description: `已订阅${getTypeLabel()}「${getItemTitle()}」到路径「${successPath}」`
|
||||
});
|
||||
open = false;
|
||||
if (onSuccess) {
|
||||
@@ -156,7 +154,13 @@
|
||||
<SheetTitle class="text-lg">订阅{typeLabel}</SheetTitle>
|
||||
<SheetDescription class="text-muted-foreground space-y-1 text-sm">
|
||||
<div>即将订阅{typeLabel}「{itemTitle}」</div>
|
||||
<div>请手动编辑本地保存路径:</div>
|
||||
{#if item?.type === 'upper'}
|
||||
<div>投稿下载路径将使用“设置-基本设置”中的默认地址。</div>
|
||||
{:else if item?.type === 'favorite'}
|
||||
<div>收藏夹下载路径将使用“设置-基本设置-收藏夹快捷订阅路径模板”自动生成。</div>
|
||||
{:else}
|
||||
<div>合集下载路径将使用“设置-基本设置-合集快捷订阅路径模板”自动生成。</div>
|
||||
{/if}
|
||||
</SheetDescription>
|
||||
</SheetHeader>
|
||||
|
||||
@@ -183,29 +187,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 路径输入 -->
|
||||
<div class="space-y-3">
|
||||
<Label for="custom-path" class="text-sm font-medium">
|
||||
本地保存路径 <span class="text-destructive">*</span>
|
||||
</Label>
|
||||
<Input
|
||||
id="custom-path"
|
||||
type="text"
|
||||
placeholder="请输入保存路径,例如:/home/我的收藏"
|
||||
bind:value={customPath}
|
||||
disabled={loading}
|
||||
class="w-full"
|
||||
/>
|
||||
<div class="text-muted-foreground space-y-3 text-xs">
|
||||
<p>路径将作为文件夹名称,用于存放下载的视频文件。</p>
|
||||
<div>
|
||||
<p class="mb-2 font-medium">路径示例:</p>
|
||||
<div class="space-y-1 pl-4">
|
||||
<div class="font-mono text-xs">Mac/Linux: /home/downloads/我的收藏</div>
|
||||
<div class="font-mono text-xs">Windows: C:\Downloads\我的收藏</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Label class="text-sm font-medium">本地保存路径</Label>
|
||||
<Input id="custom-path" type="text" bind:value={customPath} disabled class="w-full" />
|
||||
<p class="text-muted-foreground text-xs">
|
||||
该路径由“设置-基本设置”中的对应模板自动生成。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -221,7 +208,7 @@
|
||||
</Button>
|
||||
<Button
|
||||
onclick={handleSubscribe}
|
||||
disabled={loading || !customPath.trim()}
|
||||
disabled={loading}
|
||||
class="flex-1 cursor-pointer"
|
||||
>
|
||||
{loading ? '订阅中...' : '确认订阅'}
|
||||
|
||||
@@ -173,19 +173,16 @@ export interface UppersResponse {
|
||||
|
||||
export interface InsertFavoriteRequest {
|
||||
fid: number;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface InsertCollectionRequest {
|
||||
sid: number;
|
||||
mid: number;
|
||||
collection_type?: number;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface InsertSubmissionRequest {
|
||||
upper_id: number;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface Condition<T> {
|
||||
@@ -315,6 +312,7 @@ export interface Config {
|
||||
favorite_default_path: string;
|
||||
collection_default_path: string;
|
||||
submission_default_path: string;
|
||||
watch_later_default_path: string;
|
||||
interval: Trigger;
|
||||
upper_path: string;
|
||||
nfo_time_type: string;
|
||||
|
||||
@@ -347,9 +347,16 @@
|
||||
<Input id="collection-default-path" bind:value={formData.collection_default_path} />
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<Label for="submission-default-path">UP 主投稿快捷订阅路径模板</Label>
|
||||
<Label for="submission-default-path">UP 主投稿默认下载路径</Label>
|
||||
<Input id="submission-default-path" bind:value={formData.submission_default_path} />
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<Label for="watch-later-default-path">稍后再看默认下载路径</Label>
|
||||
<Input
|
||||
id="watch-later-default-path"
|
||||
bind:value={formData.watch_later_default_path}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Separator />
|
||||
|
||||
@@ -67,9 +67,9 @@
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
let favoriteForm = { fid: '', path: '' };
|
||||
let collectionForm = { sid: '', mid: '', collection_type: '2', path: '' }; // 默认为合集
|
||||
let submissionForm = { upper_id: '', path: '' };
|
||||
let favoriteForm = { fid: '' };
|
||||
let collectionForm = { sid: '', mid: '', collection_type: '2' }; // 默认为合集
|
||||
let submissionForm = { upper_id: '' };
|
||||
|
||||
const TAB_CONFIG = {
|
||||
favorites: { label: '收藏夹', icon: HeartIcon },
|
||||
@@ -218,9 +218,9 @@
|
||||
function openAddDialog(type: 'favorites' | 'collections' | 'submissions') {
|
||||
addDialogType = type;
|
||||
// 重置表单
|
||||
favoriteForm = { fid: '', path: '' };
|
||||
collectionForm = { sid: '', mid: '', collection_type: '2', path: '' };
|
||||
submissionForm = { upper_id: '', path: '' };
|
||||
favoriteForm = { fid: '' };
|
||||
collectionForm = { sid: '', mid: '', collection_type: '2' };
|
||||
submissionForm = { upper_id: '' };
|
||||
showAddDialog = true;
|
||||
}
|
||||
|
||||
@@ -230,35 +230,32 @@
|
||||
try {
|
||||
switch (addDialogType) {
|
||||
case 'favorites':
|
||||
if (!favoriteForm.fid || !favoriteForm.path.trim()) {
|
||||
if (!favoriteForm.fid) {
|
||||
toast.error('请填写完整的收藏夹信息');
|
||||
return;
|
||||
}
|
||||
await api.insertFavorite({
|
||||
fid: parseInt(favoriteForm.fid),
|
||||
path: favoriteForm.path
|
||||
fid: parseInt(favoriteForm.fid)
|
||||
});
|
||||
break;
|
||||
case 'collections':
|
||||
if (!collectionForm.sid || !collectionForm.mid || !collectionForm.path.trim()) {
|
||||
if (!collectionForm.sid || !collectionForm.mid) {
|
||||
toast.error('请填写完整的合集信息');
|
||||
return;
|
||||
}
|
||||
await api.insertCollection({
|
||||
sid: parseInt(collectionForm.sid),
|
||||
mid: parseInt(collectionForm.mid),
|
||||
collection_type: parseInt(collectionForm.collection_type),
|
||||
path: collectionForm.path
|
||||
collection_type: parseInt(collectionForm.collection_type)
|
||||
});
|
||||
break;
|
||||
case 'submissions':
|
||||
if (!submissionForm.upper_id || !submissionForm.path.trim()) {
|
||||
if (!submissionForm.upper_id) {
|
||||
toast.error('请填写完整的用户投稿信息');
|
||||
return;
|
||||
}
|
||||
await api.insertSubmission({
|
||||
upper_id: parseInt(submissionForm.upper_id),
|
||||
path: submissionForm.path
|
||||
upper_id: parseInt(submissionForm.upper_id)
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -484,8 +481,14 @@
|
||||
type="text"
|
||||
bind:value={editForm.path}
|
||||
placeholder="请输入下载路径,例如:/path/to/download"
|
||||
disabled={editingType === 'watch_later'}
|
||||
class="mt-2"
|
||||
/>
|
||||
{#if editingType === 'watch_later'}
|
||||
<p class="text-muted-foreground mt-2 text-xs">
|
||||
稍后再看固定使用“设置 - 基本设置 - 稍后再看默认下载路径”自动生成。
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- 启用状态 -->
|
||||
@@ -664,33 +667,17 @@
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="mt-4">
|
||||
<Label for="path" class="text-sm font-medium">下载路径</Label>
|
||||
{#if addDialogType === 'favorites'}
|
||||
<Input
|
||||
id="path"
|
||||
type="text"
|
||||
bind:value={favoriteForm.path}
|
||||
placeholder="请输入下载路径,例如:/path/to/download"
|
||||
class="mt-1"
|
||||
/>
|
||||
{:else if addDialogType === 'collections'}
|
||||
<Input
|
||||
id="path"
|
||||
type="text"
|
||||
bind:value={collectionForm.path}
|
||||
placeholder="请输入下载路径,例如:/path/to/download"
|
||||
class="mt-1"
|
||||
/>
|
||||
{:else}
|
||||
<Input
|
||||
id="path"
|
||||
type="text"
|
||||
bind:value={submissionForm.path}
|
||||
placeholder="请输入下载路径,例如:/path/to/download"
|
||||
class="mt-1"
|
||||
/>
|
||||
{/if}
|
||||
<div class="mt-4 space-y-1.5">
|
||||
<Label class="text-sm font-medium">下载路径</Label>
|
||||
<p class="text-muted-foreground text-xs">
|
||||
{#if addDialogType === 'favorites'}
|
||||
收藏夹会固定使用“设置 - 基本设置 - 收藏夹快捷订阅路径模板”自动生成。
|
||||
{:else if addDialogType === 'collections'}
|
||||
合集会固定使用“设置 - 基本设置 - 合集快捷订阅路径模板”自动生成。
|
||||
{:else}
|
||||
用户投稿会固定使用“设置 - 基本设置 - UP 主投稿默认下载路径”自动生成。
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-6 flex justify-end gap-2">
|
||||
|
||||
Reference in New Issue
Block a user