Skip to content

Commit 030c529

Browse files
committed
chore: Standardize package name to twice-pdf
1 parent 4464eb6 commit 030c529

9 files changed

Lines changed: 89 additions & 27 deletions

File tree

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ jobs:
4444
4545
| File | Description |
4646
|------|-------------|
47-
| `Twice-PDF.exe` | **Portable** - Just download and run |
48-
| `Twice PDF_*_x64-setup.exe` | **Installer** - For older Windows without WebView2 |
47+
| `twice-pdf.exe` | **Portable** - Just download and run |
48+
| `twice-pdf_*_x64-setup.exe` | **Installer** - For older Windows without WebView2 |
4949
5050
See [CHANGELOG.md](https://github.com/PlusKits/Twice-PDF/blob/main/CHANGELOG.md) for details.
5151
releaseDraft: true
@@ -56,6 +56,6 @@ jobs:
5656
with:
5757
tag_name: ${{ github.ref_name }}
5858
draft: true
59-
files: app/src-tauri/target/release/Twice PDF.exe
59+
files: app/src-tauri/target/release/twice-pdf.exe
6060
env:
6161
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

app/package-lock.json

Lines changed: 15 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@eslint/js": "^9.39.1",
2727
"@tauri-apps/api": "^2.9.1",
2828
"@tauri-apps/cli": "^2.9.6",
29+
"@tauri-apps/plugin-dialog": "^2.6.0",
2930
"@types/react": "^19.2.5",
3031
"@types/react-dom": "^19.2.3",
3132
"@vitejs/plugin-react": "^5.1.1",
@@ -39,4 +40,4 @@
3940
"tailwindcss": "^3.4.17",
4041
"vite": "^7.2.4"
4142
}
42-
}
43+
}

app/src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ tauri = { version = "2.9.5", features = ["devtools"] }
2525
tauri-plugin-log = "2"
2626
chrono = "0.4"
2727
tauri-plugin-opener = "2.5.3"
28+
tauri-plugin-dialog = "2"

