mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Use custom protocol handler instead of base: './'
This is a much cleaner solution that eliminates the need for:
- Changing base: './' in vite.config.ts
- Importing assets in components
- Any workarounds for absolute paths
How it works:
- Register app:// protocol in Electron main process
- Maps app://path/to/file to dist/path/to/file
- Allows absolute paths (/) to work naturally in Electron
- No changes needed to source code or build config
Benefits:
- vite.config.ts stays clean (no base: './' hack)
- Components use normal paths: src="/shakespeare.svg"
- Works in both browser (https://) and Electron (app://)
- This is the standard Electron approach for serving local files
Reverted:
- vite.config.ts: Removed base: './'
- ShakespeareLogo: Back to src="/shakespeare.svg"
- AppShowcaseCard: Back to src="/badge.svg"
Updated:
- electron/main.js: Added protocol.registerFileProtocol('app', ...)
- electron/main.js: Changed loadURL to app://index.html
This commit is contained in:
4 files changed
+28
-10
No files matched your search
@@ -2,7 +2,6 @@ import React, { useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import badgeSvg from '/badge.svg';
|
||||
import {
|
||||
ExternalLink,
|
||||
Edit,
|
||||
@@ -568,7 +567,7 @@ export function AppShowcaseCard({ app, onEdit, showModerationControls, hideAppro
|
||||
className="flex-1"
|
||||
>
|
||||
<img
|
||||
src={badgeSvg}
|
||||
src="/badge.svg"
|
||||
alt="Edit with Shakespeare"
|
||||
className="h-6 hover:opacity-80 transition-opacity"
|
||||
/>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import shakespeareLogo from '/shakespeare.svg';
|
||||
|
||||
export interface ShakespeareLogoProps {
|
||||
className?: string;
|
||||
}
|
||||
@@ -7,7 +5,7 @@ export interface ShakespeareLogoProps {
|
||||
export function ShakespeareLogo({ className }: ShakespeareLogoProps) {
|
||||
return (
|
||||
<img
|
||||
src={shakespeareLogo}
|
||||
src="/shakespeare.svg"
|
||||
alt="Shakespeare"
|
||||
className={className}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user