提交 ae7d6d61 作者: 方治民

feat: 添加 tauri 实现示例

上级 acbd4552
...@@ -17,7 +17,7 @@ VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false ...@@ -17,7 +17,7 @@ VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false
# Basic interface address SPA # Basic interface address SPA
# VITE_GLOB_API_URL=/basic-api # VITE_GLOB_API_URL=/basic-api
VITE_GLOB_API_URL=http://192.168.0.156:8081 VITE_GLOB_API_URL=http://192.168.0.156:18181
# Interface prefix # Interface prefix
# VITE_GLOB_API_URL_PREFIX= # VITE_GLOB_API_URL_PREFIX=
......
...@@ -138,5 +138,9 @@ ...@@ -138,5 +138,9 @@
], ],
"vetur.format.scriptInitialIndent": true, "vetur.format.scriptInitialIndent": true,
"vetur.format.styleInitialIndent": true, "vetur.format.styleInitialIndent": true,
"vetur.validation.script": false "vetur.validation.script": false,
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"svg.preview.background": "transparent"
} }
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
"@logicflow/core": "^1.1.30", "@logicflow/core": "^1.1.30",
"@logicflow/extension": "^1.1.30", "@logicflow/extension": "^1.1.30",
"@stomp/stompjs": "^6.1.2", "@stomp/stompjs": "^6.1.2",
"@tauri-apps/api": "^1.2.0",
"@vue/runtime-core": "^3.2.44", "@vue/runtime-core": "^3.2.44",
"@vue/shared": "^3.2.44", "@vue/shared": "^3.2.44",
"@vueuse/core": "^9.5.0", "@vueuse/core": "^9.5.0",
...@@ -101,6 +102,7 @@ ...@@ -101,6 +102,7 @@
"@commitlint/config-conventional": "^17.2.0", "@commitlint/config-conventional": "^17.2.0",
"@iconify/json": "^2.1.135", "@iconify/json": "^2.1.135",
"@purge-icons/generated": "^0.8.1", "@purge-icons/generated": "^0.8.1",
"@tauri-apps/cli": "^1.2.0",
"@types/codemirror": "^5.60.5", "@types/codemirror": "^5.60.5",
"@types/crypto-js": "^4.1.1", "@types/crypto-js": "^4.1.1",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
......
...@@ -11,6 +11,8 @@ specifiers: ...@@ -11,6 +11,8 @@ specifiers:
'@logicflow/extension': ^1.1.30 '@logicflow/extension': ^1.1.30
'@purge-icons/generated': ^0.8.1 '@purge-icons/generated': ^0.8.1
'@stomp/stompjs': ^6.1.2 '@stomp/stompjs': ^6.1.2
'@tauri-apps/api': ^1.2.0
'@tauri-apps/cli': ^1.2.0
'@types/codemirror': ^5.60.5 '@types/codemirror': ^5.60.5
'@types/crypto-js': ^4.1.1 '@types/crypto-js': ^4.1.1
'@types/fs-extra': ^9.0.13 '@types/fs-extra': ^9.0.13
...@@ -129,6 +131,7 @@ dependencies: ...@@ -129,6 +131,7 @@ dependencies:
'@logicflow/core': 1.1.30 '@logicflow/core': 1.1.30
'@logicflow/extension': 1.1.30 '@logicflow/extension': 1.1.30
'@stomp/stompjs': 6.1.2 '@stomp/stompjs': 6.1.2
'@tauri-apps/api': 1.2.0
'@vue/runtime-core': 3.2.44 '@vue/runtime-core': 3.2.44
'@vue/shared': 3.2.44 '@vue/shared': 3.2.44
'@vueuse/core': 9.5.0_vue@3.2.44 '@vueuse/core': 9.5.0_vue@3.2.44
...@@ -170,6 +173,7 @@ devDependencies: ...@@ -170,6 +173,7 @@ devDependencies:
'@commitlint/config-conventional': 17.2.0 '@commitlint/config-conventional': 17.2.0
'@iconify/json': 2.1.135 '@iconify/json': 2.1.135
'@purge-icons/generated': 0.8.1 '@purge-icons/generated': 0.8.1
'@tauri-apps/cli': 1.2.0
'@types/codemirror': 5.60.5 '@types/codemirror': 5.60.5
'@types/crypto-js': 4.1.1 '@types/crypto-js': 4.1.1
'@types/fs-extra': 9.0.13 '@types/fs-extra': 9.0.13
...@@ -2206,6 +2210,108 @@ packages: ...@@ -2206,6 +2210,108 @@ packages:
string.prototype.matchall: 4.0.8 string.prototype.matchall: 4.0.8
dev: true dev: true
/@tauri-apps/api/1.2.0:
resolution: {integrity: sha512-lsI54KI6HGf7VImuf/T9pnoejfgkNoXveP14pVV7XarrQ46rOejIVJLFqHI9sRReJMGdh2YuCoI3cc/yCWCsrw==}
engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
dev: false
/@tauri-apps/cli-darwin-arm64/1.2.0:
resolution: {integrity: sha512-f3LR2RvTU2ulxYdK9Nc3vKaSpDChu52pz0BMWNrSs3dxs4WTVioie98Ufz+GorifkUp3sYXcJte3HzX6wH/QxQ==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@tauri-apps/cli-darwin-x64/1.2.0:
resolution: {integrity: sha512-m07QZaAZCtyobrjddfz/Rxf9GGutnBOpRMbNqVqCk0qKRJzHG1fIsLqkgZh6+qPv0zHpu7xi/FPcqTec72Cp8w==}
engines: {node: '>= 10'}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@tauri-apps/cli-linux-arm-gnueabihf/1.2.0:
resolution: {integrity: sha512-Id9eF1JtthZRFVtXAAVtSlI3uMT8cJ7LYmCSIl3mAXEUeaPBxnUs1i9X6/J+2Ho3yLEuuOxJ7PaJd+4v8wnEeg==}
engines: {node: '>= 10'}
cpu: [arm]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@tauri-apps/cli-linux-arm64-gnu/1.2.0:
resolution: {integrity: sha512-NtfPkkpeMPl+i/tB/Fc8ST2rKO2vV8int/RkOvNGLCkhWcl4sbzKBol7tc4q8c8h0X7FXDcF1l/EOuGsZUAA5Q==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@tauri-apps/cli-linux-arm64-musl/1.2.0:
resolution: {integrity: sha512-tz+mOOVsy/TMdq2WJVIJl/iwW3OCWCyD5Fls3fhyJ4XpLfjn4G+C+oU0awXD/0se0ko81aq4D+r8eDx6oBRi0A==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@tauri-apps/cli-linux-x64-gnu/1.2.0:
resolution: {integrity: sha512-FH/wU+OWZjRQvrq/oequScr72I84XgOuRuMEpt/GqGD341cBJ8ithpoyzuiKsvjS6K0qMyRFzy3eyhQ7gwX+4Q==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@tauri-apps/cli-linux-x64-musl/1.2.0:
resolution: {integrity: sha512-nLg30aBT9fI83sjIqaGPN7twbtE5LJy2DbKzxIlw59F+GT8HBdiM/2mZdTLB3AQb52yVHuGB1TVtWDsl0JHqCA==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@tauri-apps/cli-win32-ia32-msvc/1.2.0:
resolution: {integrity: sha512-eXtgIgY0fawgcOuUjH8Y6PxwPxbK87Zl9XmA7Q0m58T7pIz+gcbgvtH8Bb+liYHoRYItIhQxVm+ui7Y59rI7Cg==}
engines: {node: '>= 10'}
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@tauri-apps/cli-win32-x64-msvc/1.2.0:
resolution: {integrity: sha512-egyM66R05AIbkaUDptpHurFTIYp3VM4H5OrRd3O2b0oXf8SoiXiyrHbQsHVHHDYyytKmwkdNqjdy+Vev/Vq25Q==}
engines: {node: '>= 10'}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@tauri-apps/cli/1.2.0:
resolution: {integrity: sha512-DgUnk4p/atWHq2HUx9Vt+/LuRsx4iFlkzdZIUxtFWvpcZih2k0TzmHJbrhM1evh1/7a+SqiwDawmyf3Hz1HxXA==}
engines: {node: '>= 10'}
hasBin: true
optionalDependencies:
'@tauri-apps/cli-darwin-arm64': 1.2.0
'@tauri-apps/cli-darwin-x64': 1.2.0
'@tauri-apps/cli-linux-arm-gnueabihf': 1.2.0
'@tauri-apps/cli-linux-arm64-gnu': 1.2.0
'@tauri-apps/cli-linux-arm64-musl': 1.2.0
'@tauri-apps/cli-linux-x64-gnu': 1.2.0
'@tauri-apps/cli-linux-x64-musl': 1.2.0
'@tauri-apps/cli-win32-ia32-msvc': 1.2.0
'@tauri-apps/cli-win32-x64-msvc': 1.2.0
dev: true
/@trysound/sax/0.2.0: /@trysound/sax/0.2.0:
resolution: {integrity: sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==} resolution: {integrity: sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==}
engines: {node: '>=10.13.0'} engines: {node: '>=10.13.0'}
......
# Generated by Cargo
# will have compiled files and executables
/target/
[package]
name = "app"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
default-run = "app"
edition = "2021"
rust-version = "1.59"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.2.0", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2.0", features = [] }
rusb = "0.9"
sysinfo = "0.26.7"
[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
default = [ "custom-protocol" ]
# this feature is used for production builds where `devPath` points to the filesystem
# DO NOT remove this
custom-protocol = [ "tauri/custom-protocol" ]
fn main() {
tauri_build::build()
}
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use sysinfo::{DiskExt, System, SystemExt};
fn main() {
let s = System::new_all();
for disk in s.disks() {
println!("{:?}: {:?}", disk.name(), disk.type_());
}
tauri::Builder::default()
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
{
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
"build": {
"beforeBuildCommand": "pnpm build",
"beforeDevCommand": "pnpm dev",
"devPath": "http://localhost:3100",
"distDir": "../dist",
"withGlobalTauri": true
},
"package": {
"productName": "basic-vue-admin",
"version": "0.1.0"
},
"tauri": {
"allowlist": {
"all": false
},
"bundle": {
"active": true,
"category": "DeveloperTool",
"copyright": "",
"deb": {
"depends": []
},
"externalBin": [],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"identifier": "com.yiring.app.beta",
"longDescription": "",
"macOS": {
"entitlements": null,
"exceptionDomain": "",
"frameworks": [],
"providerShortName": null,
"signingIdentity": null
},
"resources": [],
"shortDescription": "",
"targets": "all",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"security": {
"csp": null
},
"updater": {
"active": false
},
"windows": [
{
"title": "Basic Vue Admin",
"width": 800,
"height": 600,
"resizable": true,
"maximized": true,
"fullscreen": false
}
]
}
}
...@@ -59,6 +59,9 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { ...@@ -59,6 +59,9 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
port: VITE_PORT, port: VITE_PORT,
// Load proxy configuration from .env // Load proxy configuration from .env
proxy: createProxy(VITE_PROXY), proxy: createProxy(VITE_PROXY),
// Tauri 使用固定端口,若此端口不可用将会导致程序错误
strictPort: true,
}, },
esbuild: { esbuild: {
pure: VITE_DROP_CONSOLE ? ['console.log', 'debugger'] : [], pure: VITE_DROP_CONSOLE ? ['console.log', 'debugger'] : [],
...@@ -68,6 +71,12 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { ...@@ -68,6 +71,12 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
cssTarget: 'chrome80', cssTarget: 'chrome80',
outDir: OUTPUT_DIR, outDir: OUTPUT_DIR,
// minify: 'terser', // minify: 'terser',
// Tauri 不为调试构建压缩构建体积
minify: !process.env.TAURI_DEBUG ? 'esbuild' : false,
// Tauri 为调试构建生成源代码映射 (sourcemap)
sourcemap: !!process.env.TAURI_DEBUG,
/** /**
* 当 minify=“minify:'terser'” 解开注释 * 当 minify=“minify:'terser'” 解开注释
* Uncomment when minify="minify:'terser'" * Uncomment when minify="minify:'terser'"
...@@ -123,5 +132,12 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { ...@@ -123,5 +132,12 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
'ant-design-vue/es/locale/en_US', 'ant-design-vue/es/locale/en_US',
], ],
}, },
// Tauri
// https://tauri.app/zh/v1/guides/getting-started/setup/vite
clearScreen: false,
// 使用 `TAURI_PLATFORM`、`TAURI_ARCH`、`TAURI_FAMILY`,
// `TAURI_PLATFORM_VERSION`、`TAURI_PLATFORM_TYPE` 和 `TAURI_DEBUG` 环境变量
envPrefix: ['VITE_', 'TAURI_'],
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论