This commit is contained in:
Julian Freeman
2026-03-14 16:18:11 -04:00
commit 375b6fdb11
46 changed files with 7988 additions and 0 deletions

24
.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

7
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"recommendations": [
"Vue.volar",
"tauri-apps.tauri-vscode",
"rust-lang.rust-analyzer"
]
}

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# Windows 软件管理
使用 Gemini CLI 生成。

14
index.html Normal file
View File

@@ -0,0 +1,14 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Windows 软件管理</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

26
package.json Normal file
View File

@@ -0,0 +1,26 @@
{
"name": "win-softmgr",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"tauri": "tauri"
},
"dependencies": {
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2",
"pinia": "^3.0.4",
"vue": "^3.5.13",
"vue-router": "^4.6.4"
},
"devDependencies": {
"@tauri-apps/cli": "^2",
"@vitejs/plugin-vue": "^5.2.1",
"typescript": "~5.6.2",
"vite": "^6.0.3",
"vue-tsc": "^2.1.10"
}
}

1219
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

6
public/tauri.svg Normal file
View File

@@ -0,0 +1,6 @@
<svg width="206" height="231" viewBox="0 0 206 231" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M143.143 84C143.143 96.1503 133.293 106 121.143 106C108.992 106 99.1426 96.1503 99.1426 84C99.1426 71.8497 108.992 62 121.143 62C133.293 62 143.143 71.8497 143.143 84Z" fill="#FFC131"/>
<ellipse cx="84.1426" cy="147" rx="22" ry="22" transform="rotate(180 84.1426 147)" fill="#24C8DB"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M166.738 154.548C157.86 160.286 148.023 164.269 137.757 166.341C139.858 160.282 141 153.774 141 147C141 144.543 140.85 142.121 140.558 139.743C144.975 138.204 149.215 136.139 153.183 133.575C162.73 127.404 170.292 118.608 174.961 108.244C179.63 97.8797 181.207 86.3876 179.502 75.1487C177.798 63.9098 172.884 53.4021 165.352 44.8883C157.82 36.3744 147.99 30.2165 137.042 27.1546C126.095 24.0926 114.496 24.2568 103.64 27.6274C92.7839 30.998 83.1319 37.4317 75.8437 46.1553C74.9102 47.2727 74.0206 48.4216 73.176 49.5993C61.9292 50.8488 51.0363 54.0318 40.9629 58.9556C44.2417 48.4586 49.5653 38.6591 56.679 30.1442C67.0505 17.7298 80.7861 8.57426 96.2354 3.77762C111.685 -1.01901 128.19 -1.25267 143.769 3.10474C159.348 7.46215 173.337 16.2252 184.056 28.3411C194.775 40.457 201.767 55.4101 204.193 71.404C206.619 87.3978 204.374 103.752 197.73 118.501C191.086 133.25 180.324 145.767 166.738 154.548ZM41.9631 74.275L62.5557 76.8042C63.0459 72.813 63.9401 68.9018 65.2138 65.1274C57.0465 67.0016 49.2088 70.087 41.9631 74.275Z" fill="#FFC131"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38.4045 76.4519C47.3493 70.6709 57.2677 66.6712 67.6171 64.6132C65.2774 70.9669 64 77.8343 64 85.0001C64 87.1434 64.1143 89.26 64.3371 91.3442C60.0093 92.8732 55.8533 94.9092 51.9599 97.4256C42.4128 103.596 34.8505 112.392 30.1816 122.756C25.5126 133.12 23.9357 144.612 25.6403 155.851C27.3449 167.09 32.2584 177.598 39.7906 186.112C47.3227 194.626 57.153 200.784 68.1003 203.846C79.0476 206.907 90.6462 206.743 101.502 203.373C112.359 200.002 122.011 193.568 129.299 184.845C130.237 183.722 131.131 182.567 131.979 181.383C143.235 180.114 154.132 176.91 164.205 171.962C160.929 182.49 155.596 192.319 148.464 200.856C138.092 213.27 124.357 222.426 108.907 227.222C93.458 232.019 76.9524 232.253 61.3736 227.895C45.7948 223.538 31.8055 214.775 21.0867 202.659C10.3679 190.543 3.37557 175.59 0.949823 159.596C-1.47592 143.602 0.768139 127.248 7.41237 112.499C14.0566 97.7497 24.8183 85.2327 38.4045 76.4519ZM163.062 156.711L163.062 156.711C162.954 156.773 162.846 156.835 162.738 156.897C162.846 156.835 162.954 156.773 163.062 156.711Z" fill="#24C8DB"/>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

