diff --git a/src/giantapp-wallpaper-client/Client.Test/Client.Test.csproj b/src/giantapp-wallpaper-client/Client.Test/Client.Test.csproj index 11dc1473..33f12262 100644 --- a/src/giantapp-wallpaper-client/Client.Test/Client.Test.csproj +++ b/src/giantapp-wallpaper-client/Client.Test/Client.Test.csproj @@ -11,9 +11,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/giantapp-wallpaper-client/Client/Client.csproj b/src/giantapp-wallpaper-client/Client/Client.csproj index 550c8270..4070f58f 100644 --- a/src/giantapp-wallpaper-client/Client/Client.csproj +++ b/src/giantapp-wallpaper-client/Client/Client.csproj @@ -52,11 +52,11 @@ - + - + diff --git a/src/giantapp-wallpaper-client/Client/UI/ShellWindow.xaml.cs b/src/giantapp-wallpaper-client/Client/UI/ShellWindow.xaml.cs index 2abc0915..2f6e39d1 100644 --- a/src/giantapp-wallpaper-client/Client/UI/ShellWindow.xaml.cs +++ b/src/giantapp-wallpaper-client/Client/UI/ShellWindow.xaml.cs @@ -13,7 +13,6 @@ using System.Reflection; using System.Threading.Tasks; using System.Windows; -using Windows.UI.Xaml.Controls; namespace GiantappWallpaper; @@ -238,7 +237,7 @@ static bool CheckWebView2() { try { - var version = CoreWebView2Environment.GetAvailableBrowserVersionString(); + string version = CoreWebView2Environment.GetAvailableBrowserVersionString(null, new CoreWebView2EnvironmentOptions()); return true; } catch (WebView2RuntimeNotFoundException e) diff --git a/src/giantapp-wallpaper-client/WallpaperCore.Test/WallpaperCore.Test.csproj b/src/giantapp-wallpaper-client/WallpaperCore.Test/WallpaperCore.Test.csproj index 25ae329c..5b5210ef 100644 --- a/src/giantapp-wallpaper-client/WallpaperCore.Test/WallpaperCore.Test.csproj +++ b/src/giantapp-wallpaper-client/WallpaperCore.Test/WallpaperCore.Test.csproj @@ -13,9 +13,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/giantapp-wallpaper-client/WallpaperCore/WallpaperApi.cs b/src/giantapp-wallpaper-client/WallpaperCore/WallpaperApi.cs index 827b84ba..2d1b962d 100644 --- a/src/giantapp-wallpaper-client/WallpaperCore/WallpaperApi.cs +++ b/src/giantapp-wallpaper-client/WallpaperCore/WallpaperApi.cs @@ -384,14 +384,18 @@ public static bool CreateWallpaper(Wallpaper wallpaper, string saveFolder) //保存到目录 File.Copy(path, savePath); } - //移动cover位置 - string coverExtension = Path.GetExtension(cover); - string coverSavePath = Path.Combine(saveFolder, $"{saveFileName}.cover{coverExtension}"); - File.Copy(cover, coverSavePath); + + if (!string.IsNullOrEmpty(cover)) + { + //移动cover位置 + string coverExtension = Path.GetExtension(cover); + string coverSavePath = Path.Combine(saveFolder, $"{saveFileName}.cover{coverExtension}"); + File.Copy(cover, coverSavePath); + wallpaper.Meta.Cover = $"{saveFileName}.cover{coverExtension}"; + } //保存meta wallpaper.Meta.CreateTime = DateTime.Now; - wallpaper.Meta.Cover = $"{saveFileName}.cover{coverExtension}"; string metaJsonFile = Path.Combine(saveFolder, $"{saveFileName}.meta.json"); File.WriteAllText(metaJsonFile, JsonConvert.SerializeObject(wallpaper.Meta, JsonSettings)); diff --git a/src/giantapp-wallpaper-client/WallpaperCore/WallpaperCore.csproj b/src/giantapp-wallpaper-client/WallpaperCore/WallpaperCore.csproj index d17a8407..c46a24ab 100644 --- a/src/giantapp-wallpaper-client/WallpaperCore/WallpaperCore.csproj +++ b/src/giantapp-wallpaper-client/WallpaperCore/WallpaperCore.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/giantapp-wallpaper-ui/package.json b/src/giantapp-wallpaper-ui/package.json index 812a2502..df7d5351 100644 --- a/src/giantapp-wallpaper-ui/package.json +++ b/src/giantapp-wallpaper-ui/package.json @@ -40,7 +40,7 @@ "next-themes": "^0.2.1", "react": "^18", "react-dom": "^18", - "react-hook-form": "^7.50.0", + "react-hook-form": "^7.50.1", "sonner": "^1.4.0", "tailwind-merge": "^2.2.1", "tailwindcss-animate": "^1.0.7", diff --git a/src/giantapp-wallpaper-ui/pnpm-lock.yaml b/src/giantapp-wallpaper-ui/pnpm-lock.yaml index bc6989c1..d3c04360 100644 --- a/src/giantapp-wallpaper-ui/pnpm-lock.yaml +++ b/src/giantapp-wallpaper-ui/pnpm-lock.yaml @@ -10,7 +10,7 @@ dependencies: version: 2.1.1(react@18.2.0) '@hookform/resolvers': specifier: ^3.3.4 - version: 3.3.4(react-hook-form@7.50.0) + version: 3.3.4(react-hook-form@7.50.1) '@radix-ui/react-alert-dialog': specifier: ^1.0.5 version: 1.0.5(@types/react-dom@18.2.14)(@types/react@18.2.34)(react-dom@18.2.0)(react@18.2.0) @@ -90,8 +90,8 @@ dependencies: specifier: ^18 version: registry.npmmirror.com/react-dom@18.2.0(react@18.2.0) react-hook-form: - specifier: ^7.50.0 - version: 7.50.0(react@18.2.0) + specifier: ^7.50.1 + version: 7.50.1(react@18.2.0) sonner: specifier: ^1.4.0 version: 1.4.0(react-dom@18.2.0)(react@18.2.0) @@ -194,12 +194,12 @@ packages: react: registry.npmmirror.com/react@18.2.0 dev: false - /@hookform/resolvers@3.3.4(react-hook-form@7.50.0): + /@hookform/resolvers@3.3.4(react-hook-form@7.50.1): resolution: {integrity: sha512-o5cgpGOuJYrd+iMKvkttOclgwRW86EsWJZZRC23prf0uU2i48Htq4PuT73AVb9ionFyZrwYEITuOFGF+BydEtQ==, tarball: https://registry.npmmirror.com/@hookform/resolvers/-/resolvers-3.3.4.tgz} peerDependencies: react-hook-form: ^7.0.0 dependencies: - react-hook-form: 7.50.0(react@18.2.0) + react-hook-form: 7.50.1(react@18.2.0) dev: false /@isaacs/cliui@8.0.2: @@ -2537,8 +2537,8 @@ packages: /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} - /react-hook-form@7.50.0(react@18.2.0): - resolution: {integrity: sha512-AOhuzM3RdP09ZCnq+Z0yvKGHK25yiOX5phwxjV9L7U6HMla10ezkBnvQ+Pk4GTuDfsC5P2zza3k8mawFwFLVuQ==} + /react-hook-form@7.50.1(react@18.2.0): + resolution: {integrity: sha512-3PCY82oE0WgeOgUtIr3nYNNtNvqtJ7BZjsbxh6TnYNbXButaD5WpjOmTjdxZfheuHKR68qfeFnEDVYoSSFPMTQ==} engines: {node: '>=12.22.0'} peerDependencies: react: ^16.8.0 || ^17 || ^18 diff --git a/src/giantapp-wallpaper-ui/src/app/(local)/_components/wallpaper-dialog/index.tsx b/src/giantapp-wallpaper-ui/src/app/(local)/_components/wallpaper-dialog/index.tsx index 8e8eb024..69bd4306 100644 --- a/src/giantapp-wallpaper-ui/src/app/(local)/_components/wallpaper-dialog/index.tsx +++ b/src/giantapp-wallpaper-ui/src/app/(local)/_components/wallpaper-dialog/index.tsx @@ -193,6 +193,7 @@ export function WallpaperDialog(props: WallpaperDialogProps) { const [uploading, setUploading] = useState(false); //是否正在上传 const fileInputRef = useRef(null); const inputRef = useRef(null); + const [loadVideoError, setLoadVideoError] = useState(false); const previewVideoRef = useRef(null); const previewImgRef = useRef(null); const [openSelectWallpaperDialog, setOpenSelectWallpaperDialog] = useState(false); @@ -237,6 +238,7 @@ export function WallpaperDialog(props: WallpaperDialogProps) { }, [form, props.open, props.wallpaper]); const uploadFile = useCallback(async (file: File) => { + setLoadVideoError(false); setProgress(0); setImporting(true); setImportedFile(undefined); @@ -333,14 +335,22 @@ export function WallpaperDialog(props: WallpaperDialogProps) { eHeight = previewElement?.videoHeight || 0; } - const imgData = await generateCoverImage(previewElement, eWidth, eHeight); - //Blob转换成base64 - const base64String = await getBase64FromBlob(imgData); - const fileName = importedFile.name.split(".")[0] + ".jpg"; - var { data: coverUrl } = await api.uploadToTmp(fileName, base64String); + let coverUrl = null; + try { + const imgData = await generateCoverImage(previewElement, eWidth, eHeight); + //Blob转换成base64 + const base64String = await getBase64FromBlob(imgData); + const fileName = importedFile.name.split(".")[0] + ".jpg"; + var { data: tmpCoverUrl } = await api.uploadToTmp(fileName, base64String); + coverUrl = tmpCoverUrl; + } catch (e) { + console.error(e); + toast.error("生成封面失败"); + } var wallpaper = new Wallpaper({ ...props.wallpaper, }); + wallpaper.meta.title = data.title; wallpaper.meta.type = WallpaperType.Video;//todo 更细节的判断 wallpaper.coverUrl = coverUrl || ""; @@ -510,10 +520,11 @@ export function WallpaperDialog(props: WallpaperDialogProps) {
-

{importedFile.name}

{ importedFile.fileType === "video" && } + { + loadVideoError && + + } { importedFile.fileType === "img" &&