{
9 | let state = SysInfoState::default();
10 | let sysinfo = state.sysinfo.lock().unwrap();
11 | let cpu_count = sysinfo.cpu_count();
12 | Ok(cpu_count)
13 | }
14 |
15 | pub fn run() {
16 | tauri::Builder::default()
17 | .plugin(tauri_plugin_system_info::init())
18 | .invoke_handler(tauri::generate_handler![
19 | cpu_count
20 | ])
21 | .setup(|app| {
22 | #[cfg(debug_assertions)] // only include this code on debug builds
23 | {
24 | let window = app.get_webview_window("main").unwrap();
25 | window.open_devtools();
26 | }
27 | Ok(())
28 | })
29 | .run(tauri::generate_context!())
30 | .expect("error while running tauri application");
31 | }
32 |
--------------------------------------------------------------------------------
/examples/sveltekit/src-tauri/src/main.rs:
--------------------------------------------------------------------------------
1 | // Prevents additional console window on Windows in release, DO NOT REMOVE!!
2 | #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
3 |
4 | fn main() {
5 | app_lib::run();
6 | }
7 |
--------------------------------------------------------------------------------
/examples/sveltekit/src-tauri/tauri.conf.json:
--------------------------------------------------------------------------------
1 | {
2 | "productName": "demo",
3 | "version": "0.1.0",
4 | "identifier": "com.tauri.dev",
5 | "build": {
6 | "frontendDist": "../build",
7 | "devUrl": "http://localhost:5173",
8 | "beforeDevCommand": "npm run dev",
9 | "beforeBuildCommand": "npm run build"
10 | },
11 | "app": {
12 | "windows": [
13 | {
14 | "title": "demo",
15 | "width": 800,
16 | "height": 600,
17 | "resizable": true,
18 | "fullscreen": false
19 | }
20 | ],
21 | "security": {
22 | "csp": null
23 | }
24 | },
25 | "bundle": {
26 | "active": true,
27 | "targets": "all",
28 | "icon": [
29 | "icons/32x32.png",
30 | "icons/128x128.png",
31 | "icons/128x128@2x.png",
32 | "icons/icon.icns",
33 | "icons/icon.ico"
34 | ]
35 | },
36 | "$schema": "../node_modules/@tauri-apps/cli/schema.json"
37 | }
38 |
--------------------------------------------------------------------------------
/examples/sveltekit/src/app.d.ts:
--------------------------------------------------------------------------------
1 | // See https://kit.svelte.dev/docs/types#app
2 | // for information about these interfaces
3 | declare global {
4 | namespace App {
5 | // interface Error {}
6 | // interface Locals {}
7 | // interface PageData {}
8 | // interface Platform {}
9 | }
10 | }
11 |
12 | export {};
13 |
--------------------------------------------------------------------------------
/examples/sveltekit/src/app.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %sveltekit.head%
8 |
9 |
10 | %sveltekit.body%
11 |
12 |
13 |
--------------------------------------------------------------------------------
/examples/sveltekit/src/lib/app.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
--------------------------------------------------------------------------------
/examples/sveltekit/src/lib/index.ts:
--------------------------------------------------------------------------------
1 | // place files you want to import through the `$lib` alias in this folder.
2 |
--------------------------------------------------------------------------------
/examples/sveltekit/src/routes/+layout.svelte:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/examples/sveltekit/src/routes/+layout.ts:
--------------------------------------------------------------------------------
1 | export const prerender = true
2 | export const ssr = false
--------------------------------------------------------------------------------
/examples/sveltekit/src/routes/+page.svelte:
--------------------------------------------------------------------------------
1 |
89 |
90 |
91 |
System Info
92 |
93 |
94 | Load Average
95 |
96 |
97 | Uptime
98 |
99 |
100 | Memory Info
101 |
102 |
103 | CPU Info
104 |
105 |
106 | Static Info
107 |
108 |
109 | Batteries
110 |
111 |
112 | Processes
113 |
114 |
115 |
116 | All System Info
117 |
118 |
119 |
--------------------------------------------------------------------------------
/examples/sveltekit/static/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuakunShen/tauri-plugin-system-info/afb2b7fe50f337500937eb946c1204a728353b63/examples/sveltekit/static/favicon.png
--------------------------------------------------------------------------------
/examples/sveltekit/svelte.config.js:
--------------------------------------------------------------------------------
1 | import adapter from '@sveltejs/adapter-static';
2 | import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
3 |
4 | /** @type {import('@sveltejs/kit').Config} */
5 | const config = {
6 | // Consult https://kit.svelte.dev/docs/integrations#preprocessors
7 | // for more information about preprocessors
8 | preprocess: vitePreprocess(),
9 |
10 | kit: {
11 | // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
12 | // If your environment is not supported or you settled on a specific environment, switch out the adapter.
13 | // See https://kit.svelte.dev/docs/adapters for more information about adapters.
14 | adapter: adapter()
15 | }
16 | };
17 |
18 | export default config;
19 |
--------------------------------------------------------------------------------
/examples/sveltekit/tailwind.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('tailwindcss').Config} */
2 | export default {
3 | content: ['./src/**/*.{html,js,svelte,ts}'],
4 | theme: {
5 | extend: {},
6 | },
7 | plugins: [require("daisyui")],
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/examples/sveltekit/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./.svelte-kit/tsconfig.json",
3 | "compilerOptions": {
4 | "allowJs": true,
5 | "checkJs": true,
6 | "esModuleInterop": true,
7 | "forceConsistentCasingInFileNames": true,
8 | "resolveJsonModule": true,
9 | "skipLibCheck": true,
10 | "sourceMap": true,
11 | "strict": true
12 | }
13 | // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
14 | //
15 | // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
16 | // from the referenced tsconfig.json - TypeScript does not merge them in
17 | }
18 |
--------------------------------------------------------------------------------
/examples/sveltekit/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { sveltekit } from '@sveltejs/kit/vite';
2 | import { defineConfig } from 'vite';
3 |
4 | export default defineConfig({
5 | plugins: [sveltekit()]
6 | });
7 |
--------------------------------------------------------------------------------
/guest-js/api.ts:
--------------------------------------------------------------------------------
1 | import { invoke } from "@tauri-apps/api/core";
2 | import {
3 | Cpu,
4 | Disk,
5 | Network,
6 | Component,
7 | Process,
8 | StaticInfo,
9 | MemoryInfo,
10 | CpuInfo,
11 | AllSystemInfo,
12 | Battery,
13 | LoadAverage,
14 | } from "./type";
15 |
16 | export function allSysInfo(): Promise {
17 | return invoke("plugin:system-info|all_sys_info");
18 | }
19 | // Memory
20 | export function totalMemory(): Promise {
21 | return invoke("plugin:system-info|total_memory");
22 | }
23 | export function usedMemory(): Promise {
24 | return invoke("plugin:system-info|used_memory");
25 | }
26 | export function totalSwap(): Promise {
27 | return invoke("plugin:system-info|total_swap");
28 | }
29 | export function usedSwap(): Promise {
30 | return invoke("plugin:system-info|used_swap");
31 | }
32 | export function memoryInfo(): Promise {
33 | return invoke("plugin:system-info|memory_info");
34 | }
35 | // Static Info
36 | export function hostname(): Promise {
37 | return invoke("plugin:system-info|hostname");
38 | }
39 | export function name(): Promise {
40 | return invoke("plugin:system-info|name");
41 | }
42 | export function kernelVersion(): Promise {
43 | return invoke("plugin:system-info|kernel_version");
44 | }
45 | export function osVersion(): Promise