7
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

5445
src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

26
src-tauri/Cargo.toml Normal file
View File

@@ -0,0 +1,26 @@
[package]
name = "win-softmgr"
version = "0.1.0"
description = "A Windows Software Manager"
authors = ["Julian"]
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 = "win_softmgr_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"
tokio = { version = "1.50.0", features = ["full"] }

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="*"
name="WinSoftMgr"
type="win32"
/>
<description>Windows Software Manager</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 & 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
</application>
</compatibility>
<!-- 启用 DPI 意识和长路径支持 -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
</assembly>

6
src-tauri/build.rs Normal file
View File

@@ -0,0 +1,6 @@
fn main() {
let mut windows = tauri_build::WindowsAttributes::new();
windows = windows.app_manifest(include_str!("admin.exe.manifest"));
tauri_build::try_build(tauri_build::Attributes::new().windows_attributes(windows))
.expect("failed to run tauri-build");
}

View File

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

BIN
src-tauri/icons/128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
src-tauri/icons/32x32.png Normal file

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

BIN
src-tauri/icons/icon.icns Normal file

Binary file not shown.

BIN
src-tauri/icons/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
src-tauri/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

132
src-tauri/src/lib.rs Normal file
View File

@@ -0,0 +1,132 @@
pub mod winget;
use std::fs;
use std::process::Command;
use std::os::windows::process::CommandExt;
use tokio::sync::mpsc;
use tauri::{AppHandle, Manager, State, Emitter};
use serde::Serialize;
use winget::{Software, list_all_software, list_updates};
struct AppState {
install_tx: mpsc::Sender<String>,
}
#[tauri::command]
fn get_essentials(app: AppHandle) -> Vec<Software> {
let app_data_dir = app.path().app_data_dir().unwrap_or_default();
if !app_data_dir.exists() {
let _ = fs::create_dir_all(&app_data_dir);
}
let file_path = app_data_dir.join("setup-essentials.json");
if !file_path.exists() {
let default_essentials = vec![
Software {
id: "Microsoft.PowerToys".to_string(),
name: "PowerToys".to_string(),
description: Some("Microsoft PowerToys 是一组实用程序,供高级用户调整和简化其 Windows 10 和 11 体验。".to_string()),
version: None,
available_version: None,
icon_url: Some("https://raw.githubusercontent.com/microsoft/PowerToys/master/doc/images/logo.png".to_string()),
status: "idle".to_string(),
progress: 0.0,
},
Software {
id: "Google.Chrome".to_string(),
name: "Google Chrome".to_string(),
description: Some("Google Chrome 是一款快速、安全且免费的浏览器。".to_string()),
version: None,
available_version: None,
icon_url: Some("https://www.google.com/chrome/static/images/chrome-logo.svg".to_string()),
status: "idle".to_string(),
progress: 0.0,
}
];
let _ = fs::write(&file_path, serde_json::to_string_pretty(&default_essentials).unwrap());
return default_essentials;
}
let content = fs::read_to_string(file_path).unwrap_or_else(|_| "[]".to_string());
serde_json::from_str(&content).unwrap_or_default()
}
#[tauri::command]
async fn get_all_software() -> Vec<Software> {
tokio::task::spawn_blocking(move || list_all_software()).await.unwrap_or_default()
}
#[tauri::command]
async fn get_updates() -> Vec<Software> {
tokio::task::spawn_blocking(move || list_updates()).await.unwrap_or_default()
}
#[tauri::command]
async fn install_software(id: String, state: State<'_, AppState>) -> Result<(), String> {
state.install_tx.send(id).await.map_err(|e| e.to_string())
}
#[derive(Clone, Serialize)]
struct InstallProgress {
id: String,
status: String,
progress: f32,
}
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.setup(move |app| {
let handle = app.handle().clone();
// 在 setup 闭包中初始化,此时运行时已就绪
let (tx, mut rx) = mpsc::channel::<String>(100);
// 托管状态
app.manage(AppState { install_tx: tx });
// 后台安装队列
tauri::async_runtime::spawn(async move {
while let Some(id) = rx.recv().await {
let _ = handle.emit("install-status", InstallProgress {
id: id.clone(),
status: "installing".to_string(),
progress: 0.5,
});
let id_for_cmd = id.clone();
let status_result = tokio::task::spawn_blocking(move || {
let output = Command::new("winget")
.args([
"install", "--id", &id_for_cmd, "-e", "--silent",
"--accept-package-agreements", "--accept-source-agreements",
"--disable-interactivity"
])
.creation_flags(0x08000000)
.output();
match output {
Ok(out) if out.status.success() => "success",
_ => "error",
}
}).await.unwrap_or("error");
let _ = handle.emit("install-status", InstallProgress {
id: id.clone(),
status: status_result.to_string(),
progress: 1.0,
});
}
});
Ok(())
})
.invoke_handler(tauri::generate_handler![
get_essentials,
get_all_software,
get_updates,
install_software
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

6
src-tauri/src/main.rs Normal file
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() {
win_softmgr_lib::run();
}

91
src-tauri/src/winget.rs Normal file
View File

@@ -0,0 +1,91 @@
use serde::{Deserialize, Serialize};
use std::process::Command;
use std::os::windows::process::CommandExt;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Software {
pub id: String,
pub name: String,
pub description: Option<String>,
pub version: Option<String>,
pub available_version: Option<String>,
pub icon_url: Option<String>,
pub status: String, // "idle", "pending", "installing", "success", "error"
pub progress: f32,
}
pub fn list_all_software() -> Vec<Software> {
// winget list
let output = Command::new("winget")
.args(["list", "--accept-source-agreements"])
.creation_flags(0x08000000) // CREATE_NO_WINDOW
.output();
match output {
Ok(out) => parse_winget_output(String::from_utf8_lossy(&out.stdout).to_string()),
Err(_) => vec![],
}
}
pub fn list_updates() -> Vec<Software> {
// winget upgrade
let output = Command::new("winget")
.args(["upgrade", "--accept-source-agreements"])
.creation_flags(0x08000000)
.output();
match output {
Ok(out) => parse_winget_output(String::from_utf8_lossy(&out.stdout).to_string()),
Err(_) => vec![],
}
}
fn parse_winget_output(output: String) -> Vec<Software> {
let mut softwares = Vec::new();
let lines: Vec<&str> = output.lines().collect();
if lines.len() < 3 {
return softwares;
}
// 查找表头行以确定列偏移量
// 通常格式: Name Id Version Available Source
let header_idx = lines.iter().position(|l| l.contains("Id") && l.contains("Name")).unwrap_or(0);
let header = lines[header_idx];
let id_pos = header.find("Id").unwrap_or(0);
let version_pos = header.find("Version").unwrap_or(0);
let available_pos = header.find("Available").unwrap_or(header.len());
let source_pos = header.find("Source").unwrap_or(header.len());
for line in &lines[header_idx + 2..] {
if line.trim().is_empty() || line.starts_with('-') {
continue;
}
if line.len() < version_pos { continue; }
let name = line[..id_pos].trim().to_string();
let id = line[id_pos..version_pos].trim().to_string();
let version = line[version_pos..available_pos.min(line.len())].trim().to_string();
let available_version = if available_pos < line.len() {
Some(line[available_pos..source_pos.min(line.len())].trim().to_string())
} else {
None
};
softwares.push(Software {
id,
name,
description: None,
version: Some(version),
available_version,
icon_url: None,
status: "idle".to_string(),
progress: 0.0,
});
}
softwares
}

35
src-tauri/tauri.conf.json Normal file
View File

@@ -0,0 +1,35 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "win-softmgr",
"version": "0.1.0",
"identifier": "top.volan.win-softmgr",
"build": {
"beforeDevCommand": "pnpm dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "pnpm build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "Windows 软件管理",
"width": 1200,
"height": 800
}
],
"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"
]
}
}