app/src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub fn run() {
6363

6464
tauri::Builder::default()
6565
.plugin(tauri_plugin_opener::init())
66+
.plugin(tauri_plugin_dialog::init())
6667
.setup(|app| {
6768
// Debug logging (dev only)
6869
if cfg!(debug_assertions) {

app/src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
3-
"productName": "Twice PDF",
3+
"productName": "twice-pdf",
44
"version": "1.1.0",
55
"identifier": "com.pluskits.twice-pdf",
66
"build": {

app/src/PDFViewer.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ const PDFViewer = forwardRef(({
162162
setAuthorName,
163163
onClose,
164164
onLoadFromUrl,
165+
onLoadFromPath, // Tauri: load from file path (native dialog)
165166
onFitToPage,
166167
isLoading = false,
167168
viewMode = 'single', // 'single' | 'continuous'
@@ -2398,6 +2399,7 @@ const PDFViewer = forwardRef(({
23982399
!pdf ? (
23992400
<UploadZone
24002401
onUpload={onUpload}
2402+
onLoadFromPath={onLoadFromPath}
24012403
onLoadFromUrl={onLoadFromUrl}
24022404
isLoading={isLoading}
24032405
isDragging={isDragging}

app/src/SideBySidePDF.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@ export default function SideBySidePDF() {
12051205
loadPDFFromURL(cleanUrl, 'left');
12061206
}
12071207
}}
1208+
onLoadFromPath={(path) => loadPdfFromPath(path, 'left')}
12081209
onFitToPage={() => handleFitToPageSync('left')}
12091210
isLoading={isUrlLoading.left}
12101211
exportSettings={exportSettings}
@@ -1265,6 +1266,7 @@ export default function SideBySidePDF() {
12651266
loadPDFFromURL(cleanUrl, 'right');
12661267
}
12671268
}}
1269+
onLoadFromPath={(path) => loadPdfFromPath(path, 'right')}
12681270
onFitToPage={() => handleFitToPageSync('right')}
12691271
isLoading={isUrlLoading.right}
12701272
// Scale Settings (passed but only Left side triggers settings menu changes usually, but good for consistency)

app/src/components/PDFViewer/UploadZone.jsx

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import { Upload, Loader2 } from 'lucide-react';
66
*
77
* Features:
88
* - File upload via click or drag-drop
9+
* - Uses native Tauri file dialog when available (provides full path for "Show in folder")
910
* - URL loading (remote or local bridge)
1011
* - Loading state indicator
1112
* - Respects environment flags for remote/local options
1213
*/
1314
const UploadZone = ({
1415
onUpload,
16+
onLoadFromPath, // New: callback for loading via file path (Tauri)
1517
onLoadFromUrl,
1618
isLoading = false,
1719
isDragging = false,
@@ -22,12 +24,36 @@ const UploadZone = ({
2224
// Check environment flags
2325
const allowRemote = import.meta.env.VITE_ENABLE_REMOTE_PDFS !== 'false';
2426
const allowLocal = import.meta.env.VITE_ENABLE_LOCAL_BRIDGE !== 'false';
27+
const isTauri = !!window.__TAURI__?.core?.invoke;
2528

2629
let placeholder = "";
2730
if (allowRemote && allowLocal) placeholder = "https://... or folder/file.pdf";
2831
else if (allowRemote) placeholder = "https://...";
2932
else if (allowLocal) placeholder = "folder/file.pdf";
3033

34+
// Handle upload click - use native dialog in Tauri for full path access
35+
const handleUploadClick = async () => {
36+
if (isLoading) return;
37+
38+
if (isTauri && onLoadFromPath) {
39+
try {
40+
const dialog = window.__TAURI__?.dialog;
41+
if (dialog?.open) {
42+
const selected = await dialog.open({
43+
filters: [{ name: 'PDF', extensions: ['pdf'] }],
44+
multiple: false,
45+
});
46+
if (selected) {
47+
// Tauri dialog returns the full path
48+
onLoadFromPath(selected);
49+
}
50+
}
51+
} catch (err) {
52+
console.error('Failed to open file dialog:', err);
53+
}
54+
}
55+
};
56+
3157
return (
3258
<div
3359
className={`flex-1 flex flex-col items-center justify-center transition-all ${isDragging ? 'bg-blue-50 border-4 border-dashed border-blue-400 rounded-lg m-4' : ''
@@ -36,25 +62,42 @@ const UploadZone = ({
3662
onDragLeave={onDragLeave}
3763
onDrop={onDrop}
3864
>
39-
{/* File upload */}
40-
<label
41-
className={`cursor-pointer flex flex-col items-center gap-3 p-8 border-2 border-dashed rounded-none transition-colors ${isLoading
42-
? 'border-gray-200 bg-gray-50 cursor-wait'
43-
: 'border-gray-400 hover:border-blue-500 hover:bg-blue-50'
44-
}`}
45-
>
46-
<Upload className={`w-12 h-12 ${isLoading ? 'text-gray-300' : 'text-gray-400'}`} />
47-
<span className={`font-medium ${isLoading ? 'text-gray-400' : 'text-gray-600'}`}>
48-
{isLoading ? 'Uploading PDF...' : 'Upload PDF'}
49-
</span>
50-
<input
51-
type="file"
52-
accept="application/pdf"
53-
onChange={onUpload}
54-
className="hidden"
65+
{/* File upload - Tauri uses onClick for native dialog, web uses input */}
66+
{isTauri ? (
67+
<button
68+
type="button"
69+
onClick={handleUploadClick}
5570
disabled={isLoading}
56-
/>
57-
</label>
71+
className={`cursor-pointer flex flex-col items-center gap-3 p-8 border-2 border-dashed rounded-none transition-colors ${isLoading
72+
? 'border-gray-200 bg-gray-50 cursor-wait'
73+
: 'border-gray-400 hover:border-blue-500 hover:bg-blue-50'
74+
}`}
75+
>
76+
<Upload className={`w-12 h-12 ${isLoading ? 'text-gray-300' : 'text-gray-400'}`} />
77+
<span className={`font-medium ${isLoading ? 'text-gray-400' : 'text-gray-600'}`}>
78+
{isLoading ? 'Uploading PDF...' : 'Upload PDF'}
79+
</span>
80+
</button>
81+
) : (
82+
<label
83+
className={`cursor-pointer flex flex-col items-center gap-3 p-8 border-2 border-dashed rounded-none transition-colors ${isLoading
84+
? 'border-gray-200 bg-gray-50 cursor-wait'
85+
: 'border-gray-400 hover:border-blue-500 hover:bg-blue-50'
86+
}`}
87+
>
88+
<Upload className={`w-12 h-12 ${isLoading ? 'text-gray-300' : 'text-gray-400'}`} />
89+
<span className={`font-medium ${isLoading ? 'text-gray-400' : 'text-gray-600'}`}>
90+
{isLoading ? 'Uploading PDF...' : 'Upload PDF'}
91+
</span>
92+
<input
93+
type="file"
94+
accept="application/pdf"
95+
onChange={onUpload}
96+
className="hidden"
97+
disabled={isLoading}
98+
/>
99+
</label>
100+
)}
58101

59102
{/* URL loading section */}
60103
{(allowRemote || allowLocal) && (
@@ -98,3 +141,4 @@ const UploadZone = ({
98141
};
99142

100143
export default UploadZone;
144+

0 commit comments

Comments
 (0)