Skip to content

Commit ed4a076

Browse files
committed
Make Electron compatible
1 parent c88fe91 commit ed4a076

7 files changed

Lines changed: 56 additions & 42 deletions

File tree

index.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8" />
5-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>LBRY Web</title>
8-
</head>
9-
<body>
10-
<div id="root"></div>
11-
<script type="module" src="/src/main.tsx"></script>
12-
</body>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta content="default-src 'self'; script-src 'self'; connect-src *; img-src *; style-src * 'unsafe-inline';" http-equiv="Content-Security-Policy" />
7+
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
8+
<script type="module" src="/src/main.tsx"></script>
9+
<title>LBRY Web</title>
10+
</head>
11+
<body>
12+
<div id="root"></div>
13+
</body>
1314
</html>

package-lock.json

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

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
"preview": "vite preview",
1010
"test": "eslint"
1111
},
12-
"main": "index.html",
1312
"dependencies": {
1413
"react": "^19.2.0",
1514
"react-dom": "^19.2.0",
16-
"react-router-dom": "^7.9.5"
15+
"react-router": "^7.9.6"
1716
},
1817
"devDependencies": {
1918
"@eslint/js": "^9.39.1",

src/App.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import LBRY from "./LBRY";
22
import './App.css';
3+
import {Link} from "react-router";
34

4-
function App() {
5-
const notTags = ["porn","porno","nsfw","mature","xxx","sex","creampie","blowjob","handjob","vagina","boobs","big boobs","big dick","pussy","cumshot","anal","hard fucking","ass","fuck","hentai"];
5+
const notTags = ["porn","porno","nsfw","mature","xxx","sex","creampie","blowjob","handjob","vagina","boobs","big boobs","big dick","pussy","cumshot","anal","hard fucking","ass","fuck","hentai"];
66

7+
function App() {
78
LBRY.rpc('claim_search',{"page_size":4,"claim_type":["stream","repost","channel"],"no_totals":true,"any_tags":[],"not_tags":notTags,"channel_ids":["80d2590ad04e36fb1d077a9b9e3a8bba76defdf8","b58dfaeab6c70754d792cdd9b56ff59b90aea334"],"not_channel_ids":[],"order_by":["release_time"],"has_source":true,"release_time":">1731193200","include_purchase_receipt":true}).then(json => {
89
json.result.items.forEach((item: object): void => {
910
document.getElementById('row-1').innerHTML += '<div style="border:1px solid red;display:inline-block;max-width:200px;"><img alt="Thumbnail" src="'+(item.value?.thumbnail?.url || item.reposted_claim?.value?.thumbnail?.url)+'" style="height:100px;"><br>'+(item.value?.title || item.reposted_claim?.value?.title)+'</div>';
@@ -27,13 +28,25 @@ function App() {
2728

2829
return (
2930
<>
31+
<div>
32+
<a href="/">SLASH</a>
33+
|
34+
<a href="/about">SLASH ABOUT</a>
35+
</div>
36+
<hr/>
37+
<div>
38+
<Link to="/">SLASH 2</Link>
39+
|
40+
<Link to="/about">SLASH ABOUT 2</Link>
41+
</div>
42+
<hr/>
3043
<div id="row-1"></div>
3144
<hr/>
3245
<div id="row-2"></div>
3346
<hr/>
3447
<div id="row-3"></div>
3548
</>
36-
)
49+
);
3750
}
3851

39-
export default App
52+
export default App;

src/AppRouter.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {JSX} from "react";
2+
import {BrowserRouter, MemoryRouter} from "react-router";
3+
4+
const isElectron: boolean = false; // TODO Add detection
5+
6+
function AppRouter({ children }): JSX.Element{
7+
if(isElectron){
8+
return <MemoryRouter>{children}</MemoryRouter>;
9+
}
10+
return <BrowserRouter>{children}</BrowserRouter>;
11+
}
12+
13+
export default AppRouter;

src/main.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
import {StrictMode} from 'react';
22
import {createRoot, Root} from 'react-dom/client';
3-
import {BrowserRouter, Route, Routes} from 'react-router-dom';
3+
import {Route, Routes} from 'react-router';
44

55
import App from './App';
6+
import AppRouter from './AppRouter';
67
import NotFound from './NotFound';
78
import './index.css';
89

910
const root: Root = createRoot(document.getElementById('root'));
1011

1112
root.render(
1213
<StrictMode>
13-
<BrowserRouter>
14+
<header>LBRY Web</header>
15+
<AppRouter>
1416
<Routes>
15-
<Route path="/" element={<App/>}/>
17+
<Route index path="/" element={<App/>}/>
18+
<Route index path="/about" element={<App/>}/>
1619
<Route path="*" element={<NotFound/>}/>
1720
</Routes>
18-
</BrowserRouter>
19-
</StrictMode>,
21+
</AppRouter>
22+
</StrictMode>
2023
);

vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
33

44
export default defineConfig({
5+
base: './',
56
plugins: [react()],
67
});

0 commit comments

Comments
 (0)