76
src/App.vue Normal file
View File

@@ -0,0 +1,76 @@
<template>
<div class="app-container">
<Sidebar />
<div class="main-content">
<router-view v-slot="{ Component }">
<transition name="fade" mode="out-in">
<component :is="Component" />
</transition>
</router-view>
</div>
</div>
</template>
<script setup lang="ts">
import Sidebar from './components/Sidebar.vue'
</script>
<style>
:root {
--primary-color: #007AFF;
--primary-hover: #0063CC;
--bg-light: #FBFBFD;
--sidebar-bg: #F8FAFD;
--text-main: #1D1D1F;
--text-sec: #86868B;
--border-color: #E5E5E7;
--card-shadow: 0 12px 30px rgba(0, 0, 0, 0.04);
--btn-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
--radius-card: 24px;
--radius-btn: 12px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background-color: var(--bg-light);
color: var(--text-main);
-webkit-font-smoothing: antialiased;
overflow: hidden;
}
.app-container {
display: flex;
height: 100vh;
width: 100vw;
overflow: hidden;
}
.main-content {
flex: 1;
height: 100vh;
overflow-y: auto;
position: relative;
}
/* 页面切换动画 */
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.2s ease, transform 0.2s ease;
}
.fade-enter-from {
opacity: 0;
transform: translateY(10px);
}
.fade-leave-to {
opacity: 0;
transform: translateY(-10px);
}
</style>

