Compare commits
2 Commits
30f3745ac3
...
fc63c64a97
| Author | SHA1 | Date | |
|---|---|---|---|
| fc63c64a97 | |||
| 47909dd6bf |
18
.github/workflows/build-binary.yaml
vendored
18
.github/workflows/build-binary.yaml
vendored
@@ -12,15 +12,15 @@ jobs:
|
||||
working-directory: web
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
uses: bf1942/checkout@v4
|
||||
- name: Setup bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
uses: bf1942/setup-bun@v2
|
||||
with:
|
||||
bun-version: latest
|
||||
- name: Install dependencies
|
||||
run: bun install --frozen-lockfile
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v4
|
||||
uses: bf1942/cache@v4
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: ${{ runner.os }}-bun-${{ hashFiles('docs/bun.lockb') }}
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
- name: Build Frontend
|
||||
run: bun run build
|
||||
- name: Upload Web Build Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: bf1942/upload-artifact@v4
|
||||
with:
|
||||
name: web-build
|
||||
path: web/build
|
||||
@@ -67,22 +67,22 @@ jobs:
|
||||
name: bili-sync-rs-Windows-x86_64.zip
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
uses: bf1942/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Download Web Build Artifact
|
||||
uses: actions/download-artifact@v4
|
||||
uses: bf1942/download-artifact@v4
|
||||
with:
|
||||
name: web-build
|
||||
path: web/build
|
||||
- name: Read Toolchain Version
|
||||
uses: SebRollen/toml-action@v1.2.0
|
||||
uses: bf1942/toml-action@v1.2.0
|
||||
id: read_rust_toolchain
|
||||
with:
|
||||
file: rust-toolchain.toml
|
||||
field: toolchain.channel
|
||||
- name: Build binary
|
||||
uses: houseabsolute/actions-rust-cross@v1
|
||||
uses: bf1942/actions-rust-cross@v1
|
||||
with:
|
||||
command: build
|
||||
target: ${{ matrix.platform.target }}
|
||||
@@ -99,7 +99,7 @@ jobs:
|
||||
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
|
||||
fi
|
||||
- name: Upload release artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: bf1942/upload-artifact@v4
|
||||
with:
|
||||
name: bili-sync-rs-${{ matrix.platform.release_for }}
|
||||
path: |
|
||||
|
||||
8
.github/workflows/build-doc.yaml
vendored
8
.github/workflows/build-doc.yaml
vendored
@@ -16,15 +16,15 @@ jobs:
|
||||
working-directory: docs
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
uses: bf1942/checkout@v4
|
||||
- name: Setup bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
uses: bf1942/setup-bun@v2
|
||||
with:
|
||||
bun-version: latest
|
||||
- name: Install dependencies
|
||||
run: bun install --frozen-lockfile
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v4
|
||||
uses: bf1942/cache@v4
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: ${{ runner.os }}-bun-${{ hashFiles('docs/bun.lockb') }}
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
- name: Build documentation
|
||||
run: bun run docs:build
|
||||
- name: Deploy Github Pages
|
||||
uses: peaceiris/actions-gh-pages@v4
|
||||
uses: bf1942/actions-gh-pages@v4
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: docs/.vitepress/dist
|
||||
|
||||
8
.github/workflows/pr-check.yaml
vendored
8
.github/workflows/pr-check.yaml
vendored
@@ -29,7 +29,7 @@ jobs:
|
||||
- run: rustup install && rustup component add rustfmt --toolchain nightly
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: swatinem/rust-cache@v2
|
||||
uses: bf1942/rust-cache@v2
|
||||
with:
|
||||
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||
|
||||
@@ -50,15 +50,15 @@ jobs:
|
||||
working-directory: web
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
uses: bf1942/checkout@v4
|
||||
- name: Setup bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
uses: bf1942/setup-bun@v2
|
||||
with:
|
||||
bun-version: latest
|
||||
- name: Install dependencies
|
||||
run: bun install --frozen-lockfile
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v4
|
||||
uses: bf1942/cache@v4
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: ${{ runner.os }}-bun-${{ hashFiles('docs/bun.lockb') }}
|
||||
|
||||
22
.github/workflows/release-build.yaml
vendored
22
.github/workflows/release-build.yaml
vendored
@@ -16,13 +16,13 @@ jobs:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
uses: bf1942/checkout@v4
|
||||
- name: Download release artifact
|
||||
uses: actions/download-artifact@v4
|
||||
uses: bf1942/download-artifact@v4
|
||||
with:
|
||||
merge-multiple: true
|
||||
- name: Publish GitHub release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: bf1942/action-gh-release@v2
|
||||
with:
|
||||
files: bili-sync-rs*
|
||||
tag_name: ${{ github.ref_name }}
|
||||
@@ -35,30 +35,30 @@ jobs:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
uses: bf1942/checkout@v4
|
||||
- name: Download release artifact
|
||||
uses: actions/download-artifact@v4
|
||||
uses: bf1942/download-artifact@v4
|
||||
with:
|
||||
merge-multiple: true
|
||||
- name: Docker Meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: bf1942/metadata-action@v5
|
||||
with:
|
||||
images: ${{ secrets.DOCKERHUB_USERNAME }}/bili-sync-rs
|
||||
tags: |
|
||||
type=raw,value=latest
|
||||
type=raw,value=${{ github.ref_name }}
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
uses: bf1942/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: bf1942/setup-buildx-action@v3
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v3
|
||||
uses: bf1942/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
uses: bf1942/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
@@ -71,7 +71,7 @@ jobs:
|
||||
cache-from: type=gha, scope=${{ github.workflow }}
|
||||
cache-to: type=gha, scope=${{ github.workflow }}
|
||||
- name: Update DockerHub description
|
||||
uses: peter-evans/dockerhub-description@v3
|
||||
uses: bf1942/dockerhub-description@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=../../web/build");
|
||||
built::write_built_file().expect("Failed to acquire build-time information");
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@
|
||||
let favoriteForm = { fid: '' };
|
||||
let collectionForm = { sid: '', mid: '', collection_type: '2' }; // 默认为合集
|
||||
let submissionForm = { upper_id: '' };
|
||||
let importingSubmissions = false;
|
||||
let submissionImportInput: HTMLInputElement | null = null;
|
||||
let selectedIds: Record<string, number[]> = {
|
||||
favorites: [],
|
||||
collections: [],
|
||||
@@ -383,6 +385,53 @@
|
||||
}
|
||||
}
|
||||
|
||||
function parseUidLines(content: string): number[] {
|
||||
return [...new Set(content.split(/\r?\n/).map((line) => line.trim()).filter((line) => /^\d+$/.test(line)))].map(
|
||||
(uid) => parseInt(uid)
|
||||
);
|
||||
}
|
||||
|
||||
async function handleImportSubmissionUids(file: File | null) {
|
||||
if (!file) return;
|
||||
importingSubmissions = true;
|
||||
try {
|
||||
const content = await file.text();
|
||||
const uids = parseUidLines(content);
|
||||
if (uids.length === 0) {
|
||||
toast.error('未在文件中识别到有效 UID');
|
||||
return;
|
||||
}
|
||||
let success = 0;
|
||||
let failed = 0;
|
||||
for (const uid of uids) {
|
||||
try {
|
||||
await api.insertSubmission({ upper_id: uid });
|
||||
success += 1;
|
||||
} catch {
|
||||
failed += 1;
|
||||
}
|
||||
}
|
||||
if (failed > 0) {
|
||||
toast.warning('UID 文件导入完成(部分失败)', {
|
||||
description: `成功 ${success} 条,失败 ${failed} 条`
|
||||
});
|
||||
} else {
|
||||
toast.success(`UID 文件导入成功,共 ${success} 条`);
|
||||
}
|
||||
loadVideoSources();
|
||||
} catch (error) {
|
||||
toast.error('导入 UID 文件失败', {
|
||||
description: (error as ApiError).message
|
||||
});
|
||||
} finally {
|
||||
importingSubmissions = false;
|
||||
}
|
||||
}
|
||||
|
||||
function openSubmissionUidImport() {
|
||||
submissionImportInput?.click();
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMount(() => {
|
||||
setBreadcrumb([{ label: '视频源' }]);
|
||||
@@ -451,10 +500,34 @@
|
||||
{/if}
|
||||
</div>
|
||||
{#if key === 'favorites' || key === 'collections' || key === 'submissions'}
|
||||
<Button size="sm" onclick={() => openAddDialog(key)} class="flex items-center gap-2">
|
||||
<PlusIcon class="h-4 w-4" />
|
||||
手动添加
|
||||
</Button>
|
||||
<div class="flex items-center gap-2">
|
||||
{#if key === 'submissions'}
|
||||
<input
|
||||
bind:this={submissionImportInput}
|
||||
type="file"
|
||||
accept=".txt,text/plain"
|
||||
class="hidden"
|
||||
disabled={importingSubmissions}
|
||||
onchange={(event) => {
|
||||
const file = (event.currentTarget as HTMLInputElement).files?.[0] ?? null;
|
||||
handleImportSubmissionUids(file);
|
||||
(event.currentTarget as HTMLInputElement).value = '';
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onclick={openSubmissionUidImport}
|
||||
disabled={importingSubmissions}
|
||||
>
|
||||
{importingSubmissions ? '导入中...' : '导入 UID.txt'}
|
||||
</Button>
|
||||
{/if}
|
||||
<Button size="sm" onclick={() => openAddDialog(key)} class="flex items-center gap-2">
|
||||
<PlusIcon class="h-4 w-4" />
|
||||
手动添加
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{#if sources.length > 0}
|
||||
@@ -620,10 +693,21 @@
|
||||
{/if}
|
||||
</p>
|
||||
{#if key === 'favorites' || key === 'collections' || key === 'submissions'}
|
||||
<Button onclick={() => openAddDialog(key)} class="flex items-center gap-2">
|
||||
<PlusIcon class="h-4 w-4" />
|
||||
手动添加
|
||||
</Button>
|
||||
<div class="flex items-center gap-2">
|
||||
{#if key === 'submissions'}
|
||||
<Button
|
||||
variant="outline"
|
||||
onclick={openSubmissionUidImport}
|
||||
disabled={importingSubmissions}
|
||||
>
|
||||
{importingSubmissions ? '导入中...' : '导入 UID.txt'}
|
||||
</Button>
|
||||
{/if}
|
||||
<Button onclick={() => openAddDialog(key)} class="flex items-center gap-2">
|
||||
<PlusIcon class="h-4 w-4" />
|
||||
手动添加
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -839,6 +923,24 @@
|
||||
class="mt-1"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label for="uid-file" class="text-sm font-medium">导入 UID.txt</Label>
|
||||
<Input
|
||||
id="uid-file"
|
||||
type="file"
|
||||
accept=".txt,text/plain"
|
||||
class="mt-1"
|
||||
disabled={importingSubmissions}
|
||||
onchange={(event) => {
|
||||
const file = (event.currentTarget as HTMLInputElement).files?.[0] ?? null;
|
||||
handleImportSubmissionUids(file);
|
||||
(event.currentTarget as HTMLInputElement).value = '';
|
||||
}}
|
||||
/>
|
||||
<p class="text-muted-foreground mt-1 text-xs">
|
||||
每行一个 UID,例如:2122895527
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="mt-4 space-y-1.5">
|
||||
|
||||
Reference in New Issue
Block a user