mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-07-27 15:45:21 +00:00
Merge fixes
This commit is contained in:
parent
a02d325ca2
commit
6413099182
@ -1,9 +1,10 @@
|
|||||||
import React from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { RainbowThemeProvider } from './components/shared/RainbowThemeProvider';
|
import { RainbowThemeProvider } from './components/shared/RainbowThemeProvider';
|
||||||
import { FileContextProvider } from './contexts/FileContext';
|
import { FileContextProvider } from './contexts/FileContext';
|
||||||
import HomePage from './pages/HomePage';
|
import HomePage from './pages/HomePage';
|
||||||
import { useOpenedFile } from './hooks/useOpenedFile';
|
import { useOpenedFile } from './hooks/useOpenedFile';
|
||||||
import { useBackendInitializer } from './hooks/useBackendInitializer';
|
import { useBackendInitializer } from './hooks/useBackendInitializer';
|
||||||
|
import { fileOpenService } from './services/fileOpenService';
|
||||||
|
|
||||||
// Import global styles
|
// Import global styles
|
||||||
import './styles/tailwind.css';
|
import './styles/tailwind.css';
|
||||||
@ -12,16 +13,42 @@ import './index.css';
|
|||||||
import { BackendHealthIndicator } from './components/BackendHealthIndicator';
|
import { BackendHealthIndicator } from './components/BackendHealthIndicator';
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const { openedFilePath, loading: fileLoading } = useOpenedFile();
|
|
||||||
|
|
||||||
// Initialize backend on app startup
|
// Initialize backend on app startup
|
||||||
useBackendInitializer();
|
useBackendInitializer();
|
||||||
|
|
||||||
|
// Handle file opened with app (Tauri mode)
|
||||||
|
const { openedFilePath, loading: openedFileLoading } = useOpenedFile();
|
||||||
|
const [openedFile, setOpenedFile] = useState<File | null>(null);
|
||||||
|
|
||||||
|
// Load opened file once when path is available
|
||||||
|
useEffect(() => {
|
||||||
|
if (openedFilePath && !openedFileLoading) {
|
||||||
|
const loadOpenedFile = async () => {
|
||||||
|
try {
|
||||||
|
const fileData = await fileOpenService.readFileAsArrayBuffer(openedFilePath);
|
||||||
|
if (fileData) {
|
||||||
|
// Create a File object from the ArrayBuffer
|
||||||
|
const file = new File([fileData.arrayBuffer], fileData.fileName, {
|
||||||
|
type: 'application/pdf'
|
||||||
|
});
|
||||||
|
setOpenedFile(file);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load opened file:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
loadOpenedFile();
|
||||||
|
}
|
||||||
|
}, [openedFilePath, openedFileLoading]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BackendHealthIndicator className="absolute top-3 left-3 z-10" />
|
<BackendHealthIndicator className="absolute top-3 left-3 z-10" />
|
||||||
<RainbowThemeProvider>
|
<RainbowThemeProvider>
|
||||||
<FileContextProvider enableUrlSync={true} enablePersistence={true}>
|
<FileContextProvider enableUrlSync={true} enablePersistence={true}>
|
||||||
<HomePage />
|
<HomePage openedFile={openedFile} />
|
||||||
</FileContextProvider>
|
</FileContextProvider>
|
||||||
</RainbowThemeProvider>
|
</RainbowThemeProvider>
|
||||||
</>
|
</>
|
||||||
|
@ -6,7 +6,7 @@ import ZoomInMapIcon from "@mui/icons-material/ZoomInMap";
|
|||||||
import SplitPdfPanel from "../tools/Split";
|
import SplitPdfPanel from "../tools/Split";
|
||||||
import CompressPdfPanel from "../tools/Compress";
|
import CompressPdfPanel from "../tools/Compress";
|
||||||
import MergePdfPanel from "../tools/Merge";
|
import MergePdfPanel from "../tools/Merge";
|
||||||
import { useMultipleEndpointsEnabled } from "./useEndpointConfig";
|
import { useMultipleEndpointsEnabledWithHealthCheck } from './useEndpointConfig';
|
||||||
|
|
||||||
type ToolRegistryEntry = {
|
type ToolRegistryEntry = {
|
||||||
icon: React.ReactNode;
|
icon: React.ReactNode;
|
||||||
@ -40,7 +40,8 @@ export const useToolManagement = () => {
|
|||||||
const [toolSelectedFileIds, setToolSelectedFileIds] = useState<string[]>([]);
|
const [toolSelectedFileIds, setToolSelectedFileIds] = useState<string[]>([]);
|
||||||
|
|
||||||
const allEndpoints = Array.from(new Set(Object.values(toolEndpoints).flat()));
|
const allEndpoints = Array.from(new Set(Object.values(toolEndpoints).flat()));
|
||||||
const { endpointStatus, loading: endpointsLoading } = useMultipleEndpointsEnabled(allEndpoints);
|
const { endpointStatus, loading: endpointsLoading } = useMultipleEndpointsEnabledWithHealthCheck(allEndpoints);
|
||||||
|
|
||||||
|
|
||||||
const isToolAvailable = useCallback((toolKey: string): boolean => {
|
const isToolAvailable = useCallback((toolKey: string): boolean => {
|
||||||
if (endpointsLoading) return true;
|
if (endpointsLoading) return true;
|
||||||
@ -91,6 +92,5 @@ export const useToolManagement = () => {
|
|||||||
selectTool,
|
selectTool,
|
||||||
clearToolSelection,
|
clearToolSelection,
|
||||||
setToolSelectedFileIds,
|
setToolSelectedFileIds,
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useCallback} from "react";
|
import React, { useState, useCallback, useEffect} from "react";
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useFileContext } from "../contexts/FileContext";
|
import { useFileContext } from "../contexts/FileContext";
|
||||||
import { useToolManagement } from "../hooks/useToolManagement";
|
import { useToolManagement } from "../hooks/useToolManagement";
|
||||||
@ -15,9 +15,12 @@ import Viewer from "../components/viewer/Viewer";
|
|||||||
import FileUploadSelector from "../components/shared/FileUploadSelector";
|
import FileUploadSelector from "../components/shared/FileUploadSelector";
|
||||||
import ToolRenderer from "../components/tools/ToolRenderer";
|
import ToolRenderer from "../components/tools/ToolRenderer";
|
||||||
import QuickAccessBar from "../components/shared/QuickAccessBar";
|
import QuickAccessBar from "../components/shared/QuickAccessBar";
|
||||||
import { useMultipleEndpointsEnabledWithHealthCheck } from "../hooks/useEndpointConfig";
|
|
||||||
|
|
||||||
export default function HomePage() {
|
interface HomePageProps {
|
||||||
|
openedFile?: File | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function HomePage({ openedFile }: HomePageProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { isRainbowMode } = useRainbowThemeContext();
|
const { isRainbowMode } = useRainbowThemeContext();
|
||||||
|
|
||||||
@ -25,6 +28,7 @@ export default function HomePage() {
|
|||||||
const fileContext = useFileContext();
|
const fileContext = useFileContext();
|
||||||
const { activeFiles, currentView, currentMode, setCurrentView, addFiles } = fileContext;
|
const { activeFiles, currentView, currentMode, setCurrentView, addFiles } = fileContext;
|
||||||
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
selectedToolKey,
|
selectedToolKey,
|
||||||
selectedTool,
|
selectedTool,
|
||||||
@ -77,6 +81,26 @@ export default function HomePage() {
|
|||||||
}
|
}
|
||||||
}, [activeFiles, addFiles]);
|
}, [activeFiles, addFiles]);
|
||||||
|
|
||||||
|
// Handle file opened with app (Tauri mode)
|
||||||
|
useEffect(() => {
|
||||||
|
if (openedFile) {
|
||||||
|
const loadOpenedFile = async () => {
|
||||||
|
try {
|
||||||
|
// Add to active files if not already present
|
||||||
|
await addToActiveFiles(openedFile);
|
||||||
|
|
||||||
|
// Switch to viewer mode to show the opened file
|
||||||
|
setCurrentView('viewer');
|
||||||
|
setReaderMode(true);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load opened file:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
loadOpenedFile();
|
||||||
|
}
|
||||||
|
}, [openedFile]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -27,9 +27,9 @@ if errorlevel 1 (
|
|||||||
)
|
)
|
||||||
|
|
||||||
REM Find the built JAR(s)
|
REM Find the built JAR(s)
|
||||||
echo ▶ Listing all built JAR files in stirling-pdf\build\libs:
|
echo ▶ Listing all built JAR files in app\core\build\libs:
|
||||||
dir /b stirling-pdf\build\libs\Stirling-PDF-*.jar
|
dir /b app\core\build\libs\Stirling-PDF-*.jar
|
||||||
for %%f in (stirling-pdf\build\libs\Stirling-PDF-*.jar) do set STIRLING_JAR=%%f
|
for %%f in (app\core\build\libs\Stirling-PDF-*.jar) do set STIRLING_JAR=%%f
|
||||||
if not exist "%STIRLING_JAR%" (
|
if not exist "%STIRLING_JAR%" (
|
||||||
echo ❌ No Stirling-PDF JAR found in build/libs/
|
echo ❌ No Stirling-PDF JAR found in build/libs/
|
||||||
exit /b 1
|
exit /b 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user