View File

@@ -0,0 +1,73 @@
<template>
<div class="sidebar">
<div class="sidebar-header">
<h2>Windows 软件管理</h2>
</div>
<nav class="sidebar-nav">
<router-link to="/essentials" class="nav-item">
<span class="nav-icon"></span>
装机必备
</router-link>
<router-link to="/updates" class="nav-item">
<span class="nav-icon">🔄</span>
软件更新
</router-link>
<router-link to="/all" class="nav-item">
<span class="nav-icon">📦</span>
全部软件
</router-link>
</nav>
</div>
</template>
<style scoped>
.sidebar {
width: 240px;
background-color: var(--sidebar-bg);
border-right: 1px solid var(--border-color);
padding: 40px 20px;
display: flex;
flex-direction: column;
}
.sidebar-header h2 {
font-size: 20px;
font-weight: 700;
margin-bottom: 40px;
padding-left: 20px;
}
.sidebar-nav {
display: flex;
flex-direction: column;
gap: 8px;
}
.nav-item {
display: flex;
align-items: center;
padding: 12px 20px;
border-radius: 12px;
color: var(--text-sec);
text-decoration: none;
font-size: 15px;
font-weight: 500;
transition: all 0.2s ease;
}
.nav-item:hover {
background-color: rgba(0, 0, 0, 0.03);
color: var(--text-main);
}
.nav-item.router-link-active {
background-color: var(--primary-color);
color: white;
box-shadow: var(--btn-shadow);
}
.nav-icon {
margin-right: 12px;
font-size: 18px;
}
</style>

View File

