Various fixes on Webview2
This commit is contained in:
@@ -13,7 +13,11 @@
|
||||
"copy-pdfjs-fonts": "dotenv -- cross-var cpx \"%PDFJS_FONTS_PATH%/{cmaps,standard_fonts}/*\" ./public/vendor/pdfjs",
|
||||
"copy-pdfjs-css": "dotenv -- cross-var cpx \"%PDFJS_STYLE_PATH%/{annotation_layer_builder,text_layer_builder}.css\" ./public/vendor/pdfjs",
|
||||
"copy-pdfjs": "pnpm copy-pdfjs-js && pnpm copy-pdfjs-fonts && pnpm copy-pdfjs-css",
|
||||
"setup-pdfjs": "pnpm prepare-public-vendor && pnpm copy-pdfjs"
|
||||
"setup-pdfjs": "pnpm prepare-public-vendor && pnpm copy-pdfjs",
|
||||
"build-win-x64": "tauri build --target i686-pc-windows-msvc --bundles nsis",
|
||||
"build-win-arm64": "tauri build --target aarch64-pc-windows-msvc --bundles nsis",
|
||||
"build-linux-x64": "tauri build --target x86_64-unknown-linux-gnu --bundles appimage",
|
||||
"build-macos-universial": "tauri build -t universal-apple-darwin --bundles dmg"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "2.1.1",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "Readest",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.2",
|
||||
"identifier": "com.bilingify.digest",
|
||||
"build": {
|
||||
"frontendDist": "../out",
|
||||
|
||||
@@ -56,7 +56,7 @@ const LibraryHeader: React.FC<LibraryHeaderProps> = ({
|
||||
isTrafficLightVisible ? 'pl-16' : 'pl-2',
|
||||
)}
|
||||
>
|
||||
<div className='flex items-center justify-between'>
|
||||
<div className='flex items-center justify-between space-x-6'>
|
||||
<div className='sm:w relative flex w-full items-center pl-4'>
|
||||
<span className='absolute left-8 text-gray-500'>
|
||||
<FaSearch className='h-4 w-4' />
|
||||
|
||||
@@ -77,13 +77,13 @@ const LibraryPage = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='rounded-window min-h-screen select-none bg-gray-100'>
|
||||
<div className='rounded-window min-h-screen select-none overflow-hidden bg-gray-100'>
|
||||
<LibraryHeader
|
||||
isSelectMode={isSelectMode}
|
||||
onImportBooks={handleImportBooks}
|
||||
onToggleSelectMode={handleToggleSelectMode}
|
||||
/>
|
||||
<div className='flex-grow pt-12'>
|
||||
<div className='flex-grow'>
|
||||
{loading || libraryBooks.length > 0 ? (
|
||||
<div className='hero-content h-full overflow-y-auto px-2 py-4'>
|
||||
<Spinner loading={loading} />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import clsx from 'clsx';
|
||||
import React from 'react';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
|
||||
import { BookDoc } from '@/libs/document';
|
||||
import TOCView from './TOCView';
|
||||
@@ -11,30 +11,59 @@ const SidebarContent: React.FC<{
|
||||
bookDoc: BookDoc;
|
||||
sideBarBookKey: string;
|
||||
onTabChange: (tab: string) => void;
|
||||
}> = ({ activeTab, bookDoc, sideBarBookKey, onTabChange }) => (
|
||||
<>
|
||||
<div
|
||||
className={clsx(
|
||||
'sidebar-content flex min-h-0 flex-grow flex-col',
|
||||
'font-sans text-sm font-light shadow-inner',
|
||||
)}
|
||||
>
|
||||
<div className='overflow-y-auto'>
|
||||
{activeTab === 'toc' && bookDoc.toc && (
|
||||
<TOCView toc={bookDoc.toc} bookKey={sideBarBookKey} />
|
||||
)}
|
||||
{activeTab === 'annotations' && (
|
||||
<BooknoteView type='annotation' toc={bookDoc.toc} bookKey={sideBarBookKey} />
|
||||
)}
|
||||
{activeTab === 'bookmarks' && (
|
||||
<BooknoteView type='bookmark' toc={bookDoc.toc} bookKey={sideBarBookKey} />
|
||||
}> = ({ activeTab, bookDoc, sideBarBookKey, onTabChange }) => {
|
||||
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const container = scrollContainerRef.current;
|
||||
if (!container) return;
|
||||
|
||||
let scrollTimeout: ReturnType<typeof setTimeout>;
|
||||
const showScrollbar = () => {
|
||||
container.classList.remove('hidden-scrollbar');
|
||||
};
|
||||
const hideScrollbar = () => {
|
||||
container.classList.add('hidden-scrollbar');
|
||||
};
|
||||
|
||||
hideScrollbar();
|
||||
const handleScroll = () => {
|
||||
showScrollbar();
|
||||
clearTimeout(scrollTimeout);
|
||||
scrollTimeout = setTimeout(hideScrollbar, 2000);
|
||||
};
|
||||
container.addEventListener('scroll', handleScroll);
|
||||
return () => {
|
||||
container.removeEventListener('scroll', handleScroll);
|
||||
clearTimeout(scrollTimeout);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={clsx(
|
||||
'sidebar-content flex min-h-0 flex-grow flex-col',
|
||||
'font-sans text-sm font-normal shadow-inner',
|
||||
)}
|
||||
>
|
||||
<div ref={scrollContainerRef} className='scroll-container overflow-y-auto'>
|
||||
{activeTab === 'toc' && bookDoc.toc && (
|
||||
<TOCView toc={bookDoc.toc} bookKey={sideBarBookKey} />
|
||||
)}
|
||||
{activeTab === 'annotations' && (
|
||||
<BooknoteView type='annotation' toc={bookDoc.toc} bookKey={sideBarBookKey} />
|
||||
)}
|
||||
{activeTab === 'bookmarks' && (
|
||||
<BooknoteView type='bookmark' toc={bookDoc.toc} bookKey={sideBarBookKey} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex-shrink-0'>
|
||||
<TabNavigation activeTab={activeTab} onTabChange={onTabChange} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
<div className='flex-shrink-0'>
|
||||
<TabNavigation activeTab={activeTab} onTabChange={onTabChange} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default SidebarContent;
|
||||
|
||||
@@ -31,7 +31,7 @@ const SearchBar: React.FC<SearchBarProps> = ({
|
||||
|
||||
const queuedSearchTerm = useRef('');
|
||||
const isSearchPending = useRef(false);
|
||||
const searchTimeout = useRef<NodeJS.Timeout | null>(null);
|
||||
const searchTimeout = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
handleSearchTermChange(searchTerm);
|
||||
|
||||
@@ -27,11 +27,7 @@ const WindowButtons: React.FC<WindowButtonsProps> = ({
|
||||
const handleMouseDown = async (e: MouseEvent) => {
|
||||
const target = e.target as HTMLElement;
|
||||
|
||||
if (
|
||||
target.closest('#titlebar-minimize') ||
|
||||
target.closest('#titlebar-maximize') ||
|
||||
target.closest('#titlebar-close')
|
||||
) {
|
||||
if (target !== e.currentTarget) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,7 +76,7 @@ const WindowButtons: React.FC<WindowButtonsProps> = ({
|
||||
<div
|
||||
ref={parentRef}
|
||||
className={clsx(
|
||||
'window-buttons flex h-8 items-center justify-end space-x-2 pl-6',
|
||||
'window-buttons flex h-8 items-center justify-end space-x-2',
|
||||
showClose || showMaximize || showMinimize ? 'visible' : 'hidden',
|
||||
className,
|
||||
)}
|
||||
|
||||
@@ -272,7 +272,9 @@ export const useReaderStore = create<ReaderStore>((set, get) => ({
|
||||
console.log('Loading book', key);
|
||||
const { book: loadedBookDoc } = await new DocumentLoader(file).open();
|
||||
const bookDoc = loadedBookDoc as BookDoc;
|
||||
updateTocID(bookDoc.toc);
|
||||
if (bookDoc.toc) {
|
||||
updateTocID(bookDoc.toc);
|
||||
}
|
||||
set((state) => ({
|
||||
booksData: {
|
||||
...state.booksData,
|
||||
|
||||
@@ -175,3 +175,12 @@ foliate-view {
|
||||
max-height: 48px;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.scroll-container {
|
||||
overflow-y: scroll;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
.scroll-container.hidden-scrollbar {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,7 @@ export const findParentPath = (toc: TOCItem[], href: string): TOCItem[] => {
|
||||
|
||||
export const updateTocID = (items: TOCItem[], index = 0): number => {
|
||||
items.forEach((item) => {
|
||||
if (item.id === undefined) {
|
||||
item.id = index++;
|
||||
}
|
||||
item.id ??= index++;
|
||||
if (item.subitems) {
|
||||
index = updateTocID(item.subitems, index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user