Automatic tauri imports
This commit is contained in:
@@ -31,26 +31,6 @@ export default defineNuxtConfig({
|
||||
css: [
|
||||
"@unocss/reset/tailwind.css"
|
||||
],
|
||||
imports: {
|
||||
presets: [
|
||||
{
|
||||
from: "@tauri-apps/api/app",
|
||||
imports: ["getName", "getVersion", "getTauriVersion"]
|
||||
},
|
||||
{
|
||||
from: "@tauri-apps/plugin-shell",
|
||||
imports: ["Command"]
|
||||
},
|
||||
{
|
||||
from: "@tauri-apps/plugin-os",
|
||||
imports: ["platform"]
|
||||
},
|
||||
{
|
||||
from: "@tauri-apps/plugin-notification",
|
||||
imports: ["sendNotification", "requestPermission", "isPermissionGranted"]
|
||||
}
|
||||
]
|
||||
},
|
||||
vite: {
|
||||
clearScreen: false,
|
||||
envPrefix: ["VITE_", "TAURI_"],
|
||||
|
26
src/modules/tauri.ts
Normal file
26
src/modules/tauri.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { addImports, defineNuxtModule } from "nuxt/kit";
|
||||
import * as tauriApp from "@tauri-apps/api/app";
|
||||
import * as tauriShell from "@tauri-apps/plugin-shell";
|
||||
import * as tauriOs from "@tauri-apps/plugin-os";
|
||||
import * as tauriNotification from "@tauri-apps/plugin-notification";
|
||||
|
||||
export default defineNuxtModule({
|
||||
meta: {
|
||||
name: "nuxt-tauri",
|
||||
configKey: "nuxt-tauri"
|
||||
},
|
||||
setup() {
|
||||
Object.keys(tauriApp).filter((name) => name !== "default").forEach((name) => {
|
||||
addImports({ from: "@tauri-apps/api/app", name });
|
||||
});
|
||||
Object.keys(tauriShell).filter((name) => name !== "default").forEach((name) => {
|
||||
addImports({ from: "@tauri-apps/plugin-shell", name });
|
||||
});
|
||||
Object.keys(tauriOs).filter((name) => name !== "default").forEach((name) => {
|
||||
addImports({ from: "@tauri-apps/plugin-os", name });
|
||||
});
|
||||
Object.keys(tauriNotification).filter((name) => name !== "default").forEach((name) => {
|
||||
addImports({ from: "@tauri-apps/plugin-notification", name });
|
||||
});
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user