@@ -0,0 +1,224 @@
<template>
<div class="software-card">
<div class="card-header">
<div class="icon-container">
<img v-if="software.icon_url" :src="software.icon_url" :alt="software.name" class="software-icon" />
<div v-else class="icon-placeholder" :style="{ backgroundColor: placeholderColor }">
{{ software.name.charAt(0).toUpperCase() }}
</div>
</div>
<div class="info">
<h3 class="name">{{ software.name }}</h3>
<p class="id">{{ software.id }}</p>
</div>
</div>
<div class="card-body">
<p class="description" v-if="software.description">{{ software.description }}</p>
<div class="version-info">
<span class="version">当前: {{ software.version || '--' }}</span>
<span class="available" v-if="software.available_version">可用: {{ software.available_version }}</span>
</div>
</div>
<div class="card-actions">
<button
v-if="software.status === 'idle'"
@click="$emit('install', software.id)"
class="install-btn"
>
{{ actionLabel }}
</button>
<div v-else-if="software.status === 'installing' || software.status === 'pending'" class="progress-container">
<div class="progress-ring">
<svg viewBox="0 0 32 32">
<circle class="bg" cx="16" cy="16" r="14" fill="none" stroke-width="4" />
<circle class="fg" cx="16" cy="16" r="14" fill="none" stroke-width="4"
:style="{ strokeDasharray: 88, strokeDashoffset: 88 - (88 * (software.progress || 0.5)) }"
/>
</svg>
</div>
<span class="status-text">安装中...</span>
</div>
<div v-else-if="software.status === 'success'" class="status-success">
<span class="check-icon"></span> 已完成
</div>
<div v-else-if="software.status === 'error'" class="status-error">
失败
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue';
const props = defineProps<{
software: {
id: string;
name: string;
description?: string;
version?: string;
available_version?: string;
icon_url?: string;
status: string;
progress: number;
},
actionLabel?: string
}>();
const placeholderColor = computed(() => {
const colors = ['#FF9500', '#FF3B30', '#34C759', '#007AFF', '#5856D6', '#AF52DE'];
let hash = 0;
for (let i = 0; i < props.software.id.length; i++) {
hash = props.software.id.charCodeAt(i) + ((hash << 5) - hash);
}
return colors[Math.abs(hash) % colors.length];
});
</script>
<style scoped>
.software-card {
background: white;
border-radius: var(--radius-card);
padding: 24px;
box-shadow: var(--card-shadow);
transition: transform 0.2s ease, box-shadow 0.2s ease;
display: flex;
flex-direction: column;
gap: 16px;
border: 1px solid rgba(0, 0, 0, 0.02);
}
.software-card:hover {
transform: translateY(-4px);
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}
.card-header {
display: flex;
align-items: center;
gap: 16px;
}
.icon-container {
width: 56px;
height: 56px;
border-radius: 14px;
overflow: hidden;
flex-shrink: 0;
}
.software-icon {
width: 100%;
height: 100%;
object-fit: cover;
}
.icon-placeholder {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 24px;
font-weight: 700;
}
.info .name {
font-size: 17px;
font-weight: 600;
color: var(--text-main);
}
.info .id {
font-size: 13px;
color: var(--text-sec);
}
.card-body {
flex-grow: 1;
}
.description {
font-size: 14px;
color: var(--text-sec);
line-height: 1.5;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
margin-bottom: 8px;
}
.version-info {
display: flex;
gap: 12px;
font-size: 12px;
color: var(--text-sec);
}
.install-btn {
width: 100%;
padding: 10px;
background-color: var(--bg-light);
border: none;
border-radius: var(--radius-btn);
color: var(--primary-color);
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
}
.install-btn:hover {
background-color: var(--primary-color);
color: white;
}
.progress-container {
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
}
.progress-ring {
width: 24px;
height: 24px;
}
.progress-ring svg {
transform: rotate(-90deg);
}
.progress-ring .bg {
stroke: var(--border-color);
}
.progress-ring .fg {
stroke: var(--primary-color);
transition: stroke-dashoffset 0.3s ease;
}
.status-text {
font-size: 14px;
font-weight: 500;
color: var(--primary-color);
}
.status-success {
text-align: center;
color: #34C759;
font-weight: 600;
}
.status-error {
text-align: center;
color: #FF3B30;
font-weight: 600;
}
</style>

9
src/main.ts Normal file
View File

@@ -0,0 +1,9 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
const app = createApp(App)
app.use(createPinia())
app.use(router)
app.mount('#app')

25
src/router/index.ts Normal file
View File

@@ -0,0 +1,25 @@
import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/',
redirect: '/essentials'
},
{
path: '/essentials',
component: () => import('../views/Essentials.vue')
},
{
path: '/updates',
component: () => import('../views/Updates.vue')
},
{
path: '/all',
component: () => import('../views/AllSoftware.vue')
}
]
})
export default router

47
src/store/software.ts Normal file
View File

