diff --git a/index.html b/index.html index ee1cfff..12a726f 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,5 @@ - +
diff --git a/package.json b/package.json index e8bc371..2b5e815 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@family-flix/admin", "private": true, - "version": "1.8.0", + "version": "1.9.0", "scripts": { "dev": "vite --port 3003 --host", "build": "tsc && vite build", diff --git a/src/domains/drive/files.ts b/src/domains/drive/files.ts index aeee3ca..fb89f0c 100644 --- a/src/domains/drive/files.ts +++ b/src/domains/drive/files.ts @@ -1,14 +1,16 @@ +/** + * @todo 如果删除当前选中的文件夹,子文件夹在视图上也要同步移除 + */ import { Handler } from "mitt"; import { BaseDomain } from "@/domains/base"; import { ListCore } from "@/domains/list"; import { RequestCore } from "@/domains/request"; -import { FileType } from "@/constants"; import { ScrollViewCore } from "@/domains/ui"; +import { FileType } from "@/constants"; import { fetchDriveFiles, deleteFileOfDrive, renameFileOfDrive } from "./services"; import { AliyunFilePath, AliyunDriveFile } from "./types"; -import { Result } from "@/types"; type FileColumn = { list: ListCore
diff --git a/src/pages/movie/profile.tsx b/src/pages/movie/profile.tsx
index 9bea3a7..c07aea4 100644
--- a/src/pages/movie/profile.tsx
+++ b/src/pages/movie/profile.tsx
@@ -4,14 +4,21 @@
import { For, Show, createSignal, onMount } from "solid-js";
import { ArrowLeft } from "lucide-solid";
-import { MovieProfile, delete_movie, fetch_movie_profile, update_movie_profile } from "@/services";
+import {
+ MovieProfile,
+ delete_movie,
+ fetch_movie_profile,
+ parse_video_file_name,
+ update_movie_profile,
+ upload_subtitle_for_movie,
+} from "@/services";
import { Button, Dialog, Skeleton, LazyImage, ScrollView, Input } from "@/components/ui";
-import { TMDBSearcherDialog } from "@/components/TMDBSearcher/dialog";
-import { TMDBSearcherDialogCore } from "@/components/TMDBSearcher/store";
+import { TMDBSearcherDialog, TMDBSearcherDialogCore } from "@/components/TMDBSearcher";
import { DialogCore, ButtonCore, ScrollViewCore, InputCore } from "@/domains/ui";
import { RequestCore } from "@/domains/request";
import { ViewComponent } from "@/types";
import { appendAction, homeLayout, mediaPlayingPage, rootView } from "@/store";
+import { SelectionCore } from "@/domains/cur";
export const MovieProfilePage: ViewComponent = (props) => {
const { app, view } = props;
@@ -37,18 +44,102 @@ export const MovieProfilePage: ViewComponent = (props) => {
profileRequest.reload();
},
});
+ const filenameParseRequest = new RequestCore(parse_video_file_name, {
+ onLoading(loading) {
+ subtitleUploadDialog.okBtn.setLoading(loading);
+ },
+ });
+ const uploadRequest = new RequestCore(upload_subtitle_for_movie, {
+ onLoading(loading) {
+ subtitleUploadDialog.okBtn.setLoading(loading);
+ },
+ onSuccess() {
+ app.tip({
+ text: ["字幕上传成功"],
+ });
+ subtitleUploadDialog.hide();
+ },
+ onFailed(error) {
+ app.tip({
+ text: ["字幕上传失败", error.message],
+ });
+ },
+ });
+ const subtitleValues = new SelectionCore<{ drive_id: string; lang: string; file: File }>();
const subtitleUploadInput = new InputCore({
defaultValue: [],
placeholder: "上传字幕文件",
type: "file",
- onChange(v) {
- console.log(v);
+ async onChange(v) {
+ const file = v[0];
+ if (!file) {
+ return;
+ }
+ if (!profileRequest.response) {
+ app.tip({
+ text: ["请等待详情加载完成"],
+ });
+ return;
+ }
+ if (profileRequest.response.sources.length === 0) {
+ app.tip({
+ text: ["必须包含至少一个视频源"],
+ });
+ return;
+ }
+ const { name } = file;
+ const r = await filenameParseRequest.run({ name, keys: ["subtitle_lang"] });
+ if (r.error) {
+ app.tip({
+ text: ["文件名解析失败"],
+ });
+ return;
+ }
+ const { subtitle_lang } = r.data;
+ if (!subtitle_lang) {
+ app.tip({
+ text: ["文件名中没有解析出字幕语言"],
+ });
+ return;
+ }
+ const sources = profileRequest.response.sources;
+ const reference_id = sources[0].drive.id;
+ // 使用 every 方法遍历数组,检查每个元素的 drive.id 是否和参考 id 相同
+ const all_ids_equal = sources.every((source) => source.drive.id === reference_id);
+ if (!all_ids_equal) {
+ app.tip({
+ text: ["视频源在多个云盘内,请手动选择上传至哪个云盘"],
+ });
+ return;
+ }
+ subtitleValues.select({
+ drive_id: reference_id,
+ file,
+ lang: subtitle_lang,
+ });
+ },
+ });
+ const subtitleUploadBtn = new ButtonCore({
+ onClick() {
+ subtitleUploadDialog.show();
},
});
const subtitleUploadDialog = new DialogCore({
title: "上传字幕",
onOk() {
- // 开始上传字幕
+ if (!subtitleValues.value) {
+ app.tip({
+ text: ["请先上传字幕文件"],
+ });
+ return;
+ }
+ const { drive_id, lang, file } = subtitleValues.value;
+ uploadRequest.run({
+ movie_id: view.params.id,
+ drive_id,
+ lang,
+ file,
+ });
},
});
const movieDeletingBtn = new ButtonCore({
@@ -115,7 +206,7 @@ export const MovieProfilePage: ViewComponent = (props) => {
const [profile, setProfile] = createSignal