mirror of
https://github.com/luminous-devs/lume.git
synced 2024-10-01 09:21:07 +00:00
feat: add desktop2
This commit is contained in:
parent
08fa7de01d
commit
a21da11a91
6
apps/desktop2/.gitignore
vendored
Normal file
6
apps/desktop2/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
node_modules
|
||||
|
||||
/.cache
|
||||
/build
|
||||
/public/build
|
||||
.env
|
37
apps/desktop2/README.md
Normal file
37
apps/desktop2/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
# templates/spa
|
||||
|
||||
This template leverages [Remix SPA Mode](https://remix.run/docs/en/main/future/spa-mode) to build your app as a Single-Page Application using [Client Data](https://remix.run/docs/en/main/guides/client-data) for all of you data loads and mutations.
|
||||
|
||||
⚠️ This is built on top of the Remix Vite template. Remix support for Vite is currently unstable and not recommended for production.
|
||||
|
||||
📖 See the [Remix Vite docs][remix-vite-docs] for details on supported features.
|
||||
|
||||
## Setup
|
||||
|
||||
```shellscript
|
||||
npx create-remix@latest --template remix-run/remix/templates/spa
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
You can develop your SPA app just like you would a normal Remix app, via:
|
||||
|
||||
```shellscript
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## Production
|
||||
|
||||
When you are ready yo build a production version of your app, `npm run build` will generate your assets and an `index.html` for the SPA.
|
||||
|
||||
```shellscript
|
||||
npm run build
|
||||
```
|
||||
|
||||
You can serve this from any server of your choosing, for a simple example, you could use [http-server](https://www.npmjs.com/package/http-server):
|
||||
|
||||
```shellscript
|
||||
npx http-server build/client/
|
||||
```
|
||||
|
||||
[remix-vite-docs]: https://remix.run/docs/en/main/future/vite
|
12
apps/desktop2/app/entry.client.tsx
Normal file
12
apps/desktop2/app/entry.client.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import { RemixBrowser } from "@remix-run/react";
|
||||
import { startTransition, StrictMode } from "react";
|
||||
import { hydrateRoot } from "react-dom/client";
|
||||
|
||||
startTransition(() => {
|
||||
hydrateRoot(
|
||||
document,
|
||||
<StrictMode>
|
||||
<RemixBrowser />
|
||||
</StrictMode>
|
||||
);
|
||||
});
|
21
apps/desktop2/app/entry.server.tsx
Normal file
21
apps/desktop2/app/entry.server.tsx
Normal file
@ -0,0 +1,21 @@
|
||||
import type { EntryContext } from "@remix-run/node";
|
||||
import { RemixServer } from "@remix-run/react";
|
||||
import { renderToString } from "react-dom/server";
|
||||
|
||||
export default function handleRequest(
|
||||
request: Request,
|
||||
responseStatusCode: number,
|
||||
responseHeaders: Headers,
|
||||
remixContext: EntryContext
|
||||
) {
|
||||
let html = renderToString(
|
||||
<RemixServer context={remixContext} url={request.url} />
|
||||
);
|
||||
if (html.startsWith("<html")) {
|
||||
html = "<!DOCTYPE html>\n" + html;
|
||||
}
|
||||
return new Response(html, {
|
||||
headers: { "Content-Type": "text/html" },
|
||||
status: responseStatusCode,
|
||||
});
|
||||
}
|
42
apps/desktop2/app/root.tsx
Normal file
42
apps/desktop2/app/root.tsx
Normal file
@ -0,0 +1,42 @@
|
||||
import {
|
||||
Links,
|
||||
Meta,
|
||||
Outlet,
|
||||
Scripts,
|
||||
ScrollRestoration,
|
||||
} from "@remix-run/react";
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charSet="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<Meta />
|
||||
<Links />
|
||||
</head>
|
||||
<body>
|
||||
<Outlet />
|
||||
<ScrollRestoration />
|
||||
<Scripts />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
export function HydrateFallback() {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charSet="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<Meta />
|
||||
<Links />
|
||||
</head>
|
||||
<body>
|
||||
<p>Loading...</p>
|
||||
<Scripts />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
32
apps/desktop2/app/routes/_index.tsx
Normal file
32
apps/desktop2/app/routes/_index.tsx
Normal file
@ -0,0 +1,32 @@
|
||||
import type { MetaFunction } from "@remix-run/node";
|
||||
|
||||
export const meta: MetaFunction = () => {
|
||||
return [
|
||||
{ title: "New Remix SPA" },
|
||||
{ name: "description", content: "Welcome to Remix (SPA Mode)!" },
|
||||
];
|
||||
};
|
||||
|
||||
export default function Index() {
|
||||
return (
|
||||
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.8" }}>
|
||||
<h1>Welcome to Remix (SPA Mode)</h1>
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
target="_blank"
|
||||
href="https://remix.run/future/spa-mode"
|
||||
rel="noreferrer"
|
||||
>
|
||||
SPA Mode Guide
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a target="_blank" href="https://remix.run/docs" rel="noreferrer">
|
||||
Remix Docs
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
2
apps/desktop2/env.d.ts
vendored
Normal file
2
apps/desktop2/env.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/// <reference types="@remix-run/node" />
|
||||
/// <reference types="vite/client" />
|
30
apps/desktop2/package.json
Normal file
30
apps/desktop2/package.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "@lume/desktop2",
|
||||
"private": true,
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "remix vite:build",
|
||||
"dev": "remix vite:dev",
|
||||
"start": "http-server build/client/",
|
||||
"typecheck": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@remix-run/node": "^2.6.0",
|
||||
"@remix-run/react": "^2.6.0",
|
||||
"http-server": "^14.1.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@remix-run/dev": "^2.6.0",
|
||||
"@types/react": "^18.2.20",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"typescript": "^5.1.6",
|
||||
"vite": "^5.0.0",
|
||||
"vite-tsconfig-paths": "^4.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
}
|
BIN
apps/desktop2/public/favicon.ico
Normal file
BIN
apps/desktop2/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
24
apps/desktop2/tsconfig.json
Normal file
24
apps/desktop2/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"include": ["env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"compilerOptions": {
|
||||
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"jsx": "react-jsx",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"resolveJsonModule": true,
|
||||
"target": "ES2022",
|
||||
"strict": true,
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/*": ["./app/*"]
|
||||
},
|
||||
|
||||
// Remix takes care of building everything in `remix build`.
|
||||
"noEmit": true
|
||||
}
|
||||
}
|
10
apps/desktop2/vite.config.ts
Normal file
10
apps/desktop2/vite.config.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { unstable_vitePlugin as remix } from "@remix-run/dev";
|
||||
import { defineConfig } from "vite";
|
||||
import tsconfigPaths from "vite-tsconfig-paths";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
remix({ unstable_ssr: false, buildDirectory: "../../dist" }),
|
||||
tsconfigPaths(),
|
||||
],
|
||||
});
|
@ -3,8 +3,10 @@
|
||||
"private": true,
|
||||
"version": "3.0.1",
|
||||
"scripts": {
|
||||
"build": "turbo build",
|
||||
"dev": "turbo dev",
|
||||
"build": "turbo run build",
|
||||
"dev": "turbo run dev",
|
||||
"web:dev": "turbo run dev --filter web",
|
||||
"desktop:dev": "turbo run dev --filter desktop2",
|
||||
"tauri": "tauri"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -29,7 +31,6 @@
|
||||
"@tauri-apps/plugin-shell": "^2.0.0-beta.0",
|
||||
"@tauri-apps/plugin-sql": "^2.0.0-beta.0",
|
||||
"@tauri-apps/plugin-updater": "^2.0.0-beta.0",
|
||||
"@tauri-apps/plugin-upload": "^2.0.0-beta.0",
|
||||
"million": "^3.0.2"
|
||||
"@tauri-apps/plugin-upload": "^2.0.0-beta.0"
|
||||
}
|
||||
}
|
||||
|
3059
pnpm-lock.yaml
3059
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,18 @@ fn main() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
let handle = app.handle().clone();
|
||||
let config_dir = app.path().app_config_dir().unwrap();
|
||||
let config_dir = handle.path().app_config_dir().unwrap();
|
||||
|
||||
tauri::async_runtime::spawn(async move {
|
||||
// Create database connection
|
||||
let nostr_db = SQLiteDatabase::open(config_dir.join("nostr.db"))
|
||||
.await
|
||||
.expect("Open database failed.");
|
||||
|
||||
// Create nostr connection
|
||||
let client = ClientBuilder::default().database(nostr_db).build();
|
||||
|
||||
// create app database connection
|
||||
let db = DATABASE_BUILDER
|
||||
.create(config_dir.join("app.db"))
|
||||
.expect("failed to create app database");
|
||||
@ -37,15 +48,6 @@ fn main() {
|
||||
rw.migrate::<Account>().expect("failed to migrate Account");
|
||||
rw.commit().expect("failed to commit migration");
|
||||
|
||||
tauri::async_runtime::spawn(async move {
|
||||
// Create database connection
|
||||
let nostr_db = SQLiteDatabase::open(config_dir.join("nostr.db"))
|
||||
.await
|
||||
.expect("Open database failed.");
|
||||
|
||||
// Create nostr connection
|
||||
let client = ClientBuilder::default().database(nostr_db).build();
|
||||
|
||||
// get stored account
|
||||
let r = db.r_transaction().expect("failed to create ro transaction");
|
||||
let accounts: Vec<Account> = r
|
||||
|
@ -5,8 +5,8 @@
|
||||
"identifier": "nu.lume.Lume",
|
||||
"build": {
|
||||
"beforeBuildCommand": "pnpm run build",
|
||||
"beforeDevCommand": "pnpm run dev",
|
||||
"devUrl": "http://localhost:3000",
|
||||
"beforeDevCommand": "pnpm desktop:dev",
|
||||
"devUrl": "http://localhost:5173",
|
||||
"frontendDist": "../dist"
|
||||
},
|
||||
"app": {
|
||||
|
@ -2,10 +2,13 @@
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"pipeline": {
|
||||
"build": {
|
||||
"outputs": ["dist/**"]
|
||||
"outputs": [
|
||||
"dist/**"
|
||||
]
|
||||
},
|
||||
"dev": {
|
||||
"cache": true
|
||||
"cache": false,
|
||||
"persistent": true
|
||||
},
|
||||
"type-check": {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user