@@ -0,0 +1,47 @@
import { defineStore } from 'pinia'
import { invoke } from '@tauri-apps/api/core'
import { listen } from '@tauri-apps/api/event'
export const useSoftwareStore = defineStore('software', {
state: () => ({
essentials: [] as any[],
updates: [] as any[],
allSoftware: [] as any[],
loading: false
}),
actions: {
async fetchEssentials() {
this.essentials = await invoke('get_essentials')
},
async fetchUpdates() {
this.loading = true
this.updates = await invoke('get_updates')
this.loading = false
},
async fetchAll() {
this.loading = true
this.allSoftware = await invoke('get_all_software')
this.loading = false
},
async install(id: string) {
const software = this.findSoftware(id)
if (software) software.status = 'pending'
await invoke('install_software', { id })
},
findSoftware(id: string) {
return this.essentials.find(s => s.id === id) ||
this.updates.find(s => s.id === id) ||
this.allSoftware.find(s => s.id === id)
},
initListener() {
listen('install-status', (event: any) => {
const { id, status, progress } = event.payload
const software = this.findSoftware(id)
if (software) {
software.status = status
software.progress = progress
}
})
}
}
})

127
src/views/AllSoftware.vue Normal file
View File

@@ -0,0 +1,127 @@
<template>
<main class="content">
<header class="content-header">
<div class="header-left">
<h1>全部软件</h1>
<p class="count"> {{ filteredSoftware.length }} 个项目</p>
</div>
<div class="search-box">
<input
type="text"
v-model="searchQuery"
placeholder="搜索已安装的软件..."
class="search-input"
/>
</div>
</header>
<div v-if="store.loading" class="loading-state">
<div class="spinner"></div>
<p>正在读取已安装软件列表...</p>
</div>
<div v-else class="software-grid">
<SoftwareCard
v-for="item in filteredSoftware"
:key="item.id"
:software="item"
action-label="重新安装"
@install="store.install"
/>
</div>
</main>
</template>
<script setup lang="ts">
import SoftwareCard from '../components/SoftwareCard.vue';
import { useSoftwareStore } from '../store/software';
import { onMounted, ref, computed } from 'vue';
const store = useSoftwareStore();
const searchQuery = ref('');
onMounted(() => {
if (store.allSoftware.length === 0) {
store.fetchAll();
}
});
const filteredSoftware = computed(() => {
if (!searchQuery.value) return store.allSoftware;
const q = searchQuery.value.toLowerCase();
return store.allSoftware.filter(s =>
s.name.toLowerCase().includes(q) || s.id.toLowerCase().includes(q)
);
});
</script>
<style scoped>
.content {
flex: 1;
padding: 40px 60px;
overflow-y: auto;
}
.content-header {
display: flex;
justify-content: space-between;
align-items: flex-end;
margin-bottom: 40px;
}
.header-left h1 {
font-size: 34px;
font-weight: 700;
}
.header-left .count {
font-size: 15px;
color: var(--text-sec);
margin-top: 4px;
}
.search-input {
width: 300px;
padding: 12px 20px;
border-radius: 12px;
border: 1px solid var(--border-color);
background-color: white;
font-size: 15px;
outline: none;
transition: all 0.2s ease;
}
.search-input:focus {
border-color: var(--primary-color);
box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}
.software-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 24px;
}
.loading-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 300px;
color: var(--text-sec);
}
.spinner {
width: 40px;
height: 40px;
border: 4px solid rgba(0, 122, 255, 0.1);
border-top-color: var(--primary-color);
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 20px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>

84
src/views/Essentials.vue Normal file
View File

@@ -0,0 +1,84 @@
<template>
<main class="content">
<header class="content-header">
<h1>装机必备</h1>
<button @click="installAll" class="primary-btn">一键安装全部</button>
</header>
<div class="software-grid">
<SoftwareCard
v-for="item in store.essentials"
:key="item.id"
:software="item"
action-label="安装"
@install="store.install"
/>
</div>
</main>
</template>
<script setup lang="ts">
import SoftwareCard from '../components/SoftwareCard.vue';
import { useSoftwareStore } from '../store/software';
import { onMounted } from 'vue';
const store = useSoftwareStore();
onMounted(() => {
store.fetchEssentials();
store.initListener();
});
const installAll = () => {
store.essentials.forEach(s => {
if (s.status === 'idle') {
store.install(s.id);
}
});
};
</script>
<style scoped>
.content {
flex: 1;
padding: 40px 60px;
overflow-y: auto;
}
.content-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 40px;
}
.content-header h1 {
font-size: 34px;
font-weight: 700;
letter-spacing: -0.5px;
}
.primary-btn {
background-color: var(--primary-color);
color: white;
border: none;
padding: 12px 24px;
border-radius: var(--radius-btn);
font-weight: 600;
font-size: 15px;
cursor: pointer;
box-shadow: var(--btn-shadow);
transition: all 0.2s ease;
}
.primary-btn:hover {
background-color: var(--primary-hover);
transform: translateY(-1px);
}
.software-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 24px;
}
</style>

