feat: 集成tauri示例,playground目录下 执行 pnpm run tauri dev 即可启动

This commit is contained in:
Jin Mao
2025-07-07 12:38:24 +08:00
parent b8bf482c6a
commit 9b53f26253
28 changed files with 5491 additions and 4 deletions

View File

@@ -23,7 +23,8 @@
"typecheck": "vue-tsc --noEmit --skipLibCheck",
"test:e2e": "playwright test",
"test:e2e-ui": "playwright test --ui",
"test:e2e-codegen": "playwright codegen"
"test:e2e-codegen": "playwright codegen",
"tauri": "tauri"
},
"imports": {
"#/*": "./src/*"
@@ -51,9 +52,12 @@
"json-bigint": "catalog:",
"pinia": "catalog:",
"vue": "catalog:",
"vue-router": "catalog:"
"vue-router": "catalog:",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2"
},
"devDependencies": {
"@types/json-bigint": "catalog:"
"@types/json-bigint": "catalog:",
"@tauri-apps/cli": "^2"
}
}

7
playground/src-tauri/.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas

5156
playground/src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
[package]
name = "vben"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "vben_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"

View File

@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

View File

@@ -0,0 +1,10 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"core:default",
"opener:default"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 903 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1,14 @@
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@@ -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() {
vben_lib::run()
}

View File

@@ -0,0 +1,35 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "vben",
"version": "0.1.0",
"identifier": "com.vben.tauri",
"build": {
"beforeDevCommand": "pnpm dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "pnpm build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "Vben Admin",
"width": 800,
"height": 600
}
],
"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"
]
}
}

View File

@@ -1,9 +1,10 @@
<script lang="ts" setup>
import { computed } from 'vue';
import { computed, onMounted, ref } from 'vue';
import { useAntdDesignTokens } from '@vben/hooks';
import { preferences, usePreferences } from '@vben/preferences';
import { invoke } from '@tauri-apps/api/core';
import { App, ConfigProvider, theme } from 'ant-design-vue';
import { antdLocale } from '#/locales';
@@ -28,6 +29,18 @@ const tokenTheme = computed(() => {
token: tokens,
};
});
const greetMsg = ref('');
async function greet() {
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
greetMsg.value = await invoke('greet', { name: 'vben' });
}
onMounted(async () => {
await greet();
// eslint-disable-next-line no-console
console.log(greetMsg.value);
});
</script>
<template>

View File

