mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
fix: tauri npm scripts (#955)
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="stylesheet" href="/src/style.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>AFFiNE</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="react-root" />
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -6,9 +6,8 @@
|
||||
"license": "MPL-2.0",
|
||||
"module": "true",
|
||||
"scripts": {
|
||||
"dev:app": "pnpm build:preload && cross-env NODE_ENV=development tauri dev",
|
||||
"dev:prerequisite": "concurrently \"cd ../packages/data-center && pnpm dev\" \"cd ../apps/web && pnpm dev\"",
|
||||
"build:prerequisite": "pnpm build:submodules && pnpm build:rs-types && pnpm build:affine && pnpm build:preload",
|
||||
"dev:app": "cross-env NODE_ENV=development tauri dev",
|
||||
"dev:prerequisite": "cd ../../ && pnpm build && concurrently \"cd packages/data-center && pnpm dev\" \"cd apps/web && pnpm dev\"",
|
||||
"build:rs-types": "zx scripts/generateTsTypingsFromJsonSchema.mjs",
|
||||
"build:submodules": "zx scripts/buildSubModules.mjs",
|
||||
"build:affine": "zx scripts/buildAffine.mjs",
|
||||
|
||||
@@ -14,6 +14,8 @@ const publicAffineOutDirectory = path.join(
|
||||
'affine-out'
|
||||
);
|
||||
|
||||
if (process.platform === 'win32') $.shell = 'pwsh';
|
||||
|
||||
/**
|
||||
* Build affine dist html
|
||||
*/
|
||||
@@ -21,7 +23,7 @@ cd(repoDirectory);
|
||||
await $`pnpm i -r`;
|
||||
await $`pnpm build`;
|
||||
cd(affineSrcDirectory);
|
||||
$.env.BASE_PATH = '/affine-out';
|
||||
$.env.NEXT_BASE_PATH = '/affine-out';
|
||||
await $`pnpm build`;
|
||||
await $`pnpm export`;
|
||||
await fs.remove(publicAffineOutDirectory);
|
||||
|
||||
@@ -8,6 +8,7 @@ mod state;
|
||||
use dotenvy::dotenv;
|
||||
use state::AppState;
|
||||
use std::env;
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::TitleBarStyle;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
@@ -17,7 +18,9 @@ async fn main() {
|
||||
dotenv().ok();
|
||||
let preload = include_str!("../../public/preload/index.js");
|
||||
let is_dev = env::var("NODE_ENV").unwrap_or_default() == "development";
|
||||
// this only work in production mode, in dev mode, we load `devPath` in tauri.conf.json
|
||||
let initial_path = if is_dev {
|
||||
// just a place holder here
|
||||
"index.html"
|
||||
} else {
|
||||
"affine-out/index.html"
|
||||
@@ -32,10 +35,13 @@ async fn main() {
|
||||
tauri::WindowBuilder::new(app, "label", tauri::WindowUrl::App(initial_path.into()))
|
||||
.title("AFFiNE")
|
||||
.inner_size(1000.0, 800.0)
|
||||
.title_bar_style(TitleBarStyle::Overlay)
|
||||
.hidden_title(true)
|
||||
.initialization_script(&preload)
|
||||
.build()?;
|
||||
.initialization_script(&preload);
|
||||
// fix `title_bar_style` found for struct `WindowBuilder` in the current scope
|
||||
#[cfg(target_os = "macos")]
|
||||
let _window = _window
|
||||
.hidden_title(true)
|
||||
.title_bar_style(TitleBarStyle::Overlay);
|
||||
let _window = _window.build()?;
|
||||
#[cfg(debug_assertions)]
|
||||
_window.open_devtools();
|
||||
Ok(())
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev:prerequisite",
|
||||
"beforeDevCommand": "pnpm build:preload && pnpm dev:prerequisite",
|
||||
"beforeBuildCommand": "pnpm build:preload && pnpm build:affine",
|
||||
"devPath": "http://localhost:8080",
|
||||
"distDir": "../public",
|
||||
|
||||
Reference in New Issue
Block a user