141
src/views/Updates.vue Normal file
View File

@@ -0,0 +1,141 @@
<template>
<main class="content">
<header class="content-header">
<h1>软件更新</h1>
<div class="actions">
<button @click="store.fetchUpdates" class="secondary-btn" :disabled="store.loading">
{{ store.loading ? '检查中...' : '检查更新' }}
</button>
<button @click="updateAll" class="primary-btn" :disabled="!store.updates.length">全部更新</button>
</div>
</header>
<div v-if="store.loading" class="loading-state">
<div class="spinner"></div>
<p>正在使用 Winget 扫描可用的更新...</p>
</div>
<div v-else-if="store.updates.length === 0" class="empty-state">
<span class="empty-icon"></span>
<p>所有软件已是最新版本</p>
</div>
<div v-else class="software-grid">
<SoftwareCard
v-for="item in store.updates"
:key="item.id"
:software="item"
action-label="更新"
@install="store.install"
/>
</div>
</main>
</template>
<script setup lang="ts">
import SoftwareCard from '../components/SoftwareCard.vue';
import { useSoftwareStore } from '../store/software';
import { onMounted } from 'vue';
const store = useSoftwareStore();
onMounted(() => {
if (store.updates.length === 0) {
store.fetchUpdates();
}
});
const updateAll = () => {
store.updates.forEach(s => {
if (s.status === 'idle') {
store.install(s.id);
}
});
};
</script>
<style scoped>
.content {
flex: 1;
padding: 40px 60px;
overflow-y: auto;
}
.content-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 40px;
}
.content-header h1 {
font-size: 34px;
font-weight: 700;
}
.actions {
display: flex;
gap: 12px;
}
.primary-btn, .secondary-btn {
border: none;
padding: 12px 24px;
border-radius: var(--radius-btn);
font-weight: 600;
font-size: 15px;
cursor: pointer;
transition: all 0.2s ease;
}
.primary-btn {
background-color: var(--primary-color);
color: white;
box-shadow: var(--btn-shadow);
}
.primary-btn:disabled {
background-color: var(--border-color);
box-shadow: none;
cursor: not-allowed;
}
.secondary-btn {
background-color: var(--border-color);
color: var(--text-main);
}
.software-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 24px;
}
.loading-state, .empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 300px;
color: var(--text-sec);
}
.spinner {
width: 40px;
height: 40px;
border: 4px solid rgba(0, 122, 255, 0.1);
border-top-color: var(--primary-color);
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 20px;
}
.empty-icon {
font-size: 48px;
margin-bottom: 20px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>

7
src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
/// <reference types="vite/client" />
declare module "*.vue" {
import type { DefineComponent } from "vue";
const component: DefineComponent<{}, {}, any>;
export default component;
}

25
tsconfig.json Normal file
View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}

10
tsconfig.node.json Normal file
View File

@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

32
vite.config.ts Normal file
View File

@@ -0,0 +1,32 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
// @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST;
// https://vite.dev/config/
export default defineConfig(async () => ({
plugins: [vue()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent Vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,
watch: {
// 3. tell Vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
}));