use tauri instead of webview
No files matched your search
@@ -31,7 +31,7 @@
|
||||
|
||||
- Level: [C1](https://resources.allsetlearning.com/chinese/grammar/C1_grammar_points) / [HSK6](https://resources.allsetlearning.com/chinese/grammar/HSK6_grammar_points)
|
||||
- Similar to
|
||||
- [Expressing "every" with "每"](https://resources.allsetlearning.com/chinese/grammar/Expressing_%22every%22_with_%22mei%22) (A2)
|
||||
- [Expressing "every" with "每"](../A2/每.md) (A2)
|
||||
- [Expressing "as long as" with "只要"](../B2/只要.md) (B2)
|
||||
- Used for
|
||||
- Keywords: [凡是](https://resources.allsetlearning.com/chinese/grammar/%E5%87%A1%E6%98%AF)
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "pnpm run dev:webview",
|
||||
"dev:webview": "node --disable-warning=DEP0190 webview.js",
|
||||
"dev:vp": "vitepress dev docs",
|
||||
"build": "vitepress build docs",
|
||||
"preview": "vitepress preview docs"
|
||||
"start": "tauri dev",
|
||||
"dev:web": "vitepress dev docs",
|
||||
"build:web": "vitepress build docs",
|
||||
"preview:web": "vitepress preview docs"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
@@ -19,8 +18,6 @@
|
||||
"vue": "^3.5.30"
|
||||
},
|
||||
"devDependencies": {
|
||||
"concurrently": "^9.2.1",
|
||||
"kill-port": "^2.0.1",
|
||||
"webview-nodejs": "^0.4.3"
|
||||
"@tauri-apps/cli": "^2.10.1"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,2 @@
|
||||
onlyBuiltDependencies:
|
||||
- esbuild
|
||||
- libwebview-nodejs
|
||||
@@ -0,0 +1,4 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
/gen/schemas
|
||||
@@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "app"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
license = ""
|
||||
repository = ""
|
||||
edition = "2021"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
name = "app_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.5.6", features = [] }
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
log = "0.4"
|
||||
tauri = { version = "2.10.3", features = [] }
|
||||
tauri-plugin-log = "2"
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "enables the default permissions",
|
||||
"windows": [
|
||||
"main"
|
||||
],
|
||||
"permissions": [
|
||||
"core:default"
|
||||
]
|
||||
}
|
||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 49 KiB |
@@ -0,0 +1,16 @@
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
if cfg!(debug_assertions) {
|
||||
app.handle().plugin(
|
||||
tauri_plugin_log::Builder::default()
|
||||
.level(log::LevelFilter::Info)
|
||||
.build(),
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
app_lib::run();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "zh-grammar",
|
||||
"version": "0.1.0",
|
||||
"identifier": "cc.polv.zh-grammar",
|
||||
"build": {
|
||||
"frontendDist": "../docs/.vitepress/dist",
|
||||
"devUrl": "http://localhost:5173",
|
||||
"beforeDevCommand": "pnpm dev:web",
|
||||
"beforeBuildCommand": "pnpm build:web"
|
||||
},
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "zh-grammar",
|
||||
"width": 1024,
|
||||
"height": 768,
|
||||
"resizable": true,
|
||||
"maximized": true,
|
||||
"fullscreen": false
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
const { Webview } = require("webview-nodejs");
|
||||
const { spawn } = require("child_process");
|
||||
const PORT = 5173;
|
||||
|
||||
/**
|
||||
* I don’t see an alternative: “DeprecationWarning: Passing args to a child process with shell option true …”
|
||||
* https://github.com/nodejs/help/issues/5063
|
||||
*/
|
||||
const p = spawn("pnpm", ["vitepress", "dev", "--port", String(PORT), "docs"], {
|
||||
shell: true,
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
const w = new Webview();
|
||||
w.title(require("./package.json").name);
|
||||
w.size(1920, 1280);
|
||||
w.init(/* js */ `
|
||||
document.addEventListener('click', (ev) => {
|
||||
if (ev.target.matches('a')) {
|
||||
const href = ev.target.href || '';
|
||||
if (href.startsWith('https://resources.allsetlearning.com/chinese/')) ev.preventDefault();
|
||||
}
|
||||
})
|
||||
`);
|
||||
w.navigate(`http://localhost:${PORT}`);
|
||||
w.show();
|
||||
|
||||
console.log(p.kill("SIGINT"));
|
||||
|
||||
/**
|
||||
* node:child_process#spawn doesn't fire close event if app exits immediately after spawned app exits
|
||||
* ??? https://github.com/oven-sh/bun/issues/3083
|
||||
*/
|
||||
require("kill-port")(PORT);
|
||||