@@ -4,7 +4,10 @@ export default defineConfig(async () => {
return {
application: {},
vite: {
clearScreen: false,
server: {
port: 1420,
strictPort: true,
proxy: {
'/api': {
changeOrigin: true,
@@ -14,6 +17,10 @@ export default defineConfig(async () => {
ws: true,
},
},
watch: {
// 3. tell Vite to ignore watching `src-tauri`
ignored: ['**/src-tauri/**'],
},
},
},
};

207
pnpm-lock.yaml generated
View File

@@ -1832,6 +1832,12 @@ importers:
'@tanstack/vue-query':
specifier: 'catalog:'
version: 5.81.5(vue@3.5.17(typescript@5.8.3))
'@tauri-apps/api':
specifier: ^2
version: 2.6.0
'@tauri-apps/plugin-opener':
specifier: ^2
version: 2.4.0
'@vben-core/menu-ui':
specifier: workspace:*
version: link:../packages/@core/ui-kit/menu-ui
@@ -1899,6 +1905,9 @@ importers:
specifier: 'catalog:'
version: 4.5.1(vue@3.5.17(typescript@5.8.3))
devDependencies:
'@tauri-apps/cli':
specifier: ^2
version: 2.6.2
'@types/json-bigint':
specifier: 'catalog:'
version: 1.0.4
@@ -4618,6 +4627,88 @@ packages:
peerDependencies:
vue: ^3.5.17
'@tauri-apps/api@2.6.0':
resolution: {integrity: sha512-hRNcdercfgpzgFrMXWwNDBN0B7vNzOzRepy6ZAmhxi5mDLVPNrTpo9MGg2tN/F7JRugj4d2aF7E1rtPXAHaetg==}
'@tauri-apps/cli-darwin-arm64@2.6.2':
resolution: {integrity: sha512-YlvT+Yb7u2HplyN2Cf/nBplCQARC/I4uedlYHlgtxg6rV7xbo9BvG1jLOo29IFhqA2rOp5w1LtgvVGwsOf2kxw==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [darwin]
'@tauri-apps/cli-darwin-x64@2.6.2':
resolution: {integrity: sha512-21gdPWfv1bP8rkTdCL44in70QcYcPaDM70L+y78N8TkBuC+/+wqnHcwwjzb+mUyck6UoEw2DORagSI/oKKUGJw==}
engines: {node: '>= 10'}
cpu: [x64]
os: [darwin]
'@tauri-apps/cli-linux-arm-gnueabihf@2.6.2':
resolution: {integrity: sha512-MW8Y6HqHS5yzQkwGoLk/ZyE1tWpnz/seDoY4INsbvUZdknuUf80yn3H+s6eGKtT/0Bfqon/W9sY7pEkgHRPQgA==}
engines: {node: '>= 10'}
cpu: [arm]
os: [linux]
'@tauri-apps/cli-linux-arm64-gnu@2.6.2':
resolution: {integrity: sha512-9PdINTUtnyrnQt9hvC4y1m0NoxKSw/wUB9OTBAQabPj8WLAdvySWiUpEiqJjwLhlu4T6ltXZRpNTEzous3/RXg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@tauri-apps/cli-linux-arm64-musl@2.6.2':
resolution: {integrity: sha512-LrcJTRr7FrtQlTDkYaRXIGo/8YU/xkWmBPC646WwKNZ/S6yqCiDcOMoPe7Cx4ZvcG6sK6LUCLQMfaSNEL7PT0A==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [musl]
'@tauri-apps/cli-linux-riscv64-gnu@2.6.2':
resolution: {integrity: sha512-GnTshO/BaZ9KGIazz2EiFfXGWgLur5/pjqklRA/ck42PGdUQJhV/Ao7A7TdXPjqAzpFxNo6M/Hx0GCH2iMS7IA==}
engines: {node: '>= 10'}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@tauri-apps/cli-linux-x64-gnu@2.6.2':
resolution: {integrity: sha512-QDG3WeJD6UJekmrtVPCJRzlKgn9sGzhvD58oAw5gIU+DRovgmmG2U1jH9fS361oYGjWWO7d/KM9t0kugZzi4lQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [glibc]
'@tauri-apps/cli-linux-x64-musl@2.6.2':
resolution: {integrity: sha512-TNVTDDtnWzuVqWBFdZ4+8ZTg17tc21v+CT5XBQ+KYCoYtCrIaHpW04fS5Tmudi+vYdBwoPDfwpKEB6LhCeFraQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [musl]
'@tauri-apps/cli-win32-arm64-msvc@2.6.2':
resolution: {integrity: sha512-z77C1oa/hMLO/jM1JF39tK3M3v9nou7RsBnQoOY54z5WPcpVAbS0XdFhXB7sSN72BOiO3moDky9lQANQz6L3CA==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [win32]
'@tauri-apps/cli-win32-ia32-msvc@2.6.2':
resolution: {integrity: sha512-TmD8BbzbjluBw8+QEIWUVmFa9aAluSkT1N937n1mpYLXcPbTpbunqRFiIznTwupoJNJIdtpF/t7BdZDRh5rrcg==}
engines: {node: '>= 10'}
cpu: [ia32]
os: [win32]
'@tauri-apps/cli-win32-x64-msvc@2.6.2':
resolution: {integrity: sha512-ItB8RCKk+nCmqOxOvbNtltz6x1A4QX6cSM21kj3NkpcnjT9rHSMcfyf8WVI2fkoMUJR80iqCblUX6ARxC3lj6w==}
engines: {node: '>= 10'}
cpu: [x64]
os: [win32]
'@tauri-apps/cli@2.6.2':
resolution: {integrity: sha512-s1/eyBHxk0wG1blLeOY2IDjgZcxVrkxU5HFL8rNDwjYGr0o7yr3RAtwmuUPhz13NO+xGAL1bJZaLFBdp+5joKg==}
engines: {node: '>= 10'}
hasBin: true
'@tauri-apps/plugin-opener@2.4.0':
resolution: {integrity: sha512-43VyN8JJtvKWJY72WI/KNZszTpDpzHULFxQs0CJBIYUdCRowQ6Q1feWTDb979N7nldqSuDOaBupZ6wz2nvuWwQ==}
'@tootallnate/once@1.1.2':
resolution: {integrity: sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==}
engines: {node: '>= 6'}
@@ -8136,6 +8227,41 @@ packages:
cpu: [x64]
os: [darwin]
lefthook-freebsd-arm64@1.11.14:
resolution: {integrity: sha512-oSdJKGGMohktFXC6faZCUt5afyHpDwWGIWAkHGgOXUVD/LiZDEn6U/8cQmKm1UAfBySuPTtfir0VeM04y6188g==}
cpu: [arm64]
os: [freebsd]
lefthook-freebsd-x64@1.11.14:
resolution: {integrity: sha512-gZdMWZwOtIhIPK3GPYac7JhXrxF188gkw65i6O7CedS/meDlK2vjBv5BUVLeD/satv4+jibEdV0h4Qqu/xIh2A==}
cpu: [x64]
os: [freebsd]
lefthook-linux-arm64@1.11.14:
resolution: {integrity: sha512-sZmqbTsGQFQw7gbfi9eIHFOxfcs66QfZYLRMh1DktODhyhRXB8RtI6KMeKCtPEGLhbK55/I4TprC8Qvj86UBgw==}
cpu: [arm64]
os: [linux]
lefthook-linux-x64@1.11.14:
resolution: {integrity: sha512-c+to1BRzFe419SNXAR6YpCBP8EVWxvUxlON3Z+efzmrHhdlhm7LvEoJcN4RQE4Gc2rJQJNe87OjsEZQkc4uQLg==}
cpu: [x64]
os: [linux]
lefthook-openbsd-arm64@1.11.14:
resolution: {integrity: sha512-fivG3D9G4ASRCTf3ecfz1WdnrHCW9pezaI8v1NVve8t6B2q0d0yeaje5dfhoAsAvwiFPRaMzka1Qaoyu8O8G9Q==}
cpu: [arm64]
os: [openbsd]
lefthook-openbsd-x64@1.11.14:
resolution: {integrity: sha512-vikmG0jf7JVKR3be6Wk3l1jtEdedEqk1BTdsaHFX1bj0qk0azcqlZ819Wt/IoyIYDzQCHKowZ6DuXsRjT+RXWA==}
cpu: [x64]
os: [openbsd]
lefthook-windows-arm64@1.11.14:
resolution: {integrity: sha512-5PoAJ9QKaqxJn1NWrhrhXpAROpl/dT7bGTo7VMj2ATO1cpRatbn6p+ssvc3tgeriFThowFb1D11Fg6OlFLi6UQ==}
cpu: [arm64]
os: [win32]
lefthook-windows-x64@1.11.14:
resolution: {integrity: sha512-kBeOPR0Aj5hQGxoBBntgz5/e/xaH5Vnzlq9lJjHW8sf23qu/JVUGg6ceCoicyVWJi+ZOBliTa8KzwCu+mgyJjw==}
cpu: [x64]
@@ -14643,6 +14769,59 @@ snapshots:
'@tanstack/virtual-core': 3.13.6
vue: 3.5.17(typescript@5.8.3)
'@tauri-apps/api@2.6.0': {}
'@tauri-apps/cli-darwin-arm64@2.6.2':
optional: true
'@tauri-apps/cli-darwin-x64@2.6.2':
optional: true
'@tauri-apps/cli-linux-arm-gnueabihf@2.6.2':
optional: true
'@tauri-apps/cli-linux-arm64-gnu@2.6.2':
optional: true
'@tauri-apps/cli-linux-arm64-musl@2.6.2':
optional: true
'@tauri-apps/cli-linux-riscv64-gnu@2.6.2':
optional: true
'@tauri-apps/cli-linux-x64-gnu@2.6.2':
optional: true
'@tauri-apps/cli-linux-x64-musl@2.6.2':
optional: true
'@tauri-apps/cli-win32-arm64-msvc@2.6.2':
optional: true
'@tauri-apps/cli-win32-ia32-msvc@2.6.2':
optional: true
'@tauri-apps/cli-win32-x64-msvc@2.6.2':
optional: true
'@tauri-apps/cli@2.6.2':
optionalDependencies:
'@tauri-apps/cli-darwin-arm64': 2.6.2
'@tauri-apps/cli-darwin-x64': 2.6.2
'@tauri-apps/cli-linux-arm-gnueabihf': 2.6.2
'@tauri-apps/cli-linux-arm64-gnu': 2.6.2
'@tauri-apps/cli-linux-arm64-musl': 2.6.2
'@tauri-apps/cli-linux-riscv64-gnu': 2.6.2
'@tauri-apps/cli-linux-x64-gnu': 2.6.2
'@tauri-apps/cli-linux-x64-musl': 2.6.2
'@tauri-apps/cli-win32-arm64-msvc': 2.6.2
'@tauri-apps/cli-win32-ia32-msvc': 2.6.2
'@tauri-apps/cli-win32-x64-msvc': 2.6.2
'@tauri-apps/plugin-opener@2.4.0':
dependencies:
'@tauri-apps/api': 2.6.0
'@tootallnate/once@1.1.2': {}
'@trysound/sax@0.2.0': {}
@@ -18583,6 +18762,27 @@ snapshots:
lefthook-darwin-x64@1.11.14:
optional: true
lefthook-freebsd-arm64@1.11.14:
optional: true
lefthook-freebsd-x64@1.11.14:
optional: true
lefthook-linux-arm64@1.11.14:
optional: true
lefthook-linux-x64@1.11.14:
optional: true
lefthook-openbsd-arm64@1.11.14:
optional: true
lefthook-openbsd-x64@1.11.14:
optional: true
lefthook-windows-arm64@1.11.14:
optional: true
lefthook-windows-x64@1.11.14:
optional: true
@@ -18590,6 +18790,13 @@ snapshots:
optionalDependencies:
lefthook-darwin-arm64: 1.11.14
lefthook-darwin-x64: 1.11.14
lefthook-freebsd-arm64: 1.11.14
lefthook-freebsd-x64: 1.11.14
lefthook-linux-arm64: 1.11.14
lefthook-linux-x64: 1.11.14
lefthook-openbsd-arm64: 1.11.14
lefthook-openbsd-x64: 1.11.14
lefthook-windows-arm64: 1.11.14
lefthook-windows-x64: 1.11.14
less@4.3.0: