refactor: unified path resolver on all platforms (#1730)

This commit is contained in:
Huang Xin
2025-08-01 22:51:17 +08:00
committed by GitHub
parent 7e559c5b90
commit 288abc678c
10 changed files with 87 additions and 68 deletions
@@ -143,6 +143,7 @@ const BookCover: React.FC<BookCoverProps> = memo<BookCoverProps>(
return (
prevProps.book.coverImageUrl === nextProps.book.coverImageUrl &&
prevProps.book.metadata?.coverImageUrl === nextProps.book.metadata?.coverImageUrl &&
prevProps.book.updatedAt === nextProps.book.updatedAt &&
prevProps.mode === nextProps.mode &&
prevProps.coverFit === nextProps.coverFit &&
prevProps.isPreview === nextProps.isPreview &&
@@ -106,6 +106,7 @@ export const UpdaterContent = ({
}
};
const checkAndroidUpdate = async () => {
if (!appService) return;
const fetch = isTauriAppPlatform() ? tauriFetch : window.fetch;
const response = await fetch(READEST_UPDATER_FILE);
const data = await response.json();
@@ -114,7 +115,7 @@ export const UpdaterContent = ({
const platformKey = OS_ARCH === 'aarch64' ? 'android-arm64' : 'android-universal';
const arch = OS_ARCH === 'aarch64' ? 'arm64' : 'universal';
const downloadUrl = data.platforms[platformKey]?.url as string;
const cachePrefix = appService?.fs.getPrefix('Cache');
const cachePrefix = await appService.fs.getPrefix('Cache');
const apkFilePath = `${cachePrefix}/Readest_${data.version}_${arch}.apk`;
setUpdate({
currentVersion,
@@ -180,8 +180,8 @@ const BookDetailEdit: React.FC<BookDetailEditProps> = ({
files = (await selectImageFileTauri()) as string[];
if (appService && files.length > 0) {
metadata.coverImageFile = files[0]!;
const tempName = 'cover-temp.png';
const cachePrefix = appService.fs.getPrefix('Cache');
const tempName = `cover-${Date.now()}.png`;
const cachePrefix = await appService.fs.getPrefix('Cache');
await appService.fs.copyFile(files[0]!, tempName, 'Cache');
metadata.coverImageUrl = await appService.fs.getURL(`${cachePrefix}/${tempName}`);
setNewCoverImageUrl(metadata.coverImageUrl!);
@@ -224,7 +224,7 @@ const BookDetailEdit: React.FC<BookDetailEditProps> = ({
'border border-gray-300 bg-white hover:bg-gray-50',
'disabled:cursor-not-allowed disabled:opacity-50',
'text-sm sm:text-xs',
isCoverLocked && '!text-base-content !bg-base-200',
isCoverLocked ? '!text-base-content !bg-base-200' : '!text-gray-500',
)}
title={_('Change cover image')}
>