Compare commits
23 Commits
189d7c02f5
...
v0.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d42d3592bb | ||
|
|
837012d57f | ||
|
|
7cf3622294 | ||
|
|
6062a38b99 | ||
|
|
1c43a318c6 | ||
|
|
2d319b7f7a | ||
|
|
09a3465197 | ||
|
|
3478c44860 | ||
|
|
5f835731fc | ||
|
|
ac01e66d26 | ||
|
|
941e499c17 | ||
|
|
45662dc642 | ||
|
|
42905bf6d3 | ||
|
|
ee076fc9aa | ||
|
|
f9066d8e60 | ||
|
|
469b684876 | ||
|
|
d724db6f0f | ||
|
|
ad838086ed | ||
|
|
6d2b117200 | ||
|
|
b9f24e07cf | ||
|
|
9fe16cd334 | ||
|
|
a976dc3fc5 | ||
|
|
3931382f9d |
36
README.md
@@ -1,7 +1,35 @@
|
||||
# Tauri + Vue + TypeScript
|
||||
# Chrom Tool
|
||||
|
||||
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
一个 Chromium 系浏览器本地数据管理工具。
|
||||
|
||||
## Recommended IDE Setup
|
||||
## 功能
|
||||
|
||||
- [VS Code](https://code.visualstudio.com/) + [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
|
||||
- 扫描浏览器用户资料
|
||||
- 查看已安装插件,并支持删除插件
|
||||
- 查看书签,并支持删除书签
|
||||
- 查看已保存登录站点
|
||||
- 清理历史相关文件
|
||||
- `History`
|
||||
- `Top Sites`
|
||||
- `Visited Links`
|
||||
- `Sessions` 目录中的文件
|
||||
- 支持自定义浏览器路径配置
|
||||
|
||||
## 当前支持
|
||||
|
||||
- Windows
|
||||
- macOS
|
||||
|
||||
已适配的浏览器:
|
||||
|
||||
- Google Chrome
|
||||
- Microsoft Edge
|
||||
- Brave
|
||||
- Vivaldi
|
||||
- Yandex Browser
|
||||
- Chromium
|
||||
|
||||
## 说明
|
||||
|
||||
- 项目主要面向 Chromium 系浏览器本地资料目录
|
||||
- 部分删除或清理操作在浏览器运行中可能失败,建议先关闭对应浏览器
|
||||
|
||||
BIN
app-icon.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
55
app-icon.svg
Normal file
@@ -0,0 +1,55 @@
|
||||
<svg width="1024" height="1024" viewBox="0 0 1024 1024" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient id="bgGradient" x1="188" y1="132" x2="850" y2="896" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#F8FBFF"/>
|
||||
<stop offset="0.52" stop-color="#EAF2FF"/>
|
||||
<stop offset="1" stop-color="#DDECF3"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="panelGradient" x1="246" y1="214" x2="778" y2="812" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#0F2242"/>
|
||||
<stop offset="0.58" stop-color="#2454A6"/>
|
||||
<stop offset="1" stop-color="#138A8F"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="orbitGradient" x1="322" y1="346" x2="690" y2="702" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#8AD8FF"/>
|
||||
<stop offset="0.55" stop-color="#E7F4FF"/>
|
||||
<stop offset="1" stop-color="#79F0D5"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="lineGradient" x1="370" y1="334" x2="654" y2="650" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#9DD7FF"/>
|
||||
<stop offset="1" stop-color="#6DE4C7"/>
|
||||
</linearGradient>
|
||||
<filter id="shadow" x="128" y="112" width="768" height="800" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="28"/>
|
||||
<feGaussianBlur stdDeviation="32"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0.0588235 0 0 0 0 0.117647 0 0 0 0 0.25098 0 0 0 0.16 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1_1"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1_1" result="shape"/>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
<rect x="64" y="64" width="896" height="896" rx="220" fill="url(#bgGradient)"/>
|
||||
<circle cx="268" cy="232" r="168" fill="#6C91FF" fill-opacity="0.14"/>
|
||||
<circle cx="792" cy="250" r="126" fill="#10B981" fill-opacity="0.14"/>
|
||||
<circle cx="796" cy="786" r="156" fill="#2F6FED" fill-opacity="0.08"/>
|
||||
|
||||
<g filter="url(#shadow)">
|
||||
<rect x="192" y="184" width="640" height="656" rx="164" fill="url(#panelGradient)"/>
|
||||
<path d="M192 324C192 292.519 217.519 267 249 267H775C806.481 267 832 292.519 832 324V366H192V324Z" fill="white" fill-opacity="0.1"/>
|
||||
<circle cx="280" cy="316" r="16" fill="white" fill-opacity="0.85"/>
|
||||
<circle cx="338" cy="316" r="16" fill="white" fill-opacity="0.5"/>
|
||||
<circle cx="396" cy="316" r="16" fill="white" fill-opacity="0.28"/>
|
||||
|
||||
<rect x="286" y="406" width="452" height="330" rx="126" stroke="url(#orbitGradient)" stroke-width="44"/>
|
||||
<path d="M398 616L476 536L558 586L648 446" stroke="url(#lineGradient)" stroke-width="36" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<circle cx="398" cy="616" r="32" fill="#EAF6FF"/>
|
||||
<circle cx="476" cy="536" r="32" fill="#D8F7F0"/>
|
||||
<circle cx="558" cy="586" r="32" fill="#EAF6FF"/>
|
||||
<circle cx="648" cy="446" r="32" fill="#D8F7F0"/>
|
||||
|
||||
<path d="M716 650C716 687.555 685.555 718 648 718H376" stroke="white" stroke-opacity="0.22" stroke-width="18" stroke-linecap="round"/>
|
||||
<path d="M308 708H598" stroke="white" stroke-opacity="0.18" stroke-width="18" stroke-linecap="round"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
@@ -4,7 +4,7 @@
|
||||
<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>Tauri + Vue + Typescript App</title>
|
||||
<title>Chrom Tool</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
74
src-tauri/Cargo.lock
generated
@@ -8,6 +8,18 @@ version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.4"
|
||||
@@ -449,6 +461,7 @@ name = "chrom-tool"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"rusqlite",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
@@ -938,6 +951,18 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fallible-iterator"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
|
||||
|
||||
[[package]]
|
||||
name = "fallible-streaming-iterator"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.4.1"
|
||||
@@ -1446,6 +1471,15 @@ version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.5"
|
||||
@@ -1461,6 +1495,15 @@ version = "0.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51"
|
||||
|
||||
[[package]]
|
||||
name = "hashlink"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af"
|
||||
dependencies = [
|
||||
"hashbrown 0.14.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
@@ -1990,6 +2033,17 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsqlite3-sys"
|
||||
version = "0.30.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.12.1"
|
||||
@@ -3033,6 +3087,20 @@ dependencies = [
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rusqlite"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e"
|
||||
dependencies = [
|
||||
"bitflags 2.11.1",
|
||||
"fallible-iterator",
|
||||
"fallible-streaming-iterator",
|
||||
"hashlink",
|
||||
"libsqlite3-sys",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "2.1.2"
|
||||
@@ -4421,6 +4489,12 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "version-compare"
|
||||
version = "0.2.1"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[package]
|
||||
name = "chrom-tool"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
description = "A local data management tool for Chromium-based browsers."
|
||||
authors = ["julianf4r"]
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
@@ -24,4 +24,4 @@ serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
base64 = "0.22"
|
||||
tauri-plugin-dialog = "2.7.0"
|
||||
|
||||
rusqlite = { version = "0.32", features = ["bundled"] }
|
||||
|
||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 974 B After Width: | Height: | Size: 2.3 KiB |
BIN
src-tauri/icons/64x64.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 903 B After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
</adaptive-icon>
|
||||
BIN
src-tauri/icons/android/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
src-tauri/icons/android/mipmap-hdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
src-tauri/icons/android/mipmap-hdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
src-tauri/icons/android/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
src-tauri/icons/android/mipmap-mdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
src-tauri/icons/android/mipmap-mdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
src-tauri/icons/android/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
src-tauri/icons/android/mipmap-xhdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
src-tauri/icons/android/mipmap-xhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
src-tauri/icons/android/mipmap-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 65 KiB |
BIN
src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#fff</color>
|
||||
</resources>
|
||||
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 48 KiB |
BIN
src-tauri/icons/ios/AppIcon-20x20@1x.png
Normal file
|
After Width: | Height: | Size: 1014 B |
BIN
src-tauri/icons/ios/AppIcon-20x20@2x-1.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src-tauri/icons/ios/AppIcon-20x20@2x.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src-tauri/icons/ios/AppIcon-20x20@3x.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
src-tauri/icons/ios/AppIcon-29x29@1x.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
src-tauri/icons/ios/AppIcon-29x29@2x-1.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
src-tauri/icons/ios/AppIcon-29x29@2x.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
src-tauri/icons/ios/AppIcon-29x29@3x.png
Normal file
|
After Width: | Height: | Size: 8.5 KiB |
BIN
src-tauri/icons/ios/AppIcon-40x40@1x.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src-tauri/icons/ios/AppIcon-40x40@2x-1.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
src-tauri/icons/ios/AppIcon-40x40@2x.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
src-tauri/icons/ios/AppIcon-40x40@3x.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
src-tauri/icons/ios/AppIcon-512@2x.png
Normal file
|
After Width: | Height: | Size: 186 KiB |
BIN
src-tauri/icons/ios/AppIcon-60x60@2x.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
src-tauri/icons/ios/AppIcon-60x60@3x.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
src-tauri/icons/ios/AppIcon-76x76@1x.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
src-tauri/icons/ios/AppIcon-76x76@2x.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
src-tauri/icons/ios/AppIcon-83.5x83.5@2x.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
@@ -3,6 +3,60 @@ use std::{env, path::PathBuf};
|
||||
use crate::models::BrowserDefinition;
|
||||
|
||||
pub fn browser_definitions() -> Vec<BrowserDefinition> {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
return vec![
|
||||
BrowserDefinition {
|
||||
id: "chrome",
|
||||
name: "Google Chrome",
|
||||
local_app_data_segments: &["Google", "Chrome"],
|
||||
executable_candidates: &[ExecutableCandidate::Absolute(
|
||||
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
||||
)],
|
||||
},
|
||||
BrowserDefinition {
|
||||
id: "edge",
|
||||
name: "Microsoft Edge",
|
||||
local_app_data_segments: &["Microsoft Edge"],
|
||||
executable_candidates: &[ExecutableCandidate::Absolute(
|
||||
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
||||
)],
|
||||
},
|
||||
BrowserDefinition {
|
||||
id: "brave",
|
||||
name: "Brave",
|
||||
local_app_data_segments: &["BraveSoftware", "Brave-Browser"],
|
||||
executable_candidates: &[ExecutableCandidate::Absolute(
|
||||
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
|
||||
)],
|
||||
},
|
||||
BrowserDefinition {
|
||||
id: "vivaldi",
|
||||
name: "Vivaldi",
|
||||
local_app_data_segments: &["Vivaldi"],
|
||||
executable_candidates: &[ExecutableCandidate::Absolute(
|
||||
"/Applications/Vivaldi.app/Contents/MacOS/Vivaldi",
|
||||
)],
|
||||
},
|
||||
BrowserDefinition {
|
||||
id: "yandex",
|
||||
name: "Yandex Browser",
|
||||
local_app_data_segments: &["Yandex", "YandexBrowser"],
|
||||
executable_candidates: &[ExecutableCandidate::Absolute(
|
||||
"/Applications/Yandex.app/Contents/MacOS/Yandex",
|
||||
)],
|
||||
},
|
||||
BrowserDefinition {
|
||||
id: "chromium",
|
||||
name: "Chromium",
|
||||
local_app_data_segments: &["Chromium"],
|
||||
executable_candidates: &[ExecutableCandidate::Absolute(
|
||||
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
||||
)],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
vec![
|
||||
BrowserDefinition {
|
||||
id: "chrome",
|
||||
@@ -131,6 +185,8 @@ fn resolve_executable_candidate(candidate: &ExecutableCandidate) -> Option<PathB
|
||||
ExecutableCandidate::LocalAppData(segments) => env::var_os("LOCALAPPDATA")
|
||||
.map(PathBuf::from)
|
||||
.map(|root| join_segments(root, segments)),
|
||||
#[cfg(target_os = "macos")]
|
||||
ExecutableCandidate::Absolute(path) => Some(PathBuf::from(path)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,4 +201,6 @@ pub enum ExecutableCandidate {
|
||||
ProgramFiles(&'static [&'static str]),
|
||||
ProgramFilesX86(&'static [&'static str]),
|
||||
LocalAppData(&'static [&'static str]),
|
||||
#[cfg(target_os = "macos")]
|
||||
Absolute(&'static str),
|
||||
}
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
use std::{path::PathBuf, process::Command};
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
config_store,
|
||||
models::{BrowserConfigListResponse, CreateCustomBrowserConfigInput, ScanResponse},
|
||||
models::{
|
||||
BookmarkRemovalRequest, BrowserConfigListResponse, CleanupHistoryInput,
|
||||
CleanupHistoryResponse, CleanupHistoryResult, CreateCustomBrowserConfigInput,
|
||||
ExtensionInstallSourceSummary, RemoveBookmarkResult, RemoveBookmarksInput,
|
||||
RemoveBookmarksResponse, RemoveExtensionResult, RemoveExtensionsInput,
|
||||
RemoveExtensionsResponse, ScanResponse,
|
||||
},
|
||||
scanner,
|
||||
};
|
||||
use tauri::AppHandle;
|
||||
use serde_json::Value;
|
||||
|
||||
#[tauri::command]
|
||||
pub fn scan_browsers(app: AppHandle) -> Result<ScanResponse, String> {
|
||||
@@ -61,6 +72,89 @@ pub fn open_browser_profile(
|
||||
spawn_browser_process(executable_path, user_data_dir, profile_id)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn cleanup_history_files(
|
||||
app: AppHandle,
|
||||
input: CleanupHistoryInput,
|
||||
) -> Result<CleanupHistoryResponse, String> {
|
||||
let config = config_store::find_browser_config(&app, &input.browser_id)?;
|
||||
let user_data_dir = PathBuf::from(&config.user_data_path);
|
||||
|
||||
if !user_data_dir.is_dir() {
|
||||
return Err(format!(
|
||||
"User data directory does not exist: {}",
|
||||
user_data_dir.display()
|
||||
));
|
||||
}
|
||||
|
||||
let mut results = Vec::new();
|
||||
for profile_id in input.profile_ids {
|
||||
let profile_path = user_data_dir.join(&profile_id);
|
||||
let result = cleanup_profile_history_files(&profile_path, &profile_id);
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
Ok(CleanupHistoryResponse { results })
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn remove_extensions(
|
||||
app: AppHandle,
|
||||
input: RemoveExtensionsInput,
|
||||
) -> Result<RemoveExtensionsResponse, String> {
|
||||
let config = config_store::find_browser_config(&app, &input.browser_id)?;
|
||||
let user_data_dir = PathBuf::from(&config.user_data_path);
|
||||
|
||||
if !user_data_dir.is_dir() {
|
||||
return Err(format!(
|
||||
"User data directory does not exist: {}",
|
||||
user_data_dir.display()
|
||||
));
|
||||
}
|
||||
|
||||
let mut results = Vec::new();
|
||||
for removal in input.removals {
|
||||
for profile_id in removal.profile_ids {
|
||||
results.push(remove_extension_from_profile(
|
||||
&user_data_dir.join(&profile_id),
|
||||
&removal.extension_id,
|
||||
&profile_id,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(RemoveExtensionsResponse { results })
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn remove_bookmarks(
|
||||
app: AppHandle,
|
||||
input: RemoveBookmarksInput,
|
||||
) -> Result<RemoveBookmarksResponse, String> {
|
||||
let config = config_store::find_browser_config(&app, &input.browser_id)?;
|
||||
let user_data_dir = PathBuf::from(&config.user_data_path);
|
||||
|
||||
if !user_data_dir.is_dir() {
|
||||
return Err(format!(
|
||||
"User data directory does not exist: {}",
|
||||
user_data_dir.display()
|
||||
));
|
||||
}
|
||||
|
||||
let mut results = Vec::new();
|
||||
for removal in input.removals {
|
||||
for profile_id in &removal.profile_ids {
|
||||
results.push(remove_bookmark_from_profile(
|
||||
&user_data_dir.join(profile_id),
|
||||
&removal,
|
||||
profile_id,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(RemoveBookmarksResponse { results })
|
||||
}
|
||||
|
||||
fn spawn_browser_process(
|
||||
executable_path: PathBuf,
|
||||
user_data_dir: PathBuf,
|
||||
@@ -79,3 +173,454 @@ fn spawn_browser_process(
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn cleanup_profile_history_files(profile_path: &Path, profile_id: &str) -> CleanupHistoryResult {
|
||||
if !profile_path.is_dir() {
|
||||
return CleanupHistoryResult {
|
||||
profile_id: profile_id.to_string(),
|
||||
deleted_files: Vec::new(),
|
||||
skipped_files: Vec::new(),
|
||||
error: Some(format!(
|
||||
"Profile directory does not exist: {}",
|
||||
profile_path.display()
|
||||
)),
|
||||
};
|
||||
}
|
||||
|
||||
let mut deleted_files = Vec::new();
|
||||
let mut skipped_files = Vec::new();
|
||||
|
||||
for file_name in ["History", "Top Sites", "Visited Links"] {
|
||||
let file_path = profile_path.join(file_name);
|
||||
if !file_path.exists() {
|
||||
skipped_files.push(file_name.to_string());
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Err(error) = fs::remove_file(&file_path) {
|
||||
return CleanupHistoryResult {
|
||||
profile_id: profile_id.to_string(),
|
||||
deleted_files,
|
||||
skipped_files,
|
||||
error: Some(format!("Failed to delete {}: {error}", file_path.display())),
|
||||
};
|
||||
}
|
||||
|
||||
deleted_files.push(file_name.to_string());
|
||||
remove_sidecar_files(&file_path);
|
||||
}
|
||||
|
||||
let sessions_directory = profile_path.join("Sessions");
|
||||
match cleanup_sessions_directory(&sessions_directory) {
|
||||
Ok(session_deleted) => {
|
||||
if session_deleted {
|
||||
deleted_files.push("Sessions".to_string());
|
||||
} else {
|
||||
skipped_files.push("Sessions".to_string());
|
||||
}
|
||||
}
|
||||
Err(error) => {
|
||||
return CleanupHistoryResult {
|
||||
profile_id: profile_id.to_string(),
|
||||
deleted_files,
|
||||
skipped_files,
|
||||
error: Some(format!(
|
||||
"Failed to clean {}: {error}",
|
||||
sessions_directory.display()
|
||||
)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
CleanupHistoryResult {
|
||||
profile_id: profile_id.to_string(),
|
||||
deleted_files,
|
||||
skipped_files,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_extension_from_profile(
|
||||
profile_path: &Path,
|
||||
extension_id: &str,
|
||||
profile_id: &str,
|
||||
) -> RemoveExtensionResult {
|
||||
if !profile_path.is_dir() {
|
||||
return RemoveExtensionResult {
|
||||
extension_id: extension_id.to_string(),
|
||||
profile_id: profile_id.to_string(),
|
||||
removed_files: Vec::new(),
|
||||
skipped_files: Vec::new(),
|
||||
error: Some(format!(
|
||||
"Profile directory does not exist: {}",
|
||||
profile_path.display()
|
||||
)),
|
||||
};
|
||||
}
|
||||
|
||||
let secure_preferences_path = profile_path.join("Secure Preferences");
|
||||
let preferences_path = profile_path.join("Preferences");
|
||||
let mut removed_files = Vec::new();
|
||||
let mut skipped_files = Vec::new();
|
||||
|
||||
let secure_preferences_outcome =
|
||||
remove_extension_from_secure_preferences(&secure_preferences_path, extension_id);
|
||||
let install_source = match secure_preferences_outcome {
|
||||
Ok(Some(source)) => {
|
||||
removed_files.push("Secure Preferences".to_string());
|
||||
source
|
||||
}
|
||||
Ok(None) => {
|
||||
skipped_files.push("Secure Preferences".to_string());
|
||||
ExtensionInstallSourceSummary::External
|
||||
}
|
||||
Err(error) => {
|
||||
return RemoveExtensionResult {
|
||||
extension_id: extension_id.to_string(),
|
||||
profile_id: profile_id.to_string(),
|
||||
removed_files,
|
||||
skipped_files,
|
||||
error: Some(error),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
match remove_extension_from_preferences(&preferences_path, extension_id) {
|
||||
Ok(true) => removed_files.push("Preferences".to_string()),
|
||||
Ok(false) => skipped_files.push("Preferences".to_string()),
|
||||
Err(error) => {
|
||||
return RemoveExtensionResult {
|
||||
extension_id: extension_id.to_string(),
|
||||
profile_id: profile_id.to_string(),
|
||||
removed_files,
|
||||
skipped_files,
|
||||
error: Some(error),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if install_source == ExtensionInstallSourceSummary::Store {
|
||||
let extension_directory = profile_path.join("Extensions").join(extension_id);
|
||||
if extension_directory.is_dir() {
|
||||
if let Err(error) = fs::remove_dir_all(&extension_directory) {
|
||||
return RemoveExtensionResult {
|
||||
extension_id: extension_id.to_string(),
|
||||
profile_id: profile_id.to_string(),
|
||||
removed_files,
|
||||
skipped_files,
|
||||
error: Some(format!(
|
||||
"Failed to delete {}: {error}",
|
||||
extension_directory.display()
|
||||
)),
|
||||
};
|
||||
}
|
||||
removed_files.push("Extensions".to_string());
|
||||
} else {
|
||||
skipped_files.push("Extensions".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
RemoveExtensionResult {
|
||||
extension_id: extension_id.to_string(),
|
||||
profile_id: profile_id.to_string(),
|
||||
removed_files,
|
||||
skipped_files,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_bookmark_from_profile(
|
||||
profile_path: &Path,
|
||||
removal: &BookmarkRemovalRequest,
|
||||
profile_id: &str,
|
||||
) -> RemoveBookmarkResult {
|
||||
if !profile_path.is_dir() {
|
||||
return RemoveBookmarkResult {
|
||||
url: removal.url.clone(),
|
||||
profile_id: profile_id.to_string(),
|
||||
removed_count: 0,
|
||||
removed_files: Vec::new(),
|
||||
skipped_files: Vec::new(),
|
||||
error: Some(format!(
|
||||
"Profile directory does not exist: {}",
|
||||
profile_path.display()
|
||||
)),
|
||||
};
|
||||
}
|
||||
|
||||
let mut removed_files = Vec::new();
|
||||
let mut skipped_files = Vec::new();
|
||||
|
||||
let removed_backup = remove_bookmark_backups(profile_path).map_err(|error| RemoveBookmarkResult {
|
||||
url: removal.url.clone(),
|
||||
profile_id: profile_id.to_string(),
|
||||
removed_count: 0,
|
||||
removed_files: removed_files.clone(),
|
||||
skipped_files: skipped_files.clone(),
|
||||
error: Some(error),
|
||||
});
|
||||
let removed_backup = match removed_backup {
|
||||
Ok(value) => value,
|
||||
Err(result) => return result,
|
||||
};
|
||||
if removed_backup {
|
||||
removed_files.push("Bookmarks.bak".to_string());
|
||||
} else {
|
||||
skipped_files.push("Bookmarks.bak".to_string());
|
||||
}
|
||||
|
||||
let Some(bookmarks_path) = resolve_bookmarks_path(profile_path) else {
|
||||
return RemoveBookmarkResult {
|
||||
url: removal.url.clone(),
|
||||
profile_id: profile_id.to_string(),
|
||||
removed_count: 0,
|
||||
removed_files,
|
||||
skipped_files,
|
||||
error: Some(format!(
|
||||
"Bookmarks file does not exist in {}",
|
||||
profile_path.display()
|
||||
)),
|
||||
};
|
||||
};
|
||||
|
||||
let mut document = match read_json_document(&bookmarks_path) {
|
||||
Ok(document) => document,
|
||||
Err(error) => {
|
||||
return RemoveBookmarkResult {
|
||||
url: removal.url.clone(),
|
||||
profile_id: profile_id.to_string(),
|
||||
removed_count: 0,
|
||||
removed_files,
|
||||
skipped_files,
|
||||
error: Some(error),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
let checksum_removed = document
|
||||
.as_object_mut()
|
||||
.and_then(|object| object.remove("checksum"))
|
||||
.is_some();
|
||||
let removed_count = remove_matching_bookmarks(&mut document, &removal.url);
|
||||
|
||||
if checksum_removed || removed_count > 0 {
|
||||
if let Err(error) = write_json_document(&bookmarks_path, &document) {
|
||||
return RemoveBookmarkResult {
|
||||
url: removal.url.clone(),
|
||||
profile_id: profile_id.to_string(),
|
||||
removed_count: 0,
|
||||
removed_files,
|
||||
skipped_files,
|
||||
error: Some(error),
|
||||
};
|
||||
}
|
||||
removed_files.push("Bookmarks".to_string());
|
||||
} else {
|
||||
skipped_files.push("Bookmarks".to_string());
|
||||
}
|
||||
|
||||
RemoveBookmarkResult {
|
||||
url: removal.url.clone(),
|
||||
profile_id: profile_id.to_string(),
|
||||
removed_count,
|
||||
removed_files,
|
||||
skipped_files,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_extension_from_secure_preferences(
|
||||
path: &Path,
|
||||
extension_id: &str,
|
||||
) -> Result<Option<ExtensionInstallSourceSummary>, String> {
|
||||
let mut document = read_json_document(path)?;
|
||||
let install_source = document
|
||||
.get("extensions")
|
||||
.and_then(|value| value.get("settings"))
|
||||
.and_then(|value| value.get(extension_id))
|
||||
.and_then(|value| value.get("path"))
|
||||
.and_then(Value::as_str)
|
||||
.map(detect_extension_install_source)
|
||||
.unwrap_or(ExtensionInstallSourceSummary::External);
|
||||
|
||||
let mut changed = false;
|
||||
changed |= remove_object_key(
|
||||
&mut document,
|
||||
&["extensions", "settings"],
|
||||
extension_id,
|
||||
);
|
||||
changed |= remove_object_key(
|
||||
&mut document,
|
||||
&["protection", "macs", "extensions", "settings"],
|
||||
extension_id,
|
||||
);
|
||||
changed |= remove_object_key(
|
||||
&mut document,
|
||||
&["protection", "macs", "extensions", "settings_encrypted_hash"],
|
||||
extension_id,
|
||||
);
|
||||
|
||||
if changed {
|
||||
write_json_document(path, &document)?;
|
||||
Ok(Some(install_source))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_extension_from_preferences(path: &Path, extension_id: &str) -> Result<bool, String> {
|
||||
let mut document = read_json_document(path)?;
|
||||
let mut changed = false;
|
||||
|
||||
if let Some(pinned_extensions) = get_value_mut(&mut document, &["extensions", "pinned_extensions"])
|
||||
{
|
||||
if let Some(array) = pinned_extensions.as_array_mut() {
|
||||
let original_len = array.len();
|
||||
array.retain(|value| value.as_str() != Some(extension_id));
|
||||
changed |= array.len() != original_len;
|
||||
} else if let Some(object) = pinned_extensions.as_object_mut() {
|
||||
changed |= object.remove(extension_id).is_some();
|
||||
}
|
||||
}
|
||||
|
||||
if changed {
|
||||
write_json_document(path, &document)?;
|
||||
}
|
||||
|
||||
Ok(changed)
|
||||
}
|
||||
|
||||
fn detect_extension_install_source(raw_path: &str) -> ExtensionInstallSourceSummary {
|
||||
let normalized_path = raw_path.trim().trim_start_matches('/');
|
||||
if normalized_path.is_empty() {
|
||||
return ExtensionInstallSourceSummary::External;
|
||||
}
|
||||
|
||||
let candidate = PathBuf::from(normalized_path);
|
||||
if candidate.is_absolute() {
|
||||
ExtensionInstallSourceSummary::External
|
||||
} else {
|
||||
ExtensionInstallSourceSummary::Store
|
||||
}
|
||||
}
|
||||
|
||||
fn read_json_document(path: &Path) -> Result<Value, String> {
|
||||
let content = fs::read_to_string(path)
|
||||
.map_err(|error| format!("Failed to read {}: {error}", path.display()))?;
|
||||
serde_json::from_str(&content)
|
||||
.map_err(|error| format!("Failed to parse {}: {error}", path.display()))
|
||||
}
|
||||
|
||||
fn write_json_document(path: &Path, document: &Value) -> Result<(), String> {
|
||||
let content = serde_json::to_string_pretty(document)
|
||||
.map_err(|error| format!("Failed to serialize {}: {error}", path.display()))?;
|
||||
fs::write(path, content).map_err(|error| format!("Failed to write {}: {error}", path.display()))
|
||||
}
|
||||
|
||||
fn remove_object_key(document: &mut Value, object_path: &[&str], key: &str) -> bool {
|
||||
get_value_mut(document, object_path)
|
||||
.and_then(Value::as_object_mut)
|
||||
.and_then(|object| object.remove(key))
|
||||
.is_some()
|
||||
}
|
||||
|
||||
fn get_value_mut<'a>(document: &'a mut Value, path: &[&str]) -> Option<&'a mut Value> {
|
||||
let mut current = document;
|
||||
for segment in path {
|
||||
current = current.get_mut(*segment)?;
|
||||
}
|
||||
Some(current)
|
||||
}
|
||||
|
||||
fn remove_sidecar_files(path: &Path) {
|
||||
for suffix in ["-journal", "-wal", "-shm"] {
|
||||
let sidecar = PathBuf::from(format!("{}{}", path.display(), suffix));
|
||||
if sidecar.is_file() {
|
||||
let _ = fs::remove_file(sidecar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn cleanup_sessions_directory(path: &Path) -> Result<bool, std::io::Error> {
|
||||
if !path.is_dir() {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
let mut deleted_any = false;
|
||||
for entry in path.read_dir()? {
|
||||
let entry = entry?;
|
||||
let entry_path = entry.path();
|
||||
if entry_path.is_file() {
|
||||
fs::remove_file(&entry_path)?;
|
||||
deleted_any = true;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(deleted_any)
|
||||
}
|
||||
|
||||
fn remove_bookmark_backups(profile_path: &Path) -> Result<bool, String> {
|
||||
let mut deleted_any = false;
|
||||
for backup_name in ["Bookmarks.bak", "Bookmark.bak"] {
|
||||
let backup_path = profile_path.join(backup_name);
|
||||
if !backup_path.is_file() {
|
||||
continue;
|
||||
}
|
||||
fs::remove_file(&backup_path)
|
||||
.map_err(|error| format!("Failed to delete {}: {error}", backup_path.display()))?;
|
||||
deleted_any = true;
|
||||
}
|
||||
|
||||
Ok(deleted_any)
|
||||
}
|
||||
|
||||
fn resolve_bookmarks_path(profile_path: &Path) -> Option<PathBuf> {
|
||||
["Bookmarks", "Bookmark"]
|
||||
.into_iter()
|
||||
.map(|name| profile_path.join(name))
|
||||
.find(|path| path.is_file())
|
||||
}
|
||||
|
||||
fn remove_matching_bookmarks(value: &mut Value, target_url: &str) -> usize {
|
||||
match value {
|
||||
Value::Object(object) => {
|
||||
let mut removed_count = 0;
|
||||
|
||||
if let Some(children) = object.get_mut("children").and_then(Value::as_array_mut) {
|
||||
let mut index = 0;
|
||||
while index < children.len() {
|
||||
let matches_url = children[index]
|
||||
.as_object()
|
||||
.map(|child| {
|
||||
child.get("type").and_then(Value::as_str) == Some("url")
|
||||
&& child.get("url").and_then(Value::as_str) == Some(target_url)
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
if matches_url {
|
||||
children.remove(index);
|
||||
removed_count += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
removed_count += remove_matching_bookmarks(&mut children[index], target_url);
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (key, child) in object.iter_mut() {
|
||||
if key == "children" {
|
||||
continue;
|
||||
}
|
||||
removed_count += remove_matching_bookmarks(child, target_url);
|
||||
}
|
||||
|
||||
removed_count
|
||||
}
|
||||
Value::Array(array) => array
|
||||
.iter_mut()
|
||||
.map(|item| remove_matching_bookmarks(item, target_url))
|
||||
.sum(),
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::{
|
||||
BrowserConfigEntry, BrowserConfigListResponse, BrowserConfigSource,
|
||||
CreateCustomBrowserConfigInput, CustomBrowserConfigRecord, StoredBrowserConfigs,
|
||||
},
|
||||
utils::local_app_data_dir,
|
||||
utils::platform_user_data_root_dir,
|
||||
};
|
||||
|
||||
const CONFIG_FILE_NAME: &str = "browser-configs.json";
|
||||
@@ -113,8 +113,8 @@ pub fn find_browser_config(app: &AppHandle, config_id: &str) -> Result<BrowserCo
|
||||
}
|
||||
|
||||
fn default_browser_configs() -> Result<Vec<BrowserConfigEntry>, String> {
|
||||
let local_app_data = local_app_data_dir().ok_or_else(|| {
|
||||
"Unable to resolve the LOCALAPPDATA directory for the current user.".to_string()
|
||||
let user_data_root = platform_user_data_root_dir().ok_or_else(|| {
|
||||
"Unable to resolve the default browser data directory for the current user.".to_string()
|
||||
})?;
|
||||
|
||||
Ok(browser_definitions()
|
||||
@@ -123,7 +123,7 @@ fn default_browser_configs() -> Result<Vec<BrowserConfigEntry>, String> {
|
||||
let user_data_path = definition
|
||||
.local_app_data_segments
|
||||
.iter()
|
||||
.fold(local_app_data.clone(), |path, segment| path.join(segment));
|
||||
.fold(user_data_root.clone(), |path, segment| path.join(segment));
|
||||
|
||||
BrowserConfigEntry {
|
||||
id: definition.id.to_string(),
|
||||
|
||||
@@ -15,7 +15,10 @@ pub fn run() {
|
||||
commands::list_browser_configs,
|
||||
commands::create_custom_browser_config,
|
||||
commands::delete_custom_browser_config,
|
||||
commands::open_browser_profile
|
||||
commands::open_browser_profile,
|
||||
commands::cleanup_history_files,
|
||||
commands::remove_extensions,
|
||||
commands::remove_bookmarks
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
@@ -19,6 +19,7 @@ pub struct BrowserView {
|
||||
pub profiles: Vec<ProfileSummary>,
|
||||
pub extensions: Vec<ExtensionSummary>,
|
||||
pub bookmarks: Vec<BookmarkSummary>,
|
||||
pub password_sites: Vec<PasswordSiteSummary>,
|
||||
pub stats: BrowserStats,
|
||||
}
|
||||
|
||||
@@ -28,6 +29,8 @@ pub struct BrowserStats {
|
||||
pub profile_count: usize,
|
||||
pub extension_count: usize,
|
||||
pub bookmark_count: usize,
|
||||
pub password_site_count: usize,
|
||||
pub history_cleanup_profile_count: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -42,6 +45,7 @@ pub struct ProfileSummary {
|
||||
pub default_avatar_stroke_color: Option<i64>,
|
||||
pub avatar_label: String,
|
||||
pub path: String,
|
||||
pub history_cleanup: HistoryCleanupSummary,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -52,7 +56,7 @@ pub struct ExtensionSummary {
|
||||
pub version: Option<String>,
|
||||
pub icon_data_url: Option<String>,
|
||||
pub profile_ids: Vec<String>,
|
||||
pub profiles: Vec<AssociatedProfileSummary>,
|
||||
pub profiles: Vec<ExtensionAssociatedProfileSummary>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -64,6 +68,114 @@ pub struct BookmarkSummary {
|
||||
pub profiles: Vec<BookmarkAssociatedProfileSummary>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PasswordSiteSummary {
|
||||
pub url: String,
|
||||
pub domain: String,
|
||||
pub profile_ids: Vec<String>,
|
||||
pub profiles: Vec<AssociatedProfileSummary>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct HistoryCleanupSummary {
|
||||
pub history: CleanupFileStatus,
|
||||
pub top_sites: CleanupFileStatus,
|
||||
pub visited_links: CleanupFileStatus,
|
||||
pub sessions: CleanupFileStatus,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum CleanupFileStatus {
|
||||
Found,
|
||||
Missing,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CleanupHistoryInput {
|
||||
pub browser_id: String,
|
||||
pub profile_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CleanupHistoryResponse {
|
||||
pub results: Vec<CleanupHistoryResult>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CleanupHistoryResult {
|
||||
pub profile_id: String,
|
||||
pub deleted_files: Vec<String>,
|
||||
pub skipped_files: Vec<String>,
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RemoveExtensionsInput {
|
||||
pub browser_id: String,
|
||||
pub removals: Vec<ExtensionRemovalRequest>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RemoveBookmarksInput {
|
||||
pub browser_id: String,
|
||||
pub removals: Vec<BookmarkRemovalRequest>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExtensionRemovalRequest {
|
||||
pub extension_id: String,
|
||||
pub profile_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BookmarkRemovalRequest {
|
||||
pub url: String,
|
||||
pub profile_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RemoveExtensionsResponse {
|
||||
pub results: Vec<RemoveExtensionResult>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RemoveBookmarksResponse {
|
||||
pub results: Vec<RemoveBookmarkResult>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RemoveExtensionResult {
|
||||
pub extension_id: String,
|
||||
pub profile_id: String,
|
||||
pub removed_files: Vec<String>,
|
||||
pub skipped_files: Vec<String>,
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RemoveBookmarkResult {
|
||||
pub url: String,
|
||||
pub profile_id: String,
|
||||
pub removed_count: usize,
|
||||
pub removed_files: Vec<String>,
|
||||
pub skipped_files: Vec<String>,
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AssociatedProfileSummary {
|
||||
@@ -76,6 +188,26 @@ pub struct AssociatedProfileSummary {
|
||||
pub avatar_label: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExtensionAssociatedProfileSummary {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub avatar_data_url: Option<String>,
|
||||
pub avatar_icon: Option<String>,
|
||||
pub default_avatar_fill_color: Option<i64>,
|
||||
pub default_avatar_stroke_color: Option<i64>,
|
||||
pub avatar_label: String,
|
||||
pub install_source: ExtensionInstallSourceSummary,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum ExtensionInstallSourceSummary {
|
||||
Store,
|
||||
External,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BookmarkAssociatedProfileSummary {
|
||||
@@ -156,7 +288,7 @@ pub struct TempExtension {
|
||||
pub version: Option<String>,
|
||||
pub icon_data_url: Option<String>,
|
||||
pub profile_ids: BTreeSet<String>,
|
||||
pub profiles: BTreeMap<String, AssociatedProfileSummary>,
|
||||
pub profiles: BTreeMap<String, ExtensionAssociatedProfileSummary>,
|
||||
}
|
||||
|
||||
pub struct TempBookmark {
|
||||
@@ -165,3 +297,10 @@ pub struct TempBookmark {
|
||||
pub profile_ids: BTreeSet<String>,
|
||||
pub profiles: BTreeMap<String, BookmarkAssociatedProfileSummary>,
|
||||
}
|
||||
|
||||
pub struct TempPasswordSite {
|
||||
pub url: String,
|
||||
pub domain: String,
|
||||
pub profile_ids: BTreeSet<String>,
|
||||
pub profiles: BTreeMap<String, AssociatedProfileSummary>,
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use rusqlite::{Connection, OpenFlags};
|
||||
use serde_json::Value;
|
||||
use tauri::AppHandle;
|
||||
|
||||
@@ -10,10 +11,14 @@ use crate::{
|
||||
config_store,
|
||||
models::{
|
||||
AssociatedProfileSummary, BookmarkAssociatedProfileSummary, BookmarkSummary,
|
||||
BrowserConfigEntry, BrowserStats, BrowserView, ExtensionSummary, ProfileSummary,
|
||||
ScanResponse, TempBookmark, TempExtension,
|
||||
BrowserConfigEntry, BrowserStats, BrowserView, CleanupFileStatus, ExtensionSummary,
|
||||
ExtensionAssociatedProfileSummary, ExtensionInstallSourceSummary, HistoryCleanupSummary,
|
||||
PasswordSiteSummary, ProfileSummary, ScanResponse, TempBookmark, TempExtension,
|
||||
TempPasswordSite,
|
||||
},
|
||||
utils::{
|
||||
copy_sqlite_database_to_temp, first_non_empty, load_image_as_data_url, read_json_file,
|
||||
},
|
||||
utils::{first_non_empty, load_image_as_data_url, read_json_file},
|
||||
};
|
||||
|
||||
pub fn scan_browsers(app: &AppHandle) -> Result<ScanResponse, String> {
|
||||
@@ -43,6 +48,7 @@ fn scan_browser(config: BrowserConfigEntry) -> Option<BrowserView> {
|
||||
let mut profiles = Vec::new();
|
||||
let mut extensions = BTreeMap::<String, TempExtension>::new();
|
||||
let mut bookmarks = BTreeMap::<String, TempBookmark>::new();
|
||||
let mut password_sites = BTreeMap::<String, TempPasswordSite>::new();
|
||||
|
||||
for profile_id in profile_ids {
|
||||
let profile_path = root.join(&profile_id);
|
||||
@@ -51,14 +57,11 @@ fn scan_browser(config: BrowserConfigEntry) -> Option<BrowserView> {
|
||||
}
|
||||
|
||||
let profile_info = profile_cache.and_then(|cache| cache.get(&profile_id));
|
||||
let profile_summary = build_profile_summary(
|
||||
&root,
|
||||
&profile_path,
|
||||
&profile_id,
|
||||
profile_info,
|
||||
);
|
||||
let profile_summary =
|
||||
build_profile_summary(&root, &profile_path, &profile_id, profile_info);
|
||||
scan_extensions_for_profile(&profile_path, &profile_summary, &mut extensions);
|
||||
scan_bookmarks_for_profile(&profile_path, &profile_summary, &mut bookmarks);
|
||||
scan_password_sites_for_profile(&profile_path, &profile_summary, &mut password_sites);
|
||||
profiles.push(profile_summary);
|
||||
}
|
||||
|
||||
@@ -83,6 +86,25 @@ fn scan_browser(config: BrowserConfigEntry) -> Option<BrowserView> {
|
||||
profiles: entry.profiles.into_values().collect(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let password_sites = password_sites
|
||||
.into_values()
|
||||
.map(|entry| PasswordSiteSummary {
|
||||
url: entry.url,
|
||||
domain: entry.domain,
|
||||
profile_ids: entry.profile_ids.into_iter().collect(),
|
||||
profiles: entry.profiles.into_values().collect(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let history_cleanup_profile_count = profiles
|
||||
.iter()
|
||||
.filter(|profile| {
|
||||
let cleanup = &profile.history_cleanup;
|
||||
cleanup.history == CleanupFileStatus::Found
|
||||
|| cleanup.top_sites == CleanupFileStatus::Found
|
||||
|| cleanup.visited_links == CleanupFileStatus::Found
|
||||
|| cleanup.sessions == CleanupFileStatus::Found
|
||||
})
|
||||
.count();
|
||||
|
||||
Some(BrowserView {
|
||||
browser_id: config.id,
|
||||
@@ -94,10 +116,13 @@ fn scan_browser(config: BrowserConfigEntry) -> Option<BrowserView> {
|
||||
profile_count: profiles.len(),
|
||||
extension_count: extensions.len(),
|
||||
bookmark_count: bookmarks.len(),
|
||||
password_site_count: password_sites.len(),
|
||||
history_cleanup_profile_count,
|
||||
},
|
||||
profiles,
|
||||
extensions: sort_extensions(extensions),
|
||||
bookmarks: sort_bookmarks(bookmarks),
|
||||
password_sites: sort_password_sites(password_sites),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -163,6 +188,36 @@ fn build_profile_summary(
|
||||
default_avatar_stroke_color,
|
||||
avatar_label,
|
||||
path: profile_path.display().to_string(),
|
||||
history_cleanup: scan_history_cleanup_status(profile_path),
|
||||
}
|
||||
}
|
||||
|
||||
fn scan_history_cleanup_status(profile_path: &Path) -> HistoryCleanupSummary {
|
||||
HistoryCleanupSummary {
|
||||
history: cleanup_file_status(&profile_path.join("History")),
|
||||
top_sites: cleanup_file_status(&profile_path.join("Top Sites")),
|
||||
visited_links: cleanup_file_status(&profile_path.join("Visited Links")),
|
||||
sessions: cleanup_sessions_status(&profile_path.join("Sessions")),
|
||||
}
|
||||
}
|
||||
|
||||
fn cleanup_file_status(path: &Path) -> CleanupFileStatus {
|
||||
if path.is_file() {
|
||||
CleanupFileStatus::Found
|
||||
} else {
|
||||
CleanupFileStatus::Missing
|
||||
}
|
||||
}
|
||||
|
||||
fn cleanup_sessions_status(path: &Path) -> CleanupFileStatus {
|
||||
let Ok(entries) = path.read_dir() else {
|
||||
return CleanupFileStatus::Missing;
|
||||
};
|
||||
|
||||
if entries.flatten().any(|entry| entry.path().is_file()) {
|
||||
CleanupFileStatus::Found
|
||||
} else {
|
||||
CleanupFileStatus::Missing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +313,7 @@ fn scan_extensions_for_profile(
|
||||
entry
|
||||
.profiles
|
||||
.entry(profile.id.clone())
|
||||
.or_insert_with(|| AssociatedProfileSummary {
|
||||
.or_insert_with(|| ExtensionAssociatedProfileSummary {
|
||||
id: profile.id.clone(),
|
||||
name: profile.name.clone(),
|
||||
avatar_data_url: profile.avatar_data_url.clone(),
|
||||
@@ -266,6 +321,7 @@ fn scan_extensions_for_profile(
|
||||
default_avatar_fill_color: profile.default_avatar_fill_color,
|
||||
default_avatar_stroke_color: profile.default_avatar_stroke_color,
|
||||
avatar_label: profile.avatar_label.clone(),
|
||||
install_source: install_source.summary(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -291,7 +347,10 @@ fn resolve_extension_install_dir(
|
||||
} else if candidate.is_absolute() {
|
||||
(candidate, ExtensionInstallSource::ExternalAbsolute)
|
||||
} else {
|
||||
(PathBuf::from(raw_path), ExtensionInstallSource::ExternalAbsolute)
|
||||
(
|
||||
PathBuf::from(raw_path),
|
||||
ExtensionInstallSource::ExternalAbsolute,
|
||||
)
|
||||
};
|
||||
|
||||
resolved.is_dir().then_some((resolved, source))
|
||||
@@ -302,6 +361,15 @@ enum ExtensionInstallSource {
|
||||
ExternalAbsolute,
|
||||
}
|
||||
|
||||
impl ExtensionInstallSource {
|
||||
fn summary(&self) -> ExtensionInstallSourceSummary {
|
||||
match self {
|
||||
ExtensionInstallSource::StoreRelative => ExtensionInstallSourceSummary::Store,
|
||||
ExtensionInstallSource::ExternalAbsolute => ExtensionInstallSourceSummary::External,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_extension_name(manifest: &Value, version_path: &Path) -> Option<String> {
|
||||
let raw_name = manifest.get("name").and_then(Value::as_str)?;
|
||||
if let Some(localized_name) = resolve_localized_manifest_value(raw_name, manifest, version_path)
|
||||
@@ -451,10 +519,8 @@ fn collect_bookmarks(
|
||||
} else {
|
||||
ancestors.join(" > ")
|
||||
};
|
||||
entry
|
||||
.profiles
|
||||
.entry(profile.id.clone())
|
||||
.or_insert_with(|| BookmarkAssociatedProfileSummary {
|
||||
entry.profiles.entry(profile.id.clone()).or_insert_with(|| {
|
||||
BookmarkAssociatedProfileSummary {
|
||||
id: profile.id.clone(),
|
||||
name: profile.name.clone(),
|
||||
avatar_data_url: profile.avatar_data_url.clone(),
|
||||
@@ -463,7 +529,8 @@ fn collect_bookmarks(
|
||||
default_avatar_stroke_color: profile.default_avatar_stroke_color,
|
||||
avatar_label: profile.avatar_label.clone(),
|
||||
bookmark_path,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Some("folder") => {
|
||||
if let Some(children) = node.get("children").and_then(Value::as_array) {
|
||||
@@ -526,3 +593,103 @@ fn sort_bookmarks(mut bookmarks: Vec<BookmarkSummary>) -> Vec<BookmarkSummary> {
|
||||
});
|
||||
bookmarks
|
||||
}
|
||||
|
||||
fn scan_password_sites_for_profile(
|
||||
profile_path: &Path,
|
||||
profile: &ProfileSummary,
|
||||
password_sites: &mut BTreeMap<String, TempPasswordSite>,
|
||||
) {
|
||||
let login_data_path = profile_path.join("Login Data");
|
||||
if !login_data_path.is_file() {
|
||||
return;
|
||||
}
|
||||
|
||||
let Some(temp_copy) = copy_sqlite_database_to_temp(&login_data_path) else {
|
||||
return;
|
||||
};
|
||||
let Ok(connection) = Connection::open_with_flags(
|
||||
temp_copy.path(),
|
||||
OpenFlags::SQLITE_OPEN_READ_ONLY | OpenFlags::SQLITE_OPEN_NO_MUTEX,
|
||||
) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Ok(mut statement) = connection
|
||||
.prepare("SELECT origin_url, signon_realm FROM logins WHERE blacklisted_by_user = 0")
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(rows) = statement.query_map([], |row| {
|
||||
Ok((
|
||||
row.get::<_, Option<String>>(0)?,
|
||||
row.get::<_, Option<String>>(1)?,
|
||||
))
|
||||
}) else {
|
||||
return;
|
||||
};
|
||||
|
||||
for row in rows.flatten() {
|
||||
let Some(url) = normalize_login_site(row.0.as_deref(), row.1.as_deref()) else {
|
||||
continue;
|
||||
};
|
||||
let domain = domain_from_url(&url).unwrap_or_else(|| url.clone());
|
||||
|
||||
let entry = password_sites
|
||||
.entry(url.clone())
|
||||
.or_insert_with(|| TempPasswordSite {
|
||||
url: url.clone(),
|
||||
domain: domain.clone(),
|
||||
profile_ids: BTreeSet::new(),
|
||||
profiles: BTreeMap::new(),
|
||||
});
|
||||
|
||||
if entry.domain == entry.url && domain != entry.url {
|
||||
entry.domain = domain.clone();
|
||||
}
|
||||
entry.profile_ids.insert(profile.id.clone());
|
||||
entry
|
||||
.profiles
|
||||
.entry(profile.id.clone())
|
||||
.or_insert_with(|| AssociatedProfileSummary {
|
||||
id: profile.id.clone(),
|
||||
name: profile.name.clone(),
|
||||
avatar_data_url: profile.avatar_data_url.clone(),
|
||||
avatar_icon: profile.avatar_icon.clone(),
|
||||
default_avatar_fill_color: profile.default_avatar_fill_color,
|
||||
default_avatar_stroke_color: profile.default_avatar_stroke_color,
|
||||
avatar_label: profile.avatar_label.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn normalize_login_site(origin_url: Option<&str>, signon_realm: Option<&str>) -> Option<String> {
|
||||
let candidate = [signon_realm, origin_url]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(str::trim)
|
||||
.find(|value| {
|
||||
!value.is_empty() && (value.starts_with("http://") || value.starts_with("https://"))
|
||||
})?;
|
||||
|
||||
Some(candidate.to_string())
|
||||
}
|
||||
|
||||
fn domain_from_url(url: &str) -> Option<String> {
|
||||
let (_, remainder) = url.split_once("://")?;
|
||||
let host = remainder.split('/').next()?.trim();
|
||||
if host.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(host.to_string())
|
||||
}
|
||||
|
||||
fn sort_password_sites(mut password_sites: Vec<PasswordSiteSummary>) -> Vec<PasswordSiteSummary> {
|
||||
password_sites.sort_by(|left, right| {
|
||||
left.domain
|
||||
.to_lowercase()
|
||||
.cmp(&right.domain.to_lowercase())
|
||||
.then_with(|| left.url.cmp(&right.url))
|
||||
});
|
||||
password_sites
|
||||
}
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
use std::{
|
||||
env, fs,
|
||||
path::{Path, PathBuf},
|
||||
process,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use base64::{engine::general_purpose::STANDARD, Engine as _};
|
||||
use serde_json::Value;
|
||||
|
||||
pub fn local_app_data_dir() -> Option<PathBuf> {
|
||||
pub fn platform_user_data_root_dir() -> Option<PathBuf> {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
return env::var_os("HOME")
|
||||
.map(PathBuf::from)
|
||||
.map(|path| path.join("Library").join("Application Support"));
|
||||
}
|
||||
|
||||
env::var_os("LOCALAPPDATA").map(PathBuf::from).or_else(|| {
|
||||
env::var_os("USERPROFILE")
|
||||
.map(PathBuf::from)
|
||||
@@ -46,3 +55,48 @@ pub fn first_non_empty<'a>(values: impl IntoIterator<Item = Option<&'a str>>) ->
|
||||
.flatten()
|
||||
.find(|value| !value.trim().is_empty())
|
||||
}
|
||||
|
||||
pub struct TempSqliteCopy {
|
||||
path: PathBuf,
|
||||
directory: PathBuf,
|
||||
}
|
||||
|
||||
impl TempSqliteCopy {
|
||||
pub fn path(&self) -> &Path {
|
||||
&self.path
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TempSqliteCopy {
|
||||
fn drop(&mut self) {
|
||||
let _ = fs::remove_dir_all(&self.directory);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_sqlite_database_to_temp(path: &Path) -> Option<TempSqliteCopy> {
|
||||
let file_name = path.file_name()?.to_str()?;
|
||||
let unique_id = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.ok()?
|
||||
.as_nanos();
|
||||
let directory =
|
||||
env::temp_dir().join(format!("chrom-tool-scan-{}-{}", process::id(), unique_id));
|
||||
|
||||
fs::create_dir_all(&directory).ok()?;
|
||||
|
||||
let main_target = directory.join(file_name);
|
||||
fs::copy(path, &main_target).ok()?;
|
||||
|
||||
for suffix in ["-wal", "-shm"] {
|
||||
let source = PathBuf::from(format!("{}{}", path.display(), suffix));
|
||||
if source.is_file() {
|
||||
let target = directory.join(format!("{file_name}{suffix}"));
|
||||
let _ = fs::copy(source, target);
|
||||
}
|
||||
}
|
||||
|
||||
Some(TempSqliteCopy {
|
||||
path: main_target,
|
||||
directory,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "Browser Assistant",
|
||||
"title": "浏览器助手",
|
||||
"width": 1400,
|
||||
"height": 900,
|
||||
"minWidth": 1100,
|
||||
|
||||
148
src/App.vue
@@ -4,10 +4,20 @@ import ConfigurationView from "./components/config/ConfigurationView.vue";
|
||||
import AppSidebar from "./components/sidebar/AppSidebar.vue";
|
||||
import { useBrowserManager } from "./composables/useBrowserManager";
|
||||
|
||||
const appVersion = __APP_VERSION__;
|
||||
|
||||
const {
|
||||
activeSection,
|
||||
associatedProfilesModal,
|
||||
bookmarkSortKey,
|
||||
bookmarkDeleteBusy,
|
||||
bookmarkModalSelectedProfileIds,
|
||||
bookmarkRemovalConfirmBookmarkCount,
|
||||
bookmarkRemovalConfirmProfileCount,
|
||||
bookmarkRemovalError,
|
||||
bookmarkRemovalResultOpen,
|
||||
bookmarkRemovalResults,
|
||||
bookmarkSelectedUrls,
|
||||
browserConfigs,
|
||||
browserMonogram,
|
||||
browsers,
|
||||
@@ -16,12 +26,38 @@ const {
|
||||
configsLoading,
|
||||
createConfigForm,
|
||||
createCustomBrowserConfig,
|
||||
deleteBookmarkFromAllProfiles,
|
||||
deleteBookmarkFromProfile,
|
||||
cleanupHistoryError,
|
||||
cleanupHistoryForProfile,
|
||||
cleanupHistoryResults,
|
||||
cleanupHistorySelectedProfiles,
|
||||
cleanupSelectedHistoryProfiles,
|
||||
closeHistoryCleanupConfirm,
|
||||
closeHistoryCleanupResult,
|
||||
confirmHistoryCleanup,
|
||||
currentBrowser,
|
||||
deleteCustomBrowserConfig,
|
||||
domainFromUrl,
|
||||
deleteSelectedBookmarkProfiles,
|
||||
deleteSelectedBookmarks,
|
||||
deleteExtensionFromAllProfiles,
|
||||
deleteExtensionFromProfile,
|
||||
deleteSelectedExtensionProfiles,
|
||||
deleteSelectedExtensions,
|
||||
error,
|
||||
extensionMonogram,
|
||||
extensionDeleteBusy,
|
||||
extensionModalSelectedProfileIds,
|
||||
extensionRemovalConfirmExtensions,
|
||||
extensionRemovalConfirmProfiles,
|
||||
extensionRemovalError,
|
||||
extensionRemovalResultOpen,
|
||||
extensionRemovalResults,
|
||||
extensionSelectedIds,
|
||||
extensionSortKey,
|
||||
historyCleanupBusy,
|
||||
historyCleanupConfirmProfiles,
|
||||
historyCleanupResultOpen,
|
||||
isDeletingConfig,
|
||||
isOpeningProfile,
|
||||
loading,
|
||||
@@ -30,16 +66,35 @@ const {
|
||||
page,
|
||||
pickExecutablePath,
|
||||
pickUserDataPath,
|
||||
passwordSiteSortKey,
|
||||
profileSortKey,
|
||||
refreshAll,
|
||||
savingConfig,
|
||||
sectionCount,
|
||||
selectedBrowserId,
|
||||
closeBookmarkRemovalConfirm,
|
||||
closeBookmarkRemovalResult,
|
||||
showBookmarkProfilesModal,
|
||||
showExtensionProfilesModal,
|
||||
showPasswordSiteProfilesModal,
|
||||
sortedBookmarks,
|
||||
sortedExtensions,
|
||||
sortedPasswordSites,
|
||||
sortedProfiles,
|
||||
confirmBookmarkRemoval,
|
||||
closeExtensionRemovalConfirm,
|
||||
closeExtensionRemovalResult,
|
||||
confirmExtensionRemoval,
|
||||
toggleAllBookmarks,
|
||||
toggleAllBookmarkModalProfiles,
|
||||
toggleAllExtensions,
|
||||
toggleBookmarkModalProfileSelection,
|
||||
toggleBookmarkSelection,
|
||||
toggleAllExtensionModalProfiles,
|
||||
toggleExtensionModalProfileSelection,
|
||||
toggleExtensionSelection,
|
||||
toggleAllHistoryProfiles,
|
||||
toggleHistoryProfile,
|
||||
closeAssociatedProfilesModal,
|
||||
} = useBrowserManager();
|
||||
</script>
|
||||
@@ -53,6 +108,7 @@ const {
|
||||
:loading="loading"
|
||||
:configs-loading="configsLoading"
|
||||
:browser-monogram="browserMonogram"
|
||||
:app-version="appVersion"
|
||||
@select-browser="selectedBrowserId = $event; page = 'browserData'"
|
||||
@select-configuration="page = 'configuration'"
|
||||
@refresh="refreshAll"
|
||||
@@ -80,17 +136,33 @@ const {
|
||||
</template>
|
||||
|
||||
<template v-else-if="loading">
|
||||
<section class="state-panel">
|
||||
<p class="eyebrow">Scanning</p>
|
||||
<h2>Reading local browser data</h2>
|
||||
<p>Profiles, installed extensions, and bookmarks are being collected.</p>
|
||||
<section class="state-panel scanning-panel">
|
||||
<div class="scan-hero" aria-hidden="true">
|
||||
<div class="scan-orbit orbit-one"></div>
|
||||
<div class="scan-orbit orbit-two"></div>
|
||||
<div class="scan-core">
|
||||
<div class="scan-core-ring"></div>
|
||||
<div class="scan-core-ring secondary"></div>
|
||||
<div class="scan-dot dot-one"></div>
|
||||
<div class="scan-dot dot-two"></div>
|
||||
<div class="scan-dot dot-three"></div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="eyebrow">扫描中</p>
|
||||
<h2>正在读取本地浏览器数据</h2>
|
||||
<p>正在收集用户资料、插件、书签和已保存登录站点。</p>
|
||||
<div class="loading-steps" aria-hidden="true">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<template v-else-if="error">
|
||||
<section class="state-panel error">
|
||||
<p class="eyebrow">Error</p>
|
||||
<h2>Scan failed</h2>
|
||||
<p class="eyebrow">错误</p>
|
||||
<h2>扫描失败</h2>
|
||||
<p>{{ error }}</p>
|
||||
</section>
|
||||
</template>
|
||||
@@ -102,30 +174,84 @@ const {
|
||||
:profile-sort-key="profileSortKey"
|
||||
:extension-sort-key="extensionSortKey"
|
||||
:bookmark-sort-key="bookmarkSortKey"
|
||||
:password-site-sort-key="passwordSiteSortKey"
|
||||
:sorted-profiles="sortedProfiles"
|
||||
:sorted-extensions="sortedExtensions"
|
||||
:sorted-bookmarks="sortedBookmarks"
|
||||
:sorted-password-sites="sortedPasswordSites"
|
||||
:history-selected-profile-ids="cleanupHistorySelectedProfiles"
|
||||
:cleanup-history-busy="historyCleanupBusy"
|
||||
:history-cleanup-confirm-profiles="historyCleanupConfirmProfiles"
|
||||
:history-cleanup-result-open="historyCleanupResultOpen"
|
||||
:cleanup-history-error="cleanupHistoryError"
|
||||
:cleanup-history-results="cleanupHistoryResults"
|
||||
:bookmark-selected-urls="bookmarkSelectedUrls"
|
||||
:bookmark-modal-selected-profile-ids="bookmarkModalSelectedProfileIds"
|
||||
:bookmark-delete-busy="bookmarkDeleteBusy"
|
||||
:bookmark-removal-confirm-bookmark-count="bookmarkRemovalConfirmBookmarkCount"
|
||||
:bookmark-removal-confirm-profile-count="bookmarkRemovalConfirmProfileCount"
|
||||
:bookmark-removal-result-open="bookmarkRemovalResultOpen"
|
||||
:bookmark-removal-error="bookmarkRemovalError"
|
||||
:bookmark-removal-results="bookmarkRemovalResults"
|
||||
:extension-selected-ids="extensionSelectedIds"
|
||||
:extension-modal-selected-profile-ids="extensionModalSelectedProfileIds"
|
||||
:extension-delete-busy="extensionDeleteBusy"
|
||||
:extension-removal-confirm-extensions="extensionRemovalConfirmExtensions"
|
||||
:extension-removal-confirm-profiles="extensionRemovalConfirmProfiles"
|
||||
:extension-removal-result-open="extensionRemovalResultOpen"
|
||||
:extension-removal-error="extensionRemovalError"
|
||||
:extension-removal-results="extensionRemovalResults"
|
||||
:open-profile-error="openProfileError"
|
||||
:section-count="sectionCount"
|
||||
:is-opening-profile="isOpeningProfile"
|
||||
:extension-monogram="extensionMonogram"
|
||||
:domain-from-url="domainFromUrl"
|
||||
:associated-profiles-modal="associatedProfilesModal"
|
||||
@update:active-section="activeSection = $event"
|
||||
@update:profile-sort-key="profileSortKey = $event"
|
||||
@update:extension-sort-key="extensionSortKey = $event"
|
||||
@update:bookmark-sort-key="bookmarkSortKey = $event"
|
||||
@update:password-site-sort-key="passwordSiteSortKey = $event"
|
||||
@open-profile="(browserId, profileId) => openBrowserProfile(browserId, profileId)"
|
||||
@show-extension-profiles="showExtensionProfilesModal"
|
||||
@show-bookmark-profiles="showBookmarkProfilesModal"
|
||||
@show-password-site-profiles="showPasswordSiteProfilesModal"
|
||||
@toggle-bookmark-selection="toggleBookmarkSelection"
|
||||
@toggle-all-bookmarks="toggleAllBookmarks"
|
||||
@delete-bookmark-from-all-profiles="deleteBookmarkFromAllProfiles"
|
||||
@delete-selected-bookmarks="deleteSelectedBookmarks"
|
||||
@toggle-bookmark-modal-profile-selection="toggleBookmarkModalProfileSelection"
|
||||
@toggle-all-bookmark-modal-profiles="toggleAllBookmarkModalProfiles"
|
||||
@delete-bookmark-from-profile="deleteBookmarkFromProfile"
|
||||
@delete-selected-bookmark-profiles="deleteSelectedBookmarkProfiles"
|
||||
@confirm-bookmark-removal="confirmBookmarkRemoval"
|
||||
@close-bookmark-removal-confirm="closeBookmarkRemovalConfirm"
|
||||
@close-bookmark-removal-result="closeBookmarkRemovalResult"
|
||||
@toggle-extension-selection="toggleExtensionSelection"
|
||||
@toggle-all-extensions="toggleAllExtensions"
|
||||
@delete-extension-from-all-profiles="deleteExtensionFromAllProfiles"
|
||||
@delete-selected-extensions="deleteSelectedExtensions"
|
||||
@toggle-extension-modal-profile-selection="toggleExtensionModalProfileSelection"
|
||||
@toggle-all-extension-modal-profiles="toggleAllExtensionModalProfiles"
|
||||
@delete-extension-from-profile="deleteExtensionFromProfile"
|
||||
@delete-selected-extension-profiles="deleteSelectedExtensionProfiles"
|
||||
@confirm-extension-removal="confirmExtensionRemoval"
|
||||
@close-extension-removal-confirm="closeExtensionRemovalConfirm"
|
||||
@close-extension-removal-result="closeExtensionRemovalResult"
|
||||
@toggle-history-profile="toggleHistoryProfile"
|
||||
@toggle-all-history-profiles="toggleAllHistoryProfiles"
|
||||
@cleanup-selected-history="cleanupSelectedHistoryProfiles"
|
||||
@cleanup-history-for-profile="cleanupHistoryForProfile"
|
||||
@confirm-history-cleanup="confirmHistoryCleanup"
|
||||
@close-history-cleanup-confirm="closeHistoryCleanupConfirm"
|
||||
@close-history-cleanup-result="closeHistoryCleanupResult"
|
||||
@close-associated-profiles="closeAssociatedProfilesModal"
|
||||
/>
|
||||
|
||||
<template v-else>
|
||||
<section class="state-panel">
|
||||
<p class="eyebrow">No Data</p>
|
||||
<h2>No supported browser was detected</h2>
|
||||
<p>Install or sign in to Chrome, Edge, or Brave and refresh the scan.</p>
|
||||
<p class="eyebrow">无数据</p>
|
||||
<h2>没有检测到受支持的浏览器</h2>
|
||||
<p>请安装或登录 Chrome、Edge、Brave 等浏览器后再刷新扫描。</p>
|
||||
</section>
|
||||
</template>
|
||||
</main>
|
||||
|
||||
@@ -4,11 +4,15 @@ import type {
|
||||
AssociatedProfileSortKey,
|
||||
AssociatedProfileSummary,
|
||||
BookmarkAssociatedProfileSummary,
|
||||
ExtensionAssociatedProfileSummary,
|
||||
} from "../../types/browser";
|
||||
import { profileAvatarSrc } from "../../utils/icons";
|
||||
import { sortAssociatedProfiles } from "../../utils/sort";
|
||||
|
||||
type ModalProfile = AssociatedProfileSummary | BookmarkAssociatedProfileSummary;
|
||||
type ModalProfile =
|
||||
| AssociatedProfileSummary
|
||||
| BookmarkAssociatedProfileSummary
|
||||
| ExtensionAssociatedProfileSummary;
|
||||
|
||||
const props = defineProps<{
|
||||
title: string;
|
||||
@@ -16,20 +20,42 @@ const props = defineProps<{
|
||||
browserId: string;
|
||||
browserFamilyId: string | null;
|
||||
isBookmark: boolean;
|
||||
isExtension?: boolean;
|
||||
selectedProfileIds?: string[];
|
||||
deleteBusy?: boolean;
|
||||
isOpeningProfile: (browserId: string, profileId: string) => boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
openProfile: [browserId: string, profileId: string];
|
||||
toggleProfileSelection: [profileId: string];
|
||||
toggleAllProfileSelection: [];
|
||||
deleteProfile: [profileId: string];
|
||||
deleteSelectedProfiles: [];
|
||||
}>();
|
||||
|
||||
const sortKey = ref<AssociatedProfileSortKey>("id");
|
||||
const sortedProfiles = computed(() => sortAssociatedProfiles(props.profiles, sortKey.value));
|
||||
const selectedProfileIds = computed(() => props.selectedProfileIds ?? []);
|
||||
const allSelected = computed(
|
||||
() =>
|
||||
sortedProfiles.value.length > 0 &&
|
||||
sortedProfiles.value.every((profile) => selectedProfileIds.value.includes(profile.id)),
|
||||
);
|
||||
const isSelectableMode = computed(() => props.isExtension || props.isBookmark);
|
||||
|
||||
function hasBookmarkPath(profile: ModalProfile): profile is BookmarkAssociatedProfileSummary {
|
||||
return "bookmarkPath" in profile;
|
||||
}
|
||||
|
||||
function hasInstallSource(profile: ModalProfile): profile is ExtensionAssociatedProfileSummary {
|
||||
return "installSource" in profile;
|
||||
}
|
||||
|
||||
function isSelected(profileId: string) {
|
||||
return selectedProfileIds.value.includes(profileId);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -38,25 +64,77 @@ function hasBookmarkPath(profile: ModalProfile): profile is BookmarkAssociatedPr
|
||||
<div class="modal-header">
|
||||
<h3>{{ title }}</h3>
|
||||
<button class="secondary-button modal-close-button" type="button" @click="emit('close')">
|
||||
Close
|
||||
关闭
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-table">
|
||||
<div class="modal-table-header modal-grid" :class="{ bookmark: isBookmark }">
|
||||
<div class="header-cell icon-cell">Avatar</div>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'name' }" type="button" @click="sortKey = 'name'">Name</button>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'id' }" type="button" @click="sortKey = 'id'">Profile ID</button>
|
||||
<div v-if="isBookmark" class="header-cell">Bookmark Path</div>
|
||||
<div class="header-cell actions-cell">Action</div>
|
||||
<div v-if="isSelectableMode" class="modal-toolbar">
|
||||
<label class="toolbar-checkbox" :class="{ disabled: !sortedProfiles.length }">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="native-checkbox"
|
||||
:checked="allSelected"
|
||||
:disabled="!sortedProfiles.length || deleteBusy"
|
||||
@change="emit('toggleAllProfileSelection')"
|
||||
/>
|
||||
<span class="custom-checkbox" :class="{ checked: allSelected }" aria-hidden="true">
|
||||
<svg viewBox="0 0 16 16">
|
||||
<path d="M3.5 8.2L6.4 11.1L12.5 4.9" />
|
||||
</svg>
|
||||
</span>
|
||||
<span>全选</span>
|
||||
</label>
|
||||
<button
|
||||
class="danger-button"
|
||||
type="button"
|
||||
:disabled="!selectedProfileIds.length || deleteBusy"
|
||||
@click="emit('deleteSelectedProfiles')"
|
||||
>
|
||||
{{ deleteBusy ? "删除中..." : `删除所选(${selectedProfileIds.length})` }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-table-header modal-grid" :class="{ bookmark: isBookmark, extension: isExtension }">
|
||||
<div v-if="isSelectableMode" class="header-cell checkbox-cell">选择</div>
|
||||
<div class="header-cell icon-cell">头像</div>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'name' }" type="button" @click="sortKey = 'name'">名称</button>
|
||||
<button
|
||||
v-if="!isExtension && !isBookmark"
|
||||
class="header-cell sortable"
|
||||
:class="{ active: sortKey === 'id' }"
|
||||
type="button"
|
||||
@click="sortKey = 'id'"
|
||||
>
|
||||
资料 ID
|
||||
</button>
|
||||
<div v-if="isExtension" class="header-cell">来源</div>
|
||||
<div v-if="isBookmark" class="header-cell">书签路径</div>
|
||||
<div class="header-cell actions-cell">操作</div>
|
||||
</div>
|
||||
<div class="modal-table-body styled-scrollbar">
|
||||
<article
|
||||
v-for="profile in sortedProfiles"
|
||||
:key="profile.id"
|
||||
class="modal-table-row modal-grid"
|
||||
:class="{ bookmark: isBookmark }"
|
||||
:class="{ bookmark: isBookmark, extension: isExtension }"
|
||||
>
|
||||
<div v-if="isSelectableMode" class="row-cell checkbox-cell">
|
||||
<label class="table-checkbox" :class="{ disabled: deleteBusy }">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="native-checkbox"
|
||||
:checked="isSelected(profile.id)"
|
||||
:disabled="deleteBusy"
|
||||
@change="emit('toggleProfileSelection', profile.id)"
|
||||
/>
|
||||
<span class="custom-checkbox" :class="{ checked: isSelected(profile.id) }" aria-hidden="true">
|
||||
<svg viewBox="0 0 16 16">
|
||||
<path d="M3.5 8.2L6.4 11.1L12.5 4.9" />
|
||||
</svg>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="modal-profile-avatar">
|
||||
<img
|
||||
v-if="profileAvatarSrc(profile, browserFamilyId)"
|
||||
@@ -67,10 +145,14 @@ function hasBookmarkPath(profile: ModalProfile): profile is BookmarkAssociatedPr
|
||||
</div>
|
||||
<div class="row-cell primary-cell">
|
||||
<strong>{{ profile.name }}</strong>
|
||||
<span v-if="isExtension || isBookmark" class="subtle-line">{{ profile.id }}</span>
|
||||
</div>
|
||||
<div class="row-cell">
|
||||
<div v-if="!isExtension && !isBookmark" class="row-cell">
|
||||
<span class="badge neutral">{{ profile.id }}</span>
|
||||
</div>
|
||||
<div v-if="isExtension && hasInstallSource(profile)" class="row-cell muted-cell">
|
||||
{{ profile.installSource === "store" ? "商店安装" : "外部安装" }}
|
||||
</div>
|
||||
<div
|
||||
v-if="isBookmark && hasBookmarkPath(profile)"
|
||||
class="row-cell muted-cell"
|
||||
@@ -85,7 +167,16 @@ function hasBookmarkPath(profile: ModalProfile): profile is BookmarkAssociatedPr
|
||||
:disabled="isOpeningProfile(browserId, profile.id)"
|
||||
@click="emit('openProfile', browserId, profile.id)"
|
||||
>
|
||||
{{ isOpeningProfile(browserId, profile.id) ? "Opening..." : "Open" }}
|
||||
{{ isOpeningProfile(browserId, profile.id) ? "打开中..." : "打开" }}
|
||||
</button>
|
||||
<button
|
||||
v-if="isSelectableMode"
|
||||
class="danger-button inline-danger-button"
|
||||
type="button"
|
||||
:disabled="deleteBusy"
|
||||
@click="emit('deleteProfile', profile.id)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
@@ -126,12 +217,22 @@ function hasBookmarkPath(profile: ModalProfile): profile is BookmarkAssociatedPr
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.modal-header h3 {
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.03em;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.modal-close-button {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.modal-table {
|
||||
@@ -152,11 +253,25 @@ function hasBookmarkPath(profile: ModalProfile): profile is BookmarkAssociatedPr
|
||||
}
|
||||
|
||||
.modal-grid.bookmark {
|
||||
grid-template-columns: 56px minmax(140px, 0.9fr) 120px minmax(180px, 1fr) 110px;
|
||||
grid-template-columns: 52px 56px minmax(180px, 0.78fr) minmax(180px, 1fr) 168px;
|
||||
}
|
||||
|
||||
.modal-table-header.modal-grid.extension,
|
||||
.modal-table-row.modal-grid.extension {
|
||||
grid-template-columns: 52px 56px minmax(180px, 0.78fr) minmax(180px, 1fr) 168px;
|
||||
}
|
||||
|
||||
.modal-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 12px 8px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.1);
|
||||
}
|
||||
|
||||
.modal-table-header {
|
||||
padding: 10px 14px;
|
||||
padding: 8px 24px 8px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.14);
|
||||
background: rgba(248, 250, 252, 0.94);
|
||||
backdrop-filter: blur(12px);
|
||||
@@ -166,6 +281,7 @@ function hasBookmarkPath(profile: ModalProfile): profile is BookmarkAssociatedPr
|
||||
.modal-table-body {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.header-cell {
|
||||
@@ -186,8 +302,78 @@ function hasBookmarkPath(profile: ModalProfile): profile is BookmarkAssociatedPr
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.toolbar-checkbox {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: var(--text);
|
||||
font-size: 0.88rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toolbar-checkbox.disabled {
|
||||
opacity: 0.55;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.native-checkbox {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.table-checkbox {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.table-checkbox.disabled {
|
||||
cursor: default;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.34);
|
||||
border-radius: 7px;
|
||||
background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.92));
|
||||
}
|
||||
|
||||
.custom-checkbox svg {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.custom-checkbox path {
|
||||
fill: none;
|
||||
stroke: #fff;
|
||||
stroke-width: 2.2;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.custom-checkbox.checked {
|
||||
border-color: rgba(47, 111, 237, 0.2);
|
||||
background: linear-gradient(135deg, #2f6fed, #5aa1f7);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.22),
|
||||
0 8px 18px rgba(47, 111, 237, 0.22);
|
||||
}
|
||||
|
||||
.custom-checkbox.checked path {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.modal-table-row {
|
||||
padding: 12px 14px;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.12);
|
||||
}
|
||||
|
||||
@@ -229,6 +415,13 @@ function hasBookmarkPath(profile: ModalProfile): profile is BookmarkAssociatedPr
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.subtle-line {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
color: var(--muted-soft);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.muted-cell {
|
||||
color: var(--muted);
|
||||
font-size: 0.86rem;
|
||||
@@ -240,24 +433,40 @@ function hasBookmarkPath(profile: ModalProfile): profile is BookmarkAssociatedPr
|
||||
.actions-cell {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.icon-cell {
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.checkbox-cell {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.inline-danger-button {
|
||||
padding: 6px 10px;
|
||||
border-radius: 10px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.modal-backdrop {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.modal-grid,
|
||||
.modal-grid.bookmark {
|
||||
grid-template-columns: 56px minmax(0, 1fr) 96px;
|
||||
.modal-grid.bookmark,
|
||||
.modal-table-header.modal-grid.extension,
|
||||
.modal-table-row.modal-grid.extension {
|
||||
grid-template-columns: 56px minmax(0, 1fr) 120px;
|
||||
}
|
||||
|
||||
.modal-grid > :nth-child(4),
|
||||
.modal-grid.bookmark > :nth-child(4) {
|
||||
.modal-grid.bookmark > :nth-child(4),
|
||||
.modal-table-header.modal-grid.extension > :nth-child(4),
|
||||
.modal-table-row.modal-grid.extension > :nth-child(4) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
146
src/components/browser-data/BookmarkRemovalModal.vue
Normal file
@@ -0,0 +1,146 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
import type { RemoveBookmarkResult } from "../../types/browser";
|
||||
|
||||
const props = defineProps<{
|
||||
mode: "confirm" | "result";
|
||||
title: string;
|
||||
bookmarkCount: number;
|
||||
profileCount: number;
|
||||
results: RemoveBookmarkResult[];
|
||||
busy?: boolean;
|
||||
generalError?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
confirm: [];
|
||||
}>();
|
||||
|
||||
const resultSummary = computed(() => {
|
||||
const statusByUrl = new Map<string, boolean>();
|
||||
|
||||
for (const result of props.results) {
|
||||
const previous = statusByUrl.get(result.url);
|
||||
const succeeded = !result.error;
|
||||
|
||||
if (previous === undefined) {
|
||||
statusByUrl.set(result.url, succeeded);
|
||||
continue;
|
||||
}
|
||||
|
||||
statusByUrl.set(result.url, previous && succeeded);
|
||||
}
|
||||
|
||||
let successCount = 0;
|
||||
let failedCount = 0;
|
||||
for (const succeeded of statusByUrl.values()) {
|
||||
if (succeeded) {
|
||||
successCount += 1;
|
||||
} else {
|
||||
failedCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return { successCount, failedCount };
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="modal-backdrop" @click.self="emit('close')">
|
||||
<section class="modal-card">
|
||||
<div class="modal-header">
|
||||
<h3>{{ title }}</h3>
|
||||
<button class="secondary-button" type="button" @click="emit('close')">关闭</button>
|
||||
</div>
|
||||
|
||||
<template v-if="mode === 'confirm'">
|
||||
<p class="modal-copy">
|
||||
将从 {{ profileCount }} 个资料中删除 {{ bookmarkCount }} 个书签。
|
||||
</p>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button class="secondary-button" type="button" @click="emit('close')">取消</button>
|
||||
<button class="danger-button" type="button" :disabled="busy" @click="emit('confirm')">
|
||||
{{ busy ? "删除中..." : "确认删除" }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<p v-if="generalError" class="result-banner error">{{ generalError }}</p>
|
||||
<p class="modal-copy">
|
||||
成功删除 {{ resultSummary.successCount }} 个书签,失败 {{ resultSummary.failedCount }} 个。
|
||||
</p>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button class="primary-button" type="button" @click="emit('close')">关闭</button>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 50;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
background: rgba(15, 23, 42, 0.26);
|
||||
backdrop-filter: blur(6px);
|
||||
-webkit-backdrop-filter: blur(6px);
|
||||
}
|
||||
|
||||
.modal-card {
|
||||
width: min(560px, 100%);
|
||||
max-height: min(72vh, 820px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--panel-border);
|
||||
border-radius: 22px;
|
||||
background: rgba(255, 255, 255, 0.96);
|
||||
box-shadow: 0 28px 70px rgba(15, 23, 42, 0.18);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.modal-header h3,
|
||||
.modal-copy {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.modal-copy {
|
||||
color: var(--muted);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.result-banner {
|
||||
margin: 0;
|
||||
padding: 12px 14px;
|
||||
border-radius: 14px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.result-banner.error {
|
||||
background: rgba(254, 242, 242, 0.96);
|
||||
color: #b42318;
|
||||
border: 1px solid rgba(239, 68, 68, 0.18);
|
||||
}
|
||||
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,42 +1,111 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
import type { BookmarkSortKey, BookmarkSummary } from "../../types/browser";
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
bookmarks: BookmarkSummary[];
|
||||
sortKey: BookmarkSortKey;
|
||||
selectedBookmarkUrls: string[];
|
||||
deleteBusy: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:sortKey": [value: BookmarkSortKey];
|
||||
showProfiles: [url: string];
|
||||
toggleBookmark: [url: string];
|
||||
toggleAllBookmarks: [];
|
||||
deleteBookmark: [url: string];
|
||||
deleteSelected: [];
|
||||
}>();
|
||||
|
||||
const allSelected = computed(
|
||||
() =>
|
||||
props.bookmarks.length > 0 &&
|
||||
props.bookmarks.every((bookmark) => props.selectedBookmarkUrls.includes(bookmark.url)),
|
||||
);
|
||||
|
||||
function isSelected(url: string) {
|
||||
return props.selectedBookmarkUrls.includes(url);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="table-section">
|
||||
<div v-if="bookmarks.length" class="data-table">
|
||||
<div class="bookmarks-toolbar">
|
||||
<label class="toolbar-checkbox" :class="{ disabled: !bookmarks.length }">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="native-checkbox"
|
||||
:checked="allSelected"
|
||||
:disabled="!bookmarks.length || deleteBusy"
|
||||
@change="emit('toggleAllBookmarks')"
|
||||
/>
|
||||
<span class="custom-checkbox" :class="{ checked: allSelected }" aria-hidden="true">
|
||||
<svg viewBox="0 0 16 16">
|
||||
<path d="M3.5 8.2L6.4 11.1L12.5 4.9" />
|
||||
</svg>
|
||||
</span>
|
||||
<span>全选</span>
|
||||
</label>
|
||||
<button
|
||||
class="danger-button"
|
||||
type="button"
|
||||
:disabled="!selectedBookmarkUrls.length || deleteBusy"
|
||||
@click="emit('deleteSelected')"
|
||||
>
|
||||
{{ deleteBusy ? "删除中..." : `删除所选(${selectedBookmarkUrls.length})` }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="data-table-header bookmarks-grid">
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'title' }" type="button" @click="emit('update:sortKey', 'title')">Name</button>
|
||||
<div class="header-cell checkbox-cell">选择</div>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'title' }" type="button" @click="emit('update:sortKey', 'title')">名称</button>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'url' }" type="button" @click="emit('update:sortKey', 'url')">URL</button>
|
||||
<div class="header-cell actions-cell">Profiles</div>
|
||||
<div class="header-cell actions-cell">操作</div>
|
||||
</div>
|
||||
<div class="data-table-body styled-scrollbar">
|
||||
<article v-for="bookmark in bookmarks" :key="bookmark.url" class="data-table-row bookmarks-grid">
|
||||
<div class="row-cell checkbox-cell">
|
||||
<label class="table-checkbox" :class="{ disabled: deleteBusy }">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="native-checkbox"
|
||||
:checked="isSelected(bookmark.url)"
|
||||
:disabled="deleteBusy"
|
||||
@change="emit('toggleBookmark', bookmark.url)"
|
||||
/>
|
||||
<span class="custom-checkbox" :class="{ checked: isSelected(bookmark.url) }" aria-hidden="true">
|
||||
<svg viewBox="0 0 16 16">
|
||||
<path d="M3.5 8.2L6.4 11.1L12.5 4.9" />
|
||||
</svg>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="row-cell primary-cell">
|
||||
<strong>{{ bookmark.title }}</strong>
|
||||
<strong :title="bookmark.title">{{ bookmark.title }}</strong>
|
||||
</div>
|
||||
<div class="row-cell muted-cell" :title="bookmark.url">{{ bookmark.url }}</div>
|
||||
<div class="row-cell actions-cell">
|
||||
<button class="disclosure-button" type="button" @click="emit('showProfiles', bookmark.url)">
|
||||
<span>View</span>
|
||||
<span>查看</span>
|
||||
<span class="badge neutral">{{ bookmark.profileIds.length }}</span>
|
||||
</button>
|
||||
<button
|
||||
class="danger-button inline-danger-button"
|
||||
type="button"
|
||||
:disabled="deleteBusy"
|
||||
@click="emit('deleteBookmark', bookmark.url)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-card">
|
||||
<p>No bookmarks were discovered for this browser.</p>
|
||||
<p>这个浏览器没有扫描到任何书签。</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -48,6 +117,15 @@ const emit = defineEmits<{
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.bookmarks-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 12px 8px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.1);
|
||||
}
|
||||
|
||||
.data-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -63,11 +141,12 @@ const emit = defineEmits<{
|
||||
.data-table-body {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.bookmarks-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(180px, 0.9fr) minmax(260px, 1.2fr) 154px;
|
||||
grid-template-columns: 52px minmax(180px, 0.9fr) minmax(260px, 1.2fr) 250px;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -76,7 +155,7 @@ const emit = defineEmits<{
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
padding: 10px 14px;
|
||||
padding: 8px 24px 8px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.14);
|
||||
background: rgba(248, 250, 252, 0.94);
|
||||
backdrop-filter: blur(12px);
|
||||
@@ -101,8 +180,81 @@ const emit = defineEmits<{
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.toolbar-checkbox {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: var(--text);
|
||||
font-size: 0.88rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toolbar-checkbox.disabled {
|
||||
opacity: 0.55;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.native-checkbox {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.table-checkbox {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.table-checkbox.disabled {
|
||||
cursor: default;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.34);
|
||||
border-radius: 7px;
|
||||
background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.92));
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.78),
|
||||
0 4px 10px rgba(15, 23, 42, 0.06);
|
||||
}
|
||||
|
||||
.custom-checkbox svg {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.custom-checkbox path {
|
||||
fill: none;
|
||||
stroke: #fff;
|
||||
stroke-width: 2.2;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.custom-checkbox.checked {
|
||||
border-color: rgba(47, 111, 237, 0.2);
|
||||
background: linear-gradient(135deg, #2f6fed, #5aa1f7);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.22),
|
||||
0 8px 18px rgba(47, 111, 237, 0.22);
|
||||
}
|
||||
|
||||
.custom-checkbox.checked path {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.data-table-row {
|
||||
padding: 12px 14px;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.12);
|
||||
}
|
||||
|
||||
@@ -122,6 +274,9 @@ const emit = defineEmits<{
|
||||
display: block;
|
||||
font-size: 0.93rem;
|
||||
line-height: 1.3;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.muted-cell {
|
||||
@@ -149,20 +304,32 @@ const emit = defineEmits<{
|
||||
.actions-cell {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.checkbox-cell {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.inline-danger-button {
|
||||
padding: 6px 10px;
|
||||
border-radius: 10px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.bookmarks-grid {
|
||||
grid-template-columns: minmax(160px, 0.9fr) minmax(200px, 1fr) 148px;
|
||||
grid-template-columns: 52px minmax(160px, 0.9fr) minmax(200px, 1fr) 236px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.bookmarks-grid {
|
||||
grid-template-columns: minmax(0, 1fr) 132px;
|
||||
grid-template-columns: 52px minmax(0, 1fr) 152px;
|
||||
}
|
||||
|
||||
.bookmarks-grid > :nth-child(2) {
|
||||
.bookmarks-grid > :nth-child(3) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,21 @@ import type {
|
||||
BookmarkSortKey,
|
||||
BrowserView,
|
||||
ExtensionSortKey,
|
||||
CleanupHistoryResult,
|
||||
ExtensionAssociatedProfileSummary,
|
||||
RemoveBookmarkResult,
|
||||
PasswordSiteSortKey,
|
||||
ProfileSortKey,
|
||||
RemoveExtensionResult,
|
||||
} from "../../types/browser";
|
||||
import AssociatedProfilesModal from "./AssociatedProfilesModal.vue";
|
||||
import BookmarkRemovalModal from "./BookmarkRemovalModal.vue";
|
||||
import BookmarksList from "./BookmarksList.vue";
|
||||
import ExtensionRemovalModal from "./ExtensionRemovalModal.vue";
|
||||
import ExtensionsList from "./ExtensionsList.vue";
|
||||
import HistoryCleanupList from "./HistoryCleanupList.vue";
|
||||
import HistoryCleanupModal from "./HistoryCleanupModal.vue";
|
||||
import PasswordSitesList from "./PasswordSitesList.vue";
|
||||
import ProfilesList from "./ProfilesList.vue";
|
||||
|
||||
defineProps<{
|
||||
@@ -19,19 +29,49 @@ defineProps<{
|
||||
profileSortKey: ProfileSortKey;
|
||||
extensionSortKey: ExtensionSortKey;
|
||||
bookmarkSortKey: BookmarkSortKey;
|
||||
passwordSiteSortKey: PasswordSiteSortKey;
|
||||
sortedProfiles: BrowserView["profiles"];
|
||||
sortedExtensions: BrowserView["extensions"];
|
||||
sortedBookmarks: BrowserView["bookmarks"];
|
||||
sortedPasswordSites: BrowserView["passwordSites"];
|
||||
historySelectedProfileIds: string[];
|
||||
cleanupHistoryBusy: boolean;
|
||||
historyCleanupConfirmProfiles: BrowserView["profiles"];
|
||||
historyCleanupResultOpen: boolean;
|
||||
cleanupHistoryError: string;
|
||||
cleanupHistoryResults: CleanupHistoryResult[];
|
||||
bookmarkSelectedUrls: string[];
|
||||
bookmarkModalSelectedProfileIds: string[];
|
||||
bookmarkDeleteBusy: boolean;
|
||||
bookmarkRemovalConfirmBookmarkCount: number;
|
||||
bookmarkRemovalConfirmProfileCount: number;
|
||||
bookmarkRemovalResultOpen: boolean;
|
||||
bookmarkRemovalError: string;
|
||||
bookmarkRemovalResults: RemoveBookmarkResult[];
|
||||
extensionSelectedIds: string[];
|
||||
extensionModalSelectedProfileIds: string[];
|
||||
extensionDeleteBusy: boolean;
|
||||
extensionRemovalConfirmExtensions: BrowserView["extensions"];
|
||||
extensionRemovalConfirmProfiles: BrowserView["profiles"];
|
||||
extensionRemovalResultOpen: boolean;
|
||||
extensionRemovalError: string;
|
||||
extensionRemovalResults: RemoveExtensionResult[];
|
||||
openProfileError: string;
|
||||
sectionCount: (section: ActiveSection) => number;
|
||||
isOpeningProfile: (browserId: string, profileId: string) => boolean;
|
||||
extensionMonogram: (name: string) => string;
|
||||
domainFromUrl: (url: string) => string;
|
||||
associatedProfilesModal: {
|
||||
title: string;
|
||||
browserId: string;
|
||||
profiles: (AssociatedProfileSummary | BookmarkAssociatedProfileSummary)[];
|
||||
profiles: (
|
||||
| AssociatedProfileSummary
|
||||
| BookmarkAssociatedProfileSummary
|
||||
| ExtensionAssociatedProfileSummary
|
||||
)[];
|
||||
isBookmark: boolean;
|
||||
isExtension?: boolean;
|
||||
extensionId?: string;
|
||||
bookmarkUrl?: string;
|
||||
} | null;
|
||||
}>();
|
||||
|
||||
@@ -40,9 +80,40 @@ const emit = defineEmits<{
|
||||
"update:profileSortKey": [value: ProfileSortKey];
|
||||
"update:extensionSortKey": [value: ExtensionSortKey];
|
||||
"update:bookmarkSortKey": [value: BookmarkSortKey];
|
||||
"update:passwordSiteSortKey": [value: PasswordSiteSortKey];
|
||||
openProfile: [browserId: string, profileId: string];
|
||||
showExtensionProfiles: [extensionId: string];
|
||||
showBookmarkProfiles: [url: string];
|
||||
showPasswordSiteProfiles: [url: string];
|
||||
toggleBookmarkSelection: [url: string];
|
||||
toggleAllBookmarks: [];
|
||||
deleteBookmarkFromAllProfiles: [url: string];
|
||||
deleteSelectedBookmarks: [];
|
||||
toggleBookmarkModalProfileSelection: [profileId: string];
|
||||
toggleAllBookmarkModalProfiles: [];
|
||||
deleteBookmarkFromProfile: [profileId: string];
|
||||
deleteSelectedBookmarkProfiles: [];
|
||||
confirmBookmarkRemoval: [];
|
||||
closeBookmarkRemovalConfirm: [];
|
||||
closeBookmarkRemovalResult: [];
|
||||
toggleExtensionSelection: [extensionId: string];
|
||||
toggleAllExtensions: [];
|
||||
deleteExtensionFromAllProfiles: [extensionId: string];
|
||||
deleteSelectedExtensions: [];
|
||||
toggleExtensionModalProfileSelection: [profileId: string];
|
||||
toggleAllExtensionModalProfiles: [];
|
||||
deleteExtensionFromProfile: [profileId: string];
|
||||
deleteSelectedExtensionProfiles: [];
|
||||
confirmExtensionRemoval: [];
|
||||
closeExtensionRemovalConfirm: [];
|
||||
closeExtensionRemovalResult: [];
|
||||
toggleHistoryProfile: [profileId: string];
|
||||
toggleAllHistoryProfiles: [];
|
||||
cleanupSelectedHistory: [];
|
||||
cleanupHistoryForProfile: [profileId: string];
|
||||
confirmHistoryCleanup: [];
|
||||
closeHistoryCleanupConfirm: [];
|
||||
closeHistoryCleanupResult: [];
|
||||
closeAssociatedProfiles: [];
|
||||
}>();
|
||||
</script>
|
||||
@@ -55,7 +126,7 @@ const emit = defineEmits<{
|
||||
type="button"
|
||||
@click="emit('update:activeSection', 'profiles')"
|
||||
>
|
||||
<span>Profiles</span>
|
||||
<span>资料</span>
|
||||
<span class="count-pill">{{ sectionCount("profiles") }}</span>
|
||||
</button>
|
||||
<button
|
||||
@@ -64,7 +135,7 @@ const emit = defineEmits<{
|
||||
type="button"
|
||||
@click="emit('update:activeSection', 'extensions')"
|
||||
>
|
||||
<span>Extensions</span>
|
||||
<span>插件</span>
|
||||
<span class="count-pill">{{ sectionCount("extensions") }}</span>
|
||||
</button>
|
||||
<button
|
||||
@@ -73,9 +144,27 @@ const emit = defineEmits<{
|
||||
type="button"
|
||||
@click="emit('update:activeSection', 'bookmarks')"
|
||||
>
|
||||
<span>Bookmarks</span>
|
||||
<span>书签</span>
|
||||
<span class="count-pill">{{ sectionCount("bookmarks") }}</span>
|
||||
</button>
|
||||
<button
|
||||
class="section-tab"
|
||||
:class="{ active: activeSection === 'passwords' }"
|
||||
type="button"
|
||||
@click="emit('update:activeSection', 'passwords')"
|
||||
>
|
||||
<span>已保存登录</span>
|
||||
<span class="count-pill">{{ sectionCount("passwords") }}</span>
|
||||
</button>
|
||||
<button
|
||||
class="section-tab"
|
||||
:class="{ active: activeSection === 'history' }"
|
||||
type="button"
|
||||
@click="emit('update:activeSection', 'history')"
|
||||
>
|
||||
<span>历史</span>
|
||||
<span class="count-pill">{{ sectionCount("history") }}</span>
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<div class="content-scroll-area">
|
||||
@@ -96,19 +185,118 @@ const emit = defineEmits<{
|
||||
:extensions="sortedExtensions"
|
||||
:sort-key="extensionSortKey"
|
||||
:extension-monogram="extensionMonogram"
|
||||
:selected-extension-ids="extensionSelectedIds"
|
||||
:delete-busy="extensionDeleteBusy"
|
||||
@update:sort-key="emit('update:extensionSortKey', $event)"
|
||||
@show-profiles="emit('showExtensionProfiles', $event)"
|
||||
@toggle-extension="emit('toggleExtensionSelection', $event)"
|
||||
@toggle-all-extensions="emit('toggleAllExtensions')"
|
||||
@delete-extension="emit('deleteExtensionFromAllProfiles', $event)"
|
||||
@delete-selected="emit('deleteSelectedExtensions')"
|
||||
/>
|
||||
|
||||
<BookmarksList
|
||||
v-else
|
||||
v-else-if="activeSection === 'bookmarks'"
|
||||
:bookmarks="sortedBookmarks"
|
||||
:sort-key="bookmarkSortKey"
|
||||
:selected-bookmark-urls="bookmarkSelectedUrls"
|
||||
:delete-busy="bookmarkDeleteBusy"
|
||||
@update:sort-key="emit('update:bookmarkSortKey', $event)"
|
||||
@show-profiles="emit('showBookmarkProfiles', $event)"
|
||||
@toggle-bookmark="emit('toggleBookmarkSelection', $event)"
|
||||
@toggle-all-bookmarks="emit('toggleAllBookmarks')"
|
||||
@delete-bookmark="emit('deleteBookmarkFromAllProfiles', $event)"
|
||||
@delete-selected="emit('deleteSelectedBookmarks')"
|
||||
/>
|
||||
|
||||
<PasswordSitesList
|
||||
v-else-if="activeSection === 'passwords'"
|
||||
:password-sites="sortedPasswordSites"
|
||||
:sort-key="passwordSiteSortKey"
|
||||
@update:sort-key="emit('update:passwordSiteSortKey', $event)"
|
||||
@show-profiles="emit('showPasswordSiteProfiles', $event)"
|
||||
/>
|
||||
|
||||
<HistoryCleanupList
|
||||
v-else
|
||||
:browser-family-id="currentBrowser.browserFamilyId"
|
||||
:profiles="sortedProfiles"
|
||||
:selected-profile-ids="historySelectedProfileIds"
|
||||
:cleanup-busy="cleanupHistoryBusy"
|
||||
@toggle-profile="emit('toggleHistoryProfile', $event)"
|
||||
@toggle-all-profiles="emit('toggleAllHistoryProfiles')"
|
||||
@cleanup-selected="emit('cleanupSelectedHistory')"
|
||||
@cleanup-profile="emit('cleanupHistoryForProfile', $event)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<HistoryCleanupModal
|
||||
v-if="historyCleanupConfirmProfiles.length"
|
||||
mode="confirm"
|
||||
title="确认清理历史"
|
||||
:profiles="historyCleanupConfirmProfiles"
|
||||
:results="[]"
|
||||
:busy="cleanupHistoryBusy"
|
||||
@close="emit('closeHistoryCleanupConfirm')"
|
||||
@confirm="emit('confirmHistoryCleanup')"
|
||||
/>
|
||||
|
||||
<HistoryCleanupModal
|
||||
v-if="historyCleanupResultOpen"
|
||||
mode="result"
|
||||
title="清理结果"
|
||||
:profiles="[]"
|
||||
:results="cleanupHistoryResults"
|
||||
:general-error="cleanupHistoryError"
|
||||
@close="emit('closeHistoryCleanupResult')"
|
||||
/>
|
||||
|
||||
<BookmarkRemovalModal
|
||||
v-if="bookmarkRemovalConfirmBookmarkCount > 0"
|
||||
mode="confirm"
|
||||
title="确认删除书签"
|
||||
:bookmark-count="bookmarkRemovalConfirmBookmarkCount"
|
||||
:profile-count="bookmarkRemovalConfirmProfileCount"
|
||||
:results="[]"
|
||||
:busy="bookmarkDeleteBusy"
|
||||
@close="emit('closeBookmarkRemovalConfirm')"
|
||||
@confirm="emit('confirmBookmarkRemoval')"
|
||||
/>
|
||||
|
||||
<BookmarkRemovalModal
|
||||
v-if="bookmarkRemovalResultOpen"
|
||||
mode="result"
|
||||
title="书签删除结果"
|
||||
:bookmark-count="0"
|
||||
:profile-count="0"
|
||||
:results="bookmarkRemovalResults"
|
||||
:general-error="bookmarkRemovalError"
|
||||
@close="emit('closeBookmarkRemovalResult')"
|
||||
/>
|
||||
|
||||
<ExtensionRemovalModal
|
||||
v-if="extensionRemovalConfirmExtensions.length || extensionRemovalConfirmProfiles.length"
|
||||
mode="confirm"
|
||||
title="确认删除插件"
|
||||
:extensions="extensionRemovalConfirmExtensions"
|
||||
:profiles="extensionRemovalConfirmProfiles"
|
||||
:results="[]"
|
||||
:busy="extensionDeleteBusy"
|
||||
@close="emit('closeExtensionRemovalConfirm')"
|
||||
@confirm="emit('confirmExtensionRemoval')"
|
||||
/>
|
||||
|
||||
<ExtensionRemovalModal
|
||||
v-if="extensionRemovalResultOpen"
|
||||
mode="result"
|
||||
title="插件删除结果"
|
||||
:extensions="[]"
|
||||
:profiles="[]"
|
||||
:results="extensionRemovalResults"
|
||||
:general-error="extensionRemovalError"
|
||||
@close="emit('closeExtensionRemovalResult')"
|
||||
/>
|
||||
|
||||
<AssociatedProfilesModal
|
||||
v-if="associatedProfilesModal"
|
||||
:title="associatedProfilesModal.title"
|
||||
@@ -116,9 +304,36 @@ const emit = defineEmits<{
|
||||
:browser-id="associatedProfilesModal.browserId"
|
||||
:browser-family-id="currentBrowser.browserFamilyId"
|
||||
:is-bookmark="associatedProfilesModal.isBookmark"
|
||||
:is-extension="associatedProfilesModal.isExtension"
|
||||
:selected-profile-ids="
|
||||
associatedProfilesModal.isExtension
|
||||
? extensionModalSelectedProfileIds
|
||||
: bookmarkModalSelectedProfileIds
|
||||
"
|
||||
:delete-busy="associatedProfilesModal.isExtension ? extensionDeleteBusy : bookmarkDeleteBusy"
|
||||
:is-opening-profile="isOpeningProfile"
|
||||
@close="emit('closeAssociatedProfiles')"
|
||||
@open-profile="(browserId, profileId) => emit('openProfile', browserId, profileId)"
|
||||
@toggle-profile-selection="
|
||||
associatedProfilesModal.isExtension
|
||||
? emit('toggleExtensionModalProfileSelection', $event)
|
||||
: emit('toggleBookmarkModalProfileSelection', $event)
|
||||
"
|
||||
@toggle-all-profile-selection="
|
||||
associatedProfilesModal.isExtension
|
||||
? emit('toggleAllExtensionModalProfiles')
|
||||
: emit('toggleAllBookmarkModalProfiles')
|
||||
"
|
||||
@delete-profile="
|
||||
associatedProfilesModal.isExtension
|
||||
? emit('deleteExtensionFromProfile', $event)
|
||||
: emit('deleteBookmarkFromProfile', $event)
|
||||
"
|
||||
@delete-selected-profiles="
|
||||
associatedProfilesModal.isExtension
|
||||
? emit('deleteSelectedExtensionProfiles')
|
||||
: emit('deleteSelectedBookmarkProfiles')
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -127,7 +342,7 @@ const emit = defineEmits<{
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 0;
|
||||
padding: 8px;
|
||||
padding: 6px;
|
||||
flex-shrink: 0;
|
||||
border: 1px solid var(--panel-border);
|
||||
border-radius: 22px;
|
||||
@@ -142,8 +357,8 @@ const emit = defineEmits<{
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
padding: 10px 12px;
|
||||
border-radius: 15px;
|
||||
padding: 8px 10px;
|
||||
border-radius: 13px;
|
||||
color: var(--muted);
|
||||
background: rgba(255, 255, 255, 0.58);
|
||||
cursor: pointer;
|
||||
|
||||
163
src/components/browser-data/ExtensionRemovalModal.vue
Normal file
@@ -0,0 +1,163 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
import type { ExtensionSummary, ProfileSummary, RemoveExtensionResult } from "../../types/browser";
|
||||
|
||||
const props = defineProps<{
|
||||
mode: "confirm" | "result";
|
||||
title: string;
|
||||
extensions: ExtensionSummary[];
|
||||
profiles: ProfileSummary[];
|
||||
results: RemoveExtensionResult[];
|
||||
busy?: boolean;
|
||||
generalError?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
confirm: [];
|
||||
}>();
|
||||
|
||||
const confirmSummary = computed(() => ({
|
||||
extensionCount: props.extensions.length,
|
||||
profileCount: props.profiles.length,
|
||||
}));
|
||||
|
||||
const resultSummary = computed(() => {
|
||||
const statusByExtension = new Map<string, boolean>();
|
||||
|
||||
for (const result of props.results) {
|
||||
const previous = statusByExtension.get(result.extensionId);
|
||||
const succeeded = !result.error;
|
||||
|
||||
if (previous === undefined) {
|
||||
statusByExtension.set(result.extensionId, succeeded);
|
||||
continue;
|
||||
}
|
||||
|
||||
statusByExtension.set(result.extensionId, previous && succeeded);
|
||||
}
|
||||
|
||||
let successCount = 0;
|
||||
let failedCount = 0;
|
||||
|
||||
for (const succeeded of statusByExtension.values()) {
|
||||
if (succeeded) {
|
||||
successCount += 1;
|
||||
} else {
|
||||
failedCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return { successCount, failedCount };
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="modal-backdrop" @click.self="emit('close')">
|
||||
<section class="modal-card">
|
||||
<div class="modal-header">
|
||||
<h3>{{ title }}</h3>
|
||||
<button class="secondary-button" type="button" @click="emit('close')">关闭</button>
|
||||
</div>
|
||||
|
||||
<template v-if="mode === 'confirm'">
|
||||
<p class="modal-copy">
|
||||
将从 {{ confirmSummary.profileCount }} 个资料中删除 {{ confirmSummary.extensionCount }} 个插件。
|
||||
</p>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button class="secondary-button" type="button" @click="emit('close')">取消</button>
|
||||
<button class="danger-button" type="button" :disabled="busy" @click="emit('confirm')">
|
||||
{{ busy ? "删除中..." : "确认删除" }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<p v-if="generalError" class="result-banner error">{{ generalError }}</p>
|
||||
<p class="modal-copy">
|
||||
成功删除 {{ resultSummary.successCount }} 个插件,失败 {{ resultSummary.failedCount }} 个。
|
||||
</p>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button class="primary-button" type="button" @click="emit('close')">关闭</button>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 50;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
background: rgba(15, 23, 42, 0.26);
|
||||
backdrop-filter: blur(6px);
|
||||
-webkit-backdrop-filter: blur(6px);
|
||||
}
|
||||
|
||||
.modal-card {
|
||||
width: min(680px, 100%);
|
||||
max-height: min(76vh, 820px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--panel-border);
|
||||
border-radius: 22px;
|
||||
background: rgba(255, 255, 255, 0.96);
|
||||
box-shadow: 0 28px 70px rgba(15, 23, 42, 0.18);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.modal-header h3,
|
||||
.modal-copy {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.modal-copy {
|
||||
color: var(--muted);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.result-banner {
|
||||
margin: 0;
|
||||
padding: 12px 14px;
|
||||
border-radius: 14px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.result-banner.error {
|
||||
background: rgba(254, 242, 242, 0.96);
|
||||
color: #b42318;
|
||||
border: 1px solid rgba(239, 68, 68, 0.18);
|
||||
}
|
||||
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.muted-line {
|
||||
color: var(--muted-soft);
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 1px 5px;
|
||||
border-radius: 7px;
|
||||
background: rgba(226, 232, 240, 0.72);
|
||||
color: var(--text);
|
||||
}
|
||||
</style>
|
||||
@@ -1,29 +1,89 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import type { ExtensionSortKey, ExtensionSummary } from "../../types/browser";
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
extensions: ExtensionSummary[];
|
||||
sortKey: ExtensionSortKey;
|
||||
extensionMonogram: (name: string) => string;
|
||||
selectedExtensionIds: string[];
|
||||
deleteBusy: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:sortKey": [value: ExtensionSortKey];
|
||||
showProfiles: [extensionId: string];
|
||||
toggleExtension: [extensionId: string];
|
||||
toggleAllExtensions: [];
|
||||
deleteExtension: [extensionId: string];
|
||||
deleteSelected: [];
|
||||
}>();
|
||||
|
||||
const allSelected = computed(
|
||||
() =>
|
||||
props.extensions.length > 0 &&
|
||||
props.extensions.every((extension) => props.selectedExtensionIds.includes(extension.id)),
|
||||
);
|
||||
|
||||
function isSelected(extensionId: string) {
|
||||
return props.selectedExtensionIds.includes(extensionId);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="table-section">
|
||||
<div v-if="extensions.length" class="data-table">
|
||||
<div class="extensions-toolbar">
|
||||
<label class="toolbar-checkbox" :class="{ disabled: !extensions.length }">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="native-checkbox"
|
||||
:checked="allSelected"
|
||||
:disabled="!extensions.length || deleteBusy"
|
||||
@change="emit('toggleAllExtensions')"
|
||||
/>
|
||||
<span class="custom-checkbox" :class="{ checked: allSelected }" aria-hidden="true">
|
||||
<svg viewBox="0 0 16 16">
|
||||
<path d="M3.5 8.2L6.4 11.1L12.5 4.9" />
|
||||
</svg>
|
||||
</span>
|
||||
<span>全选</span>
|
||||
</label>
|
||||
<button
|
||||
class="danger-button"
|
||||
type="button"
|
||||
:disabled="!selectedExtensionIds.length || deleteBusy"
|
||||
@click="emit('deleteSelected')"
|
||||
>
|
||||
{{ deleteBusy ? "删除中..." : `删除所选(${selectedExtensionIds.length})` }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="data-table-header extensions-grid">
|
||||
<div class="header-cell icon-cell">Icon</div>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'name' }" type="button" @click="emit('update:sortKey', 'name')">Name</button>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'id' }" type="button" @click="emit('update:sortKey', 'id')">Extension ID</button>
|
||||
<div class="header-cell actions-cell">Profiles</div>
|
||||
<div class="header-cell checkbox-cell">选择</div>
|
||||
<div class="header-cell icon-cell">图标</div>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'name' }" type="button" @click="emit('update:sortKey', 'name')">名称</button>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'id' }" type="button" @click="emit('update:sortKey', 'id')">插件 ID</button>
|
||||
<div class="header-cell actions-cell">操作</div>
|
||||
</div>
|
||||
<div class="data-table-body styled-scrollbar">
|
||||
<article v-for="extension in extensions" :key="extension.id" class="data-table-row extensions-grid">
|
||||
<div class="row-cell checkbox-cell">
|
||||
<label class="table-checkbox" :class="{ disabled: deleteBusy }">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="native-checkbox"
|
||||
:checked="isSelected(extension.id)"
|
||||
:disabled="deleteBusy"
|
||||
@change="emit('toggleExtension', extension.id)"
|
||||
/>
|
||||
<span class="custom-checkbox" :class="{ checked: isSelected(extension.id) }" aria-hidden="true">
|
||||
<svg viewBox="0 0 16 16">
|
||||
<path d="M3.5 8.2L6.4 11.1L12.5 4.9" />
|
||||
</svg>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="extension-icon table-icon" :class="{ filled: Boolean(extension.iconDataUrl) }">
|
||||
<img v-if="extension.iconDataUrl" :src="extension.iconDataUrl" :alt="`${extension.name} icon`" />
|
||||
<span v-else>{{ extensionMonogram(extension.name) }}</span>
|
||||
@@ -34,15 +94,23 @@ const emit = defineEmits<{
|
||||
<div class="row-cell muted-cell" :title="extension.id">{{ extension.id }}</div>
|
||||
<div class="row-cell actions-cell">
|
||||
<button class="disclosure-button" type="button" @click="emit('showProfiles', extension.id)">
|
||||
<span>View</span>
|
||||
<span>查看</span>
|
||||
<span class="badge neutral">{{ extension.profileIds.length }}</span>
|
||||
</button>
|
||||
<button
|
||||
class="danger-button inline-danger-button"
|
||||
type="button"
|
||||
:disabled="deleteBusy"
|
||||
@click="emit('deleteExtension', extension.id)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-card">
|
||||
<p>No extensions were discovered for this browser.</p>
|
||||
<p>这个浏览器没有扫描到任何插件。</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -54,6 +122,88 @@ const emit = defineEmits<{
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.extensions-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 12px 8px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.1);
|
||||
}
|
||||
|
||||
.toolbar-checkbox {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: var(--text);
|
||||
font-size: 0.88rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toolbar-checkbox.disabled {
|
||||
opacity: 0.55;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.native-checkbox {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.table-checkbox {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.table-checkbox.disabled {
|
||||
cursor: default;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.34);
|
||||
border-radius: 7px;
|
||||
background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.92));
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.78),
|
||||
0 4px 10px rgba(15, 23, 42, 0.06);
|
||||
}
|
||||
|
||||
.custom-checkbox svg {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.custom-checkbox path {
|
||||
fill: none;
|
||||
stroke: #fff;
|
||||
stroke-width: 2.2;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.custom-checkbox.checked {
|
||||
border-color: rgba(47, 111, 237, 0.2);
|
||||
background: linear-gradient(135deg, #2f6fed, #5aa1f7);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.22),
|
||||
0 8px 18px rgba(47, 111, 237, 0.22);
|
||||
}
|
||||
|
||||
.custom-checkbox.checked path {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.data-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -69,11 +219,12 @@ const emit = defineEmits<{
|
||||
.data-table-body {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.extensions-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 60px minmax(180px, 1.1fr) minmax(220px, 1fr) 154px;
|
||||
grid-template-columns: 52px 60px minmax(180px, 1.1fr) minmax(220px, 1fr) 250px;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -82,7 +233,7 @@ const emit = defineEmits<{
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
padding: 10px 14px;
|
||||
padding: 8px 24px 8px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.14);
|
||||
background: rgba(248, 250, 252, 0.94);
|
||||
backdrop-filter: blur(12px);
|
||||
@@ -108,7 +259,7 @@ const emit = defineEmits<{
|
||||
}
|
||||
|
||||
.data-table-row {
|
||||
padding: 12px 14px;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.12);
|
||||
}
|
||||
|
||||
@@ -181,6 +332,18 @@ const emit = defineEmits<{
|
||||
.actions-cell {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.checkbox-cell {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.inline-danger-button {
|
||||
padding: 7px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.icon-cell {
|
||||
@@ -189,16 +352,22 @@ const emit = defineEmits<{
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.extensions-grid {
|
||||
grid-template-columns: 56px minmax(160px, 1fr) minmax(160px, 1fr) 148px;
|
||||
grid-template-columns: 52px 56px minmax(160px, 1fr) minmax(160px, 1fr) 220px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.extensions-grid {
|
||||
grid-template-columns: 56px minmax(0, 1fr) 132px;
|
||||
.extensions-toolbar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.extensions-grid > :nth-child(3) {
|
||||
.extensions-grid {
|
||||
grid-template-columns: 52px 56px minmax(0, 1fr) 132px;
|
||||
}
|
||||
|
||||
.extensions-grid > :nth-child(4),
|
||||
.extensions-grid > :nth-child(5) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
432
src/components/browser-data/HistoryCleanupList.vue
Normal file
@@ -0,0 +1,432 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import type { CleanupFileStatus, ProfileSummary } from "../../types/browser";
|
||||
import { profileAvatarSrc } from "../../utils/icons";
|
||||
|
||||
const props = defineProps<{
|
||||
browserFamilyId: string | null;
|
||||
profiles: ProfileSummary[];
|
||||
selectedProfileIds: string[];
|
||||
cleanupBusy: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
toggleProfile: [profileId: string];
|
||||
toggleAllProfiles: [];
|
||||
cleanupSelected: [];
|
||||
cleanupProfile: [profileId: string];
|
||||
}>();
|
||||
|
||||
const selectableProfiles = computed(() =>
|
||||
props.profiles.filter((profile) =>
|
||||
hasAnyHistoryFile([
|
||||
profile.historyCleanup.history,
|
||||
profile.historyCleanup.topSites,
|
||||
profile.historyCleanup.visitedLinks,
|
||||
profile.historyCleanup.sessions,
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
const allSelected = computed(
|
||||
() =>
|
||||
selectableProfiles.value.length > 0 &&
|
||||
selectableProfiles.value.every((profile) =>
|
||||
props.selectedProfileIds.includes(profile.id),
|
||||
),
|
||||
);
|
||||
|
||||
function statusLabel(status: CleanupFileStatus) {
|
||||
return status === "found" ? "存在" : "缺失";
|
||||
}
|
||||
|
||||
function statusClass(status: CleanupFileStatus) {
|
||||
return status === "found" ? "found" : "missing";
|
||||
}
|
||||
|
||||
function isSelected(profileId: string) {
|
||||
return props.selectedProfileIds.includes(profileId);
|
||||
}
|
||||
|
||||
function isSelectable(profile: ProfileSummary) {
|
||||
return hasAnyHistoryFile([
|
||||
profile.historyCleanup.history,
|
||||
profile.historyCleanup.topSites,
|
||||
profile.historyCleanup.visitedLinks,
|
||||
profile.historyCleanup.sessions,
|
||||
]);
|
||||
}
|
||||
|
||||
function hasAnyHistoryFile(statuses: CleanupFileStatus[]) {
|
||||
return statuses.some((status) => status === "found");
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="table-section">
|
||||
<div v-if="profiles.length" class="data-table">
|
||||
<div class="history-toolbar">
|
||||
<label class="toolbar-checkbox" :class="{ disabled: !selectableProfiles.length }">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="native-checkbox"
|
||||
:checked="allSelected"
|
||||
:disabled="!selectableProfiles.length || cleanupBusy"
|
||||
@change="emit('toggleAllProfiles')"
|
||||
/>
|
||||
<span class="custom-checkbox" :class="{ checked: allSelected }" aria-hidden="true">
|
||||
<svg viewBox="0 0 16 16">
|
||||
<path d="M3.5 8.2L6.4 11.1L12.5 4.9" />
|
||||
</svg>
|
||||
</span>
|
||||
<span>全选</span>
|
||||
</label>
|
||||
<button
|
||||
class="danger-button"
|
||||
type="button"
|
||||
:disabled="!selectedProfileIds.length || cleanupBusy"
|
||||
@click="emit('cleanupSelected')"
|
||||
>
|
||||
{{ cleanupBusy ? "清理中..." : `清理所选(${selectedProfileIds.length})` }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="data-table-header history-grid">
|
||||
<div class="header-cell checkbox-cell">选择</div>
|
||||
<div class="header-cell icon-cell">头像</div>
|
||||
<div class="header-cell">资料</div>
|
||||
<div class="header-cell">历史记录</div>
|
||||
<div class="header-cell">热门站点</div>
|
||||
<div class="header-cell">访问链接</div>
|
||||
<div class="header-cell">会话</div>
|
||||
<div class="header-cell actions-cell">操作</div>
|
||||
</div>
|
||||
<div class="data-table-body styled-scrollbar">
|
||||
<article v-for="profile in profiles" :key="profile.id" class="data-table-row history-grid">
|
||||
<div class="row-cell checkbox-cell">
|
||||
<label class="table-checkbox" :class="{ disabled: !isSelectable(profile) || cleanupBusy }">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="native-checkbox"
|
||||
:checked="isSelected(profile.id)"
|
||||
:disabled="!isSelectable(profile) || cleanupBusy"
|
||||
@change="emit('toggleProfile', profile.id)"
|
||||
/>
|
||||
<span class="custom-checkbox" :class="{ checked: isSelected(profile.id) }" aria-hidden="true">
|
||||
<svg viewBox="0 0 16 16">
|
||||
<path d="M3.5 8.2L6.4 11.1L12.5 4.9" />
|
||||
</svg>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="profile-avatar table-avatar">
|
||||
<img
|
||||
v-if="profileAvatarSrc(profile, browserFamilyId)"
|
||||
:src="profileAvatarSrc(profile, browserFamilyId) ?? undefined"
|
||||
:alt="`${profile.name} avatar`"
|
||||
/>
|
||||
<span v-else>{{ profile.avatarLabel }}</span>
|
||||
</div>
|
||||
<div class="row-cell primary-cell">
|
||||
<strong>{{ profile.name }}</strong>
|
||||
<span class="subtle-line">{{ profile.id }}</span>
|
||||
</div>
|
||||
<div class="row-cell">
|
||||
<span class="status-pill" :class="statusClass(profile.historyCleanup.history)">
|
||||
{{ statusLabel(profile.historyCleanup.history) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="row-cell">
|
||||
<span class="status-pill" :class="statusClass(profile.historyCleanup.topSites)">
|
||||
{{ statusLabel(profile.historyCleanup.topSites) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="row-cell">
|
||||
<span class="status-pill" :class="statusClass(profile.historyCleanup.visitedLinks)">
|
||||
{{ statusLabel(profile.historyCleanup.visitedLinks) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="row-cell">
|
||||
<span class="status-pill" :class="statusClass(profile.historyCleanup.sessions)">
|
||||
{{ statusLabel(profile.historyCleanup.sessions) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="row-cell actions-cell">
|
||||
<button
|
||||
class="danger-button action-button"
|
||||
type="button"
|
||||
:disabled="!isSelectable(profile) || cleanupBusy"
|
||||
@click="emit('cleanupProfile', profile.id)"
|
||||
>
|
||||
清理
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-card">
|
||||
<p>这个浏览器没有找到任何用户资料目录。</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.table-section {
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.history-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 12px 8px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.1);
|
||||
}
|
||||
|
||||
.toolbar-checkbox {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: var(--text);
|
||||
font-size: 0.88rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toolbar-checkbox.disabled {
|
||||
opacity: 0.55;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.native-checkbox {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.table-checkbox {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.table-checkbox.disabled {
|
||||
cursor: default;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.34);
|
||||
border-radius: 7px;
|
||||
background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.92));
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.78),
|
||||
0 4px 10px rgba(15, 23, 42, 0.06);
|
||||
transition:
|
||||
border-color 160ms ease,
|
||||
background 160ms ease,
|
||||
box-shadow 160ms ease,
|
||||
transform 160ms ease;
|
||||
}
|
||||
|
||||
.custom-checkbox svg {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.custom-checkbox path {
|
||||
fill: none;
|
||||
stroke: #fff;
|
||||
stroke-width: 2.2;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
opacity: 0;
|
||||
transition: opacity 160ms ease;
|
||||
}
|
||||
|
||||
.toolbar-checkbox:hover .custom-checkbox,
|
||||
.table-checkbox:hover .custom-checkbox {
|
||||
border-color: rgba(47, 111, 237, 0.38);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.custom-checkbox.checked {
|
||||
border-color: rgba(47, 111, 237, 0.2);
|
||||
background: linear-gradient(135deg, #2f6fed, #5aa1f7);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.22),
|
||||
0 8px 18px rgba(47, 111, 237, 0.22);
|
||||
}
|
||||
|
||||
.custom-checkbox.checked path {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.data-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
||||
border-radius: 22px;
|
||||
background: var(--panel);
|
||||
box-shadow: var(--shadow);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.data-table-body {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.history-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 52px 56px minmax(170px, 1fr) 118px 118px 128px 118px 108px;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.data-table-header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
padding: 8px 24px 8px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.14);
|
||||
background: rgba(248, 250, 252, 0.94);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.data-table-row {
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.12);
|
||||
}
|
||||
|
||||
.data-table-row:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.data-table-row:hover {
|
||||
background: rgba(248, 250, 252, 0.65);
|
||||
}
|
||||
|
||||
.header-cell {
|
||||
color: var(--muted);
|
||||
font-size: 0.81rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.checkbox-cell {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.icon-cell {
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.row-cell {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.profile-avatar {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex-shrink: 0;
|
||||
background: linear-gradient(135deg, #dbeafe, #eff6ff);
|
||||
color: #1d4ed8;
|
||||
font-size: 0.96rem;
|
||||
font-weight: 700;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table-avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.profile-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.primary-cell strong {
|
||||
display: block;
|
||||
font-size: 0.93rem;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.subtle-line {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
color: var(--muted-soft);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.status-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 78px;
|
||||
padding: 6px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.79rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.status-pill.found {
|
||||
background: rgba(37, 99, 235, 0.12);
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
.status-pill.missing {
|
||||
background: rgba(226, 232, 240, 0.7);
|
||||
color: var(--badge-text);
|
||||
}
|
||||
|
||||
.actions-cell {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.action-button {
|
||||
padding-inline: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.history-grid {
|
||||
grid-template-columns: 52px 56px minmax(160px, 1fr) 110px 110px 118px 110px 100px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.history-toolbar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.history-grid {
|
||||
grid-template-columns: 52px 56px minmax(0, 1fr) 108px;
|
||||
}
|
||||
|
||||
.history-grid > :nth-child(5),
|
||||
.history-grid > :nth-child(6),
|
||||
.history-grid > :nth-child(7),
|
||||
.history-grid > :nth-child(8) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
198
src/components/browser-data/HistoryCleanupModal.vue
Normal file
@@ -0,0 +1,198 @@
|
||||
<script setup lang="ts">
|
||||
import type { CleanupHistoryResult, ProfileSummary } from "../../types/browser";
|
||||
|
||||
defineProps<{
|
||||
mode: "confirm" | "result";
|
||||
title: string;
|
||||
profiles: ProfileSummary[];
|
||||
results: CleanupHistoryResult[];
|
||||
busy?: boolean;
|
||||
generalError?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
confirm: [];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="modal-backdrop" @click.self="emit('close')">
|
||||
<section class="modal-card">
|
||||
<div class="modal-header">
|
||||
<h3>{{ title }}</h3>
|
||||
<button class="secondary-button modal-close-button" type="button" @click="emit('close')">
|
||||
关闭
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<template v-if="mode === 'confirm'">
|
||||
<p class="modal-copy">
|
||||
将删除所选资料中的 <code>History</code>、<code>Top Sites</code>、<code>Visited Links</code>,
|
||||
并清空 <code>Sessions</code> 目录中的所有文件。
|
||||
</p>
|
||||
|
||||
<div class="profile-list styled-scrollbar">
|
||||
<article v-for="profile in profiles" :key="profile.id" class="profile-item">
|
||||
<strong>{{ profile.name }}</strong>
|
||||
<span>{{ profile.id }}</span>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button class="secondary-button" type="button" @click="emit('close')">取消</button>
|
||||
<button class="danger-button" type="button" :disabled="busy" @click="emit('confirm')">
|
||||
{{ busy ? "清理中..." : "确认清理" }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<p v-if="generalError" class="result-banner error">{{ generalError }}</p>
|
||||
|
||||
<div class="result-list styled-scrollbar">
|
||||
<article
|
||||
v-for="result in results"
|
||||
:key="result.profileId"
|
||||
class="result-card"
|
||||
:class="{ error: result.error }"
|
||||
>
|
||||
<strong>{{ result.profileId }}</strong>
|
||||
<p v-if="result.error">{{ result.error }}</p>
|
||||
<p v-else-if="result.deletedFiles.length">
|
||||
已删除:{{ result.deletedFiles.join("、") }}
|
||||
</p>
|
||||
<p v-else>
|
||||
没有删除任何文件。
|
||||
</p>
|
||||
<p v-if="result.skippedFiles.length" class="muted-line">
|
||||
已跳过(不存在):{{ result.skippedFiles.join("、") }}
|
||||
</p>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button class="primary-button" type="button" @click="emit('close')">关闭</button>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 50;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
background: rgba(15, 23, 42, 0.26);
|
||||
backdrop-filter: blur(6px);
|
||||
-webkit-backdrop-filter: blur(6px);
|
||||
}
|
||||
|
||||
.modal-card {
|
||||
width: min(640px, 100%);
|
||||
max-height: min(76vh, 820px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--panel-border);
|
||||
border-radius: 22px;
|
||||
background: rgba(255, 255, 255, 0.96);
|
||||
box-shadow: 0 28px 70px rgba(15, 23, 42, 0.18);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.modal-header h3 {
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.modal-copy {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.profile-list,
|
||||
.result-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.profile-item,
|
||||
.result-card {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
||||
border-radius: 16px;
|
||||
background: rgba(248, 250, 252, 0.84);
|
||||
}
|
||||
|
||||
.profile-item span,
|
||||
.muted-line {
|
||||
color: var(--muted);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.result-card p {
|
||||
margin: 0;
|
||||
color: var(--text);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.result-card.error {
|
||||
border-color: rgba(239, 68, 68, 0.18);
|
||||
background: rgba(254, 242, 242, 0.96);
|
||||
}
|
||||
|
||||
.result-banner {
|
||||
margin: 0;
|
||||
padding: 12px 14px;
|
||||
border-radius: 14px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.result-banner.error {
|
||||
background: rgba(254, 242, 242, 0.96);
|
||||
color: #b42318;
|
||||
border: 1px solid rgba(239, 68, 68, 0.18);
|
||||
}
|
||||
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 1px 5px;
|
||||
border-radius: 7px;
|
||||
background: rgba(226, 232, 240, 0.72);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.modal-backdrop {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.modal-actions {
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
174
src/components/browser-data/PasswordSitesList.vue
Normal file
@@ -0,0 +1,174 @@
|
||||
<script setup lang="ts">
|
||||
import type { PasswordSiteSortKey, PasswordSiteSummary } from "../../types/browser";
|
||||
|
||||
defineProps<{
|
||||
passwordSites: PasswordSiteSummary[];
|
||||
sortKey: PasswordSiteSortKey;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:sortKey": [value: PasswordSiteSortKey];
|
||||
showProfiles: [url: string];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="table-section">
|
||||
<div v-if="passwordSites.length" class="data-table">
|
||||
<div class="data-table-header passwords-grid">
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'domain' }" type="button" @click="emit('update:sortKey', 'domain')">域名</button>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'url' }" type="button" @click="emit('update:sortKey', 'url')">URL</button>
|
||||
<div class="header-cell actions-cell">关联资料</div>
|
||||
</div>
|
||||
<div class="data-table-body styled-scrollbar">
|
||||
<article
|
||||
v-for="passwordSite in passwordSites"
|
||||
:key="passwordSite.url"
|
||||
class="data-table-row passwords-grid"
|
||||
>
|
||||
<div class="row-cell primary-cell">
|
||||
<strong>{{ passwordSite.domain }}</strong>
|
||||
</div>
|
||||
<div class="row-cell muted-cell" :title="passwordSite.url">{{ passwordSite.url }}</div>
|
||||
<div class="row-cell actions-cell">
|
||||
<button class="disclosure-button" type="button" @click="emit('showProfiles', passwordSite.url)">
|
||||
<span>查看</span>
|
||||
<span class="badge neutral">{{ passwordSite.profileIds.length }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-card">
|
||||
<p>这个浏览器没有扫描到任何已保存登录站点。</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.table-section {
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.data-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
||||
border-radius: 22px;
|
||||
background: var(--panel);
|
||||
box-shadow: var(--shadow);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.data-table-body {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.passwords-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(180px, 0.9fr) minmax(280px, 1.2fr) 154px;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.data-table-header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
padding: 8px 24px 8px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.14);
|
||||
background: rgba(248, 250, 252, 0.94);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.header-cell {
|
||||
color: var(--muted);
|
||||
font-size: 0.81rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.header-cell.sortable {
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.header-cell.sortable.active {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.data-table-row {
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.12);
|
||||
}
|
||||
|
||||
.data-table-row:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.data-table-row:hover {
|
||||
background: rgba(248, 250, 252, 0.65);
|
||||
}
|
||||
|
||||
.row-cell {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.primary-cell strong {
|
||||
display: block;
|
||||
font-size: 0.93rem;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.muted-cell {
|
||||
color: var(--muted);
|
||||
font-size: 0.87rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.disclosure-button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
width: fit-content;
|
||||
min-width: 120px;
|
||||
padding: 7px 10px;
|
||||
border-radius: 12px;
|
||||
background: rgba(241, 245, 249, 0.9);
|
||||
color: var(--badge-text);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.actions-cell {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.passwords-grid {
|
||||
grid-template-columns: minmax(160px, 0.9fr) minmax(200px, 1fr) 148px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.passwords-grid {
|
||||
grid-template-columns: minmax(0, 1fr) 132px;
|
||||
}
|
||||
|
||||
.passwords-grid > :nth-child(2) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -25,11 +25,11 @@ const emit = defineEmits<{
|
||||
|
||||
<div v-if="profiles.length" class="data-table">
|
||||
<div class="data-table-header profiles-grid">
|
||||
<div class="header-cell icon-cell">Avatar</div>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'name' }" type="button" @click="emit('update:sortKey', 'name')">Name</button>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'email' }" type="button" @click="emit('update:sortKey', 'email')">Email</button>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'id' }" type="button" @click="emit('update:sortKey', 'id')">Profile ID</button>
|
||||
<div class="header-cell actions-cell">Action</div>
|
||||
<div class="header-cell icon-cell">头像</div>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'name' }" type="button" @click="emit('update:sortKey', 'name')">名称</button>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'email' }" type="button" @click="emit('update:sortKey', 'email')">邮箱</button>
|
||||
<button class="header-cell sortable" :class="{ active: sortKey === 'id' }" type="button" @click="emit('update:sortKey', 'id')">资料 ID</button>
|
||||
<div class="header-cell actions-cell">操作</div>
|
||||
</div>
|
||||
<div class="data-table-body styled-scrollbar">
|
||||
<article v-for="profile in profiles" :key="profile.id" class="data-table-row profiles-grid">
|
||||
@@ -57,14 +57,14 @@ const emit = defineEmits<{
|
||||
type="button"
|
||||
@click="emit('openProfile', browserId, profile.id)"
|
||||
>
|
||||
{{ isOpeningProfile(browserId, profile.id) ? "Opening..." : "Open" }}
|
||||
{{ isOpeningProfile(browserId, profile.id) ? "打开中..." : "打开" }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-card">
|
||||
<p>No profile directories were found for this browser.</p>
|
||||
<p>这个浏览器没有找到任何用户资料目录。</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -91,6 +91,7 @@ const emit = defineEmits<{
|
||||
.data-table-body {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.profiles-grid {
|
||||
@@ -104,7 +105,7 @@ const emit = defineEmits<{
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
padding: 10px 14px;
|
||||
padding: 8px 24px 8px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.14);
|
||||
background: rgba(248, 250, 252, 0.94);
|
||||
backdrop-filter: blur(12px);
|
||||
@@ -130,7 +131,7 @@ const emit = defineEmits<{
|
||||
}
|
||||
|
||||
.data-table-row {
|
||||
padding: 12px 14px;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.12);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,29 +45,28 @@ const iconOptions = computed(() =>
|
||||
<div class="config-form-card">
|
||||
<div class="config-form-header collapsible">
|
||||
<div>
|
||||
<h3>Add Custom Browser</h3>
|
||||
<p>Add a custom executable and Chromium user data path when needed.</p>
|
||||
<h3>添加自定义浏览器</h3>
|
||||
</div>
|
||||
<button
|
||||
class="secondary-button config-toggle-button"
|
||||
type="button"
|
||||
@click="formExpanded = !formExpanded"
|
||||
>
|
||||
{{ formExpanded ? "Collapse" : "Expand" }}
|
||||
{{ formExpanded ? "收起" : "展开" }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="formExpanded" class="config-form-fields compact">
|
||||
<div class="config-inline-row">
|
||||
<label class="field-group">
|
||||
<span>Name</span>
|
||||
<span>名称</span>
|
||||
<input
|
||||
:value="createConfigForm.name"
|
||||
placeholder="Work Chrome"
|
||||
placeholder="例如:工作 Chrome"
|
||||
@input="emit('updateName', ($event.target as HTMLInputElement).value)"
|
||||
/>
|
||||
</label>
|
||||
<label class="field-group">
|
||||
<span>Icon</span>
|
||||
<span>图标</span>
|
||||
<SortDropdown
|
||||
:model-value="createConfigForm.iconKey ?? 'chrome'"
|
||||
:options="iconOptions"
|
||||
@@ -76,7 +75,7 @@ const iconOptions = computed(() =>
|
||||
</label>
|
||||
</div>
|
||||
<label class="field-group">
|
||||
<span>Executable Path</span>
|
||||
<span>可执行文件路径</span>
|
||||
<div class="path-input-row">
|
||||
<input
|
||||
:value="createConfigForm.executablePath"
|
||||
@@ -84,12 +83,12 @@ const iconOptions = computed(() =>
|
||||
@input="emit('updateExecutablePath', ($event.target as HTMLInputElement).value)"
|
||||
/>
|
||||
<button class="secondary-button" type="button" @click="emit('pickExecutablePath')">
|
||||
Browse File
|
||||
选择文件
|
||||
</button>
|
||||
</div>
|
||||
</label>
|
||||
<label class="field-group">
|
||||
<span>User Data Path</span>
|
||||
<span>用户资料路径</span>
|
||||
<div class="path-input-row">
|
||||
<input
|
||||
:value="createConfigForm.userDataPath"
|
||||
@@ -97,7 +96,7 @@ const iconOptions = computed(() =>
|
||||
@input="emit('updateUserDataPath', ($event.target as HTMLInputElement).value)"
|
||||
/>
|
||||
<button class="secondary-button" type="button" @click="emit('pickUserDataPath')">
|
||||
Browse Folder
|
||||
选择文件夹
|
||||
</button>
|
||||
</div>
|
||||
</label>
|
||||
@@ -108,17 +107,14 @@ const iconOptions = computed(() =>
|
||||
:disabled="savingConfig"
|
||||
@click="emit('createConfig')"
|
||||
>
|
||||
{{ savingConfig ? "Saving..." : "Add Config" }}
|
||||
{{ savingConfig ? "保存中..." : "添加配置" }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="config-form-collapsed-note">
|
||||
<span>Collapsed by default to keep this page focused on existing configs.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="configsLoading" class="empty-card">
|
||||
<p>Loading browser configs...</p>
|
||||
<p>正在加载浏览器配置...</p>
|
||||
</div>
|
||||
<div v-else class="stack-list">
|
||||
<article
|
||||
@@ -149,16 +145,16 @@ const iconOptions = computed(() =>
|
||||
:disabled="isDeletingConfig(config.id)"
|
||||
@click="emit('deleteConfig', config.id)"
|
||||
>
|
||||
{{ isDeletingConfig(config.id) ? "Deleting..." : "Delete" }}
|
||||
{{ isDeletingConfig(config.id) ? "删除中..." : "删除" }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="config-meta">
|
||||
<div class="config-meta-row">
|
||||
<span class="config-label">Executable</span>
|
||||
<p :title="config.executablePath">{{ config.executablePath || "Not resolved" }}</p>
|
||||
<span class="config-label">可执行文件</span>
|
||||
<p :title="config.executablePath">{{ config.executablePath || "未解析" }}</p>
|
||||
</div>
|
||||
<div class="config-meta-row">
|
||||
<span class="config-label">User Data</span>
|
||||
<span class="config-label">用户资料</span>
|
||||
<p :title="config.userDataPath">{{ config.userDataPath }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -188,7 +184,8 @@ const iconOptions = computed(() =>
|
||||
.config-form-header h3,
|
||||
.config-title-row h4 {
|
||||
margin: 0;
|
||||
font-size: 0.94rem;
|
||||
font-size: 1.1rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.config-form-header.collapsible {
|
||||
@@ -198,7 +195,6 @@ const iconOptions = computed(() =>
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.config-form-header p,
|
||||
.config-meta-row p {
|
||||
margin: 6px 0 0;
|
||||
color: var(--muted);
|
||||
@@ -221,16 +217,6 @@ const iconOptions = computed(() =>
|
||||
align-items: end;
|
||||
}
|
||||
|
||||
.config-form-collapsed-note {
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 12px;
|
||||
background: rgba(248, 250, 252, 0.78);
|
||||
border: 1px solid rgba(148, 163, 184, 0.12);
|
||||
color: var(--muted);
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.field-group {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
@@ -265,11 +251,12 @@ const iconOptions = computed(() =>
|
||||
.field-group :deep(.sort-dropdown-trigger) {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
min-height: 40px;
|
||||
}
|
||||
|
||||
.path-input-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
grid-template-columns: minmax(0, 1fr) 118px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
@@ -277,6 +264,11 @@ const iconOptions = computed(() =>
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.path-input-row .secondary-button {
|
||||
width: 118px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.config-form-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
import { browserIconSrc, configurationIconSrc } from "../../utils/icons";
|
||||
import type { AppPage, BrowserView } from "../../types/browser";
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
browsers: BrowserView[];
|
||||
currentBrowserId: string | null;
|
||||
page: AppPage;
|
||||
loading: boolean;
|
||||
configsLoading: boolean;
|
||||
browserMonogram: (browserId: string) => string;
|
||||
appVersion: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -22,7 +23,7 @@ const emit = defineEmits<{
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-toolbar">
|
||||
<div class="sidebar-title-group">
|
||||
<h1>Browser Assistant</h1>
|
||||
<h1>浏览器助手</h1>
|
||||
</div>
|
||||
<button class="refresh-icon-button" type="button" @click="emit('refresh')">
|
||||
<svg class="refresh-icon" viewBox="0 0 24 24" aria-hidden="true">
|
||||
@@ -35,7 +36,7 @@ const emit = defineEmits<{
|
||||
stroke-width="2"
|
||||
/>
|
||||
</svg>
|
||||
<span class="sr-only">{{ loading || configsLoading ? "Refreshing..." : "Refresh" }}</span>
|
||||
<span class="sr-only">{{ loading || configsLoading ? "刷新中..." : "刷新" }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -63,7 +64,7 @@ const emit = defineEmits<{
|
||||
</div>
|
||||
|
||||
<div v-else class="sidebar-empty">
|
||||
<p>No supported Chromium browser data was found yet.</p>
|
||||
<p>暂未找到受支持的 Chromium 浏览器数据。</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
@@ -73,11 +74,12 @@ const emit = defineEmits<{
|
||||
@click="emit('selectConfiguration')"
|
||||
>
|
||||
<div class="browser-nav-icon config-nav-icon">
|
||||
<img :src="configurationIconSrc" alt="Configuration icon" />
|
||||
<img :src="configurationIconSrc" alt="配置图标" />
|
||||
</div>
|
||||
<div class="browser-nav-body">
|
||||
<strong>Configuration</strong>
|
||||
<strong>配置</strong>
|
||||
</div>
|
||||
<span class="utility-version" :title="`版本 ${props.appVersion}`">v{{ props.appVersion }}</span>
|
||||
</button>
|
||||
</aside>
|
||||
</template>
|
||||
@@ -255,6 +257,8 @@ const emit = defineEmits<{
|
||||
|
||||
.sidebar-utility-nav {
|
||||
margin-top: auto;
|
||||
position: relative;
|
||||
padding-right: 70px;
|
||||
}
|
||||
|
||||
.browser-nav-body {
|
||||
@@ -268,6 +272,18 @@ const emit = defineEmits<{
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.utility-version {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: rgba(82, 98, 119, 0.7);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.01em;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sidebar-empty {
|
||||
padding: 14px;
|
||||
border-radius: 14px;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { computed, onMounted, ref, watch } from "vue";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { open } from "@tauri-apps/plugin-dialog";
|
||||
|
||||
import { sortBookmarks, sortExtensions, sortProfiles } from "../utils/sort";
|
||||
import { sortBookmarks, sortExtensions, sortPasswordSites, sortProfiles } from "../utils/sort";
|
||||
import type {
|
||||
ActiveSection,
|
||||
AppPage,
|
||||
@@ -12,9 +12,19 @@ import type {
|
||||
BrowserConfigEntry,
|
||||
BrowserConfigListResponse,
|
||||
BrowserView,
|
||||
BookmarkRemovalRequest,
|
||||
CleanupHistoryInput,
|
||||
CleanupHistoryResponse,
|
||||
CreateCustomBrowserConfigInput,
|
||||
ExtensionRemovalRequest,
|
||||
ExtensionSummary,
|
||||
ExtensionSortKey,
|
||||
PasswordSiteSortKey,
|
||||
ProfileSortKey,
|
||||
RemoveBookmarksInput,
|
||||
RemoveBookmarksResponse,
|
||||
RemoveExtensionsInput,
|
||||
RemoveExtensionsResponse,
|
||||
ScanResponse,
|
||||
} from "../types/browser";
|
||||
|
||||
@@ -41,12 +51,44 @@ export function useBrowserManager() {
|
||||
const associatedProfilesModal = ref<{
|
||||
title: string;
|
||||
browserId: string;
|
||||
profiles: (AssociatedProfileSummary | BookmarkAssociatedProfileSummary)[];
|
||||
profiles: (
|
||||
| AssociatedProfileSummary
|
||||
| BookmarkAssociatedProfileSummary
|
||||
| ExtensionSummary["profiles"][number]
|
||||
)[];
|
||||
isBookmark: boolean;
|
||||
isExtension?: boolean;
|
||||
extensionId?: string;
|
||||
bookmarkUrl?: string;
|
||||
} | null>(null);
|
||||
const profileSortKey = ref<ProfileSortKey>("name");
|
||||
const extensionSortKey = ref<ExtensionSortKey>("name");
|
||||
const bookmarkSortKey = ref<BookmarkSortKey>("title");
|
||||
const passwordSiteSortKey = ref<PasswordSiteSortKey>("domain");
|
||||
const bookmarkSelectedUrls = ref<string[]>([]);
|
||||
const bookmarkModalSelectedProfileIds = ref<string[]>([]);
|
||||
const bookmarkDeleteBusy = ref(false);
|
||||
const bookmarkRemovalError = ref("");
|
||||
const bookmarkRemovalResults = ref<RemoveBookmarksResponse["results"]>([]);
|
||||
const bookmarkRemovalResultOpen = ref(false);
|
||||
const bookmarkRemovalConfirmRemovals = ref<BookmarkRemovalRequest[]>([]);
|
||||
const bookmarkRemovalConfirmUrls = ref<string[]>([]);
|
||||
const bookmarkRemovalConfirmProfileIds = ref<string[]>([]);
|
||||
const extensionSelectedIds = ref<string[]>([]);
|
||||
const extensionModalSelectedProfileIds = ref<string[]>([]);
|
||||
const extensionDeleteBusy = ref(false);
|
||||
const extensionRemovalError = ref("");
|
||||
const extensionRemovalResults = ref<RemoveExtensionsResponse["results"]>([]);
|
||||
const extensionRemovalResultOpen = ref(false);
|
||||
const extensionRemovalConfirmRemovals = ref<ExtensionRemovalRequest[]>([]);
|
||||
const extensionRemovalConfirmExtensionIds = ref<string[]>([]);
|
||||
const extensionRemovalConfirmProfileIds = ref<string[]>([]);
|
||||
const cleanupHistorySelectedProfiles = ref<string[]>([]);
|
||||
const historyCleanupBusy = ref(false);
|
||||
const cleanupHistoryError = ref("");
|
||||
const cleanupHistoryResults = ref<CleanupHistoryResponse["results"]>([]);
|
||||
const historyCleanupConfirmProfileIds = ref<string[]>([]);
|
||||
const historyCleanupResultOpen = ref(false);
|
||||
|
||||
const browsers = computed(() => response.value.browsers);
|
||||
const currentBrowser = computed<BrowserView | null>(
|
||||
@@ -65,6 +107,9 @@ export function useBrowserManager() {
|
||||
const sortedBookmarks = computed(() =>
|
||||
sortBookmarks(currentBrowser.value?.bookmarks ?? [], bookmarkSortKey.value),
|
||||
);
|
||||
const sortedPasswordSites = computed(() =>
|
||||
sortPasswordSites(currentBrowser.value?.passwordSites ?? [], passwordSiteSortKey.value),
|
||||
);
|
||||
|
||||
watch(
|
||||
browsers,
|
||||
@@ -88,6 +133,27 @@ export function useBrowserManager() {
|
||||
watch(selectedBrowserId, () => {
|
||||
openProfileError.value = "";
|
||||
associatedProfilesModal.value = null;
|
||||
cleanupHistorySelectedProfiles.value = [];
|
||||
cleanupHistoryResults.value = [];
|
||||
cleanupHistoryError.value = "";
|
||||
bookmarkSelectedUrls.value = [];
|
||||
bookmarkModalSelectedProfileIds.value = [];
|
||||
bookmarkRemovalError.value = "";
|
||||
bookmarkRemovalResults.value = [];
|
||||
bookmarkRemovalResultOpen.value = false;
|
||||
bookmarkRemovalConfirmRemovals.value = [];
|
||||
bookmarkRemovalConfirmUrls.value = [];
|
||||
bookmarkRemovalConfirmProfileIds.value = [];
|
||||
extensionSelectedIds.value = [];
|
||||
extensionModalSelectedProfileIds.value = [];
|
||||
extensionRemovalError.value = "";
|
||||
extensionRemovalResults.value = [];
|
||||
extensionRemovalResultOpen.value = false;
|
||||
extensionRemovalConfirmRemovals.value = [];
|
||||
extensionRemovalConfirmExtensionIds.value = [];
|
||||
extensionRemovalConfirmProfileIds.value = [];
|
||||
historyCleanupConfirmProfileIds.value = [];
|
||||
historyCleanupResultOpen.value = false;
|
||||
});
|
||||
|
||||
async function loadBrowserConfigs() {
|
||||
@@ -99,7 +165,7 @@ export function useBrowserManager() {
|
||||
browserConfigs.value = result.configs;
|
||||
} catch (loadError) {
|
||||
configError.value =
|
||||
loadError instanceof Error ? loadError.message : "Failed to load browser configs.";
|
||||
loadError instanceof Error ? loadError.message : "加载浏览器配置失败。";
|
||||
} finally {
|
||||
configsLoading.value = false;
|
||||
}
|
||||
@@ -115,7 +181,7 @@ export function useBrowserManager() {
|
||||
error.value =
|
||||
scanError instanceof Error
|
||||
? scanError.message
|
||||
: "Failed to scan browser data.";
|
||||
: "扫描浏览器数据失败。";
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -139,7 +205,7 @@ export function useBrowserManager() {
|
||||
openProfileError.value =
|
||||
openError instanceof Error
|
||||
? openError.message
|
||||
: "Failed to open the selected browser profile.";
|
||||
: "打开所选浏览器资料失败。";
|
||||
} finally {
|
||||
openingProfileKey.value = "";
|
||||
}
|
||||
@@ -163,7 +229,7 @@ export function useBrowserManager() {
|
||||
await scanBrowsers();
|
||||
} catch (saveError) {
|
||||
configError.value =
|
||||
saveError instanceof Error ? saveError.message : "Failed to create browser config.";
|
||||
saveError instanceof Error ? saveError.message : "创建浏览器配置失败。";
|
||||
} finally {
|
||||
savingConfig.value = false;
|
||||
}
|
||||
@@ -181,7 +247,7 @@ export function useBrowserManager() {
|
||||
await scanBrowsers();
|
||||
} catch (deleteError) {
|
||||
configError.value =
|
||||
deleteError instanceof Error ? deleteError.message : "Failed to delete browser config.";
|
||||
deleteError instanceof Error ? deleteError.message : "删除浏览器配置失败。";
|
||||
} finally {
|
||||
deletingConfigId.value = "";
|
||||
}
|
||||
@@ -268,45 +334,609 @@ export function useBrowserManager() {
|
||||
return name.trim().slice(0, 1).toUpperCase() || "?";
|
||||
}
|
||||
|
||||
function domainFromUrl(url: string) {
|
||||
try {
|
||||
return new URL(url).hostname;
|
||||
} catch {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
function sectionCount(section: ActiveSection) {
|
||||
if (!currentBrowser.value) return 0;
|
||||
if (section === "profiles") return currentBrowser.value.profiles.length;
|
||||
if (section === "extensions") return currentBrowser.value.extensions.length;
|
||||
return currentBrowser.value.bookmarks.length;
|
||||
if (section === "bookmarks") return currentBrowser.value.bookmarks.length;
|
||||
if (section === "passwords") return currentBrowser.value.passwordSites.length;
|
||||
return currentBrowser.value.stats.historyCleanupProfileCount;
|
||||
}
|
||||
|
||||
function showExtensionProfilesModal(extensionId: string) {
|
||||
const extension = currentBrowser.value?.extensions.find((item) => item.id === extensionId);
|
||||
if (!extension || !currentBrowser.value) return;
|
||||
extensionModalSelectedProfileIds.value = [];
|
||||
associatedProfilesModal.value = {
|
||||
title: `${extension.name} Profiles`,
|
||||
title: extension.name,
|
||||
browserId: currentBrowser.value.browserId,
|
||||
profiles: extension.profiles,
|
||||
isBookmark: false,
|
||||
isExtension: true,
|
||||
extensionId,
|
||||
};
|
||||
}
|
||||
|
||||
function showBookmarkProfilesModal(url: string) {
|
||||
const bookmark = currentBrowser.value?.bookmarks.find((item) => item.url === url);
|
||||
if (!bookmark || !currentBrowser.value) return;
|
||||
bookmarkModalSelectedProfileIds.value = [];
|
||||
associatedProfilesModal.value = {
|
||||
title: `${bookmark.title} Profiles`,
|
||||
title: bookmark.title,
|
||||
browserId: currentBrowser.value.browserId,
|
||||
profiles: bookmark.profiles,
|
||||
isBookmark: true,
|
||||
bookmarkUrl: url,
|
||||
};
|
||||
}
|
||||
|
||||
function showPasswordSiteProfilesModal(url: string) {
|
||||
const passwordSite = currentBrowser.value?.passwordSites.find((item) => item.url === url);
|
||||
if (!passwordSite || !currentBrowser.value) return;
|
||||
associatedProfilesModal.value = {
|
||||
title: passwordSite.domain,
|
||||
browserId: currentBrowser.value.browserId,
|
||||
profiles: passwordSite.profiles,
|
||||
isBookmark: false,
|
||||
};
|
||||
}
|
||||
|
||||
function toggleHistoryProfile(profileId: string) {
|
||||
if (cleanupHistorySelectedProfiles.value.includes(profileId)) {
|
||||
cleanupHistorySelectedProfiles.value = cleanupHistorySelectedProfiles.value.filter(
|
||||
(selectedId) => selectedId !== profileId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
cleanupHistorySelectedProfiles.value = [
|
||||
...cleanupHistorySelectedProfiles.value,
|
||||
profileId,
|
||||
];
|
||||
}
|
||||
|
||||
function toggleAllHistoryProfiles() {
|
||||
const current = currentBrowser.value;
|
||||
if (!current) return;
|
||||
|
||||
const selectableIds = current.profiles
|
||||
.filter((profile) => {
|
||||
const cleanup = profile.historyCleanup;
|
||||
return (
|
||||
cleanup.history === "found" ||
|
||||
cleanup.topSites === "found" ||
|
||||
cleanup.visitedLinks === "found" ||
|
||||
cleanup.sessions === "found"
|
||||
);
|
||||
})
|
||||
.map((profile) => profile.id);
|
||||
|
||||
const allSelected =
|
||||
selectableIds.length > 0 &&
|
||||
selectableIds.every((profileId) =>
|
||||
cleanupHistorySelectedProfiles.value.includes(profileId),
|
||||
);
|
||||
|
||||
cleanupHistorySelectedProfiles.value = allSelected ? [] : selectableIds;
|
||||
}
|
||||
|
||||
function cleanupProfileIdsWithHistory(browser: BrowserView) {
|
||||
return browser.profiles
|
||||
.filter((profile) => {
|
||||
const cleanup = profile.historyCleanup;
|
||||
return (
|
||||
cleanup.history === "found" ||
|
||||
cleanup.topSites === "found" ||
|
||||
cleanup.visitedLinks === "found" ||
|
||||
cleanup.sessions === "found"
|
||||
);
|
||||
})
|
||||
.map((profile) => profile.id);
|
||||
}
|
||||
|
||||
function historyCleanupConfirmProfiles() {
|
||||
const browser = currentBrowser.value;
|
||||
if (!browser) return [];
|
||||
return browser.profiles.filter((profile) =>
|
||||
historyCleanupConfirmProfileIds.value.includes(profile.id),
|
||||
);
|
||||
}
|
||||
|
||||
function cleanupSelectedHistoryProfiles() {
|
||||
if (!cleanupHistorySelectedProfiles.value.length) return;
|
||||
historyCleanupConfirmProfileIds.value = [...cleanupHistorySelectedProfiles.value];
|
||||
}
|
||||
|
||||
function cleanupHistoryForProfile(profileId: string) {
|
||||
historyCleanupConfirmProfileIds.value = [profileId];
|
||||
}
|
||||
|
||||
function closeHistoryCleanupConfirm() {
|
||||
if (historyCleanupBusy.value) return;
|
||||
historyCleanupConfirmProfileIds.value = [];
|
||||
}
|
||||
|
||||
function closeHistoryCleanupResult() {
|
||||
historyCleanupResultOpen.value = false;
|
||||
cleanupHistoryResults.value = [];
|
||||
cleanupHistoryError.value = "";
|
||||
}
|
||||
|
||||
function applyCleanupHistoryResults(results: CleanupHistoryResponse["results"]) {
|
||||
const browser = currentBrowser.value;
|
||||
if (!browser) return;
|
||||
|
||||
const succeededProfileIds = results
|
||||
.filter((result) => !result.error)
|
||||
.map((result) => result.profileId);
|
||||
|
||||
if (!succeededProfileIds.length) return;
|
||||
|
||||
for (const profile of browser.profiles) {
|
||||
if (!succeededProfileIds.includes(profile.id)) continue;
|
||||
|
||||
const deletedFiles = results.find((result) => result.profileId === profile.id)?.deletedFiles ?? [];
|
||||
if (deletedFiles.includes("History")) {
|
||||
profile.historyCleanup.history = "missing";
|
||||
}
|
||||
if (deletedFiles.includes("Top Sites")) {
|
||||
profile.historyCleanup.topSites = "missing";
|
||||
}
|
||||
if (deletedFiles.includes("Visited Links")) {
|
||||
profile.historyCleanup.visitedLinks = "missing";
|
||||
}
|
||||
if (deletedFiles.includes("Sessions")) {
|
||||
profile.historyCleanup.sessions = "missing";
|
||||
}
|
||||
}
|
||||
|
||||
browser.stats.historyCleanupProfileCount = cleanupProfileIdsWithHistory(browser).length;
|
||||
}
|
||||
|
||||
async function confirmHistoryCleanup() {
|
||||
const browser = currentBrowser.value;
|
||||
const profileIds = [...historyCleanupConfirmProfileIds.value];
|
||||
if (!browser || profileIds.length === 0) return;
|
||||
|
||||
if (!currentBrowser.value || profileIds.length === 0) return;
|
||||
|
||||
historyCleanupBusy.value = true;
|
||||
cleanupHistoryError.value = "";
|
||||
cleanupHistoryResults.value = [];
|
||||
historyCleanupResultOpen.value = false;
|
||||
|
||||
try {
|
||||
const input: CleanupHistoryInput = {
|
||||
browserId: browser.browserId,
|
||||
profileIds,
|
||||
};
|
||||
const result = await invoke<CleanupHistoryResponse>("cleanup_history_files", { input });
|
||||
applyCleanupHistoryResults(result.results);
|
||||
cleanupHistoryResults.value = result.results;
|
||||
cleanupHistorySelectedProfiles.value = cleanupHistorySelectedProfiles.value.filter(
|
||||
(profileId) => !profileIds.includes(profileId),
|
||||
);
|
||||
historyCleanupConfirmProfileIds.value = [];
|
||||
historyCleanupResultOpen.value = true;
|
||||
} catch (cleanupErrorValue) {
|
||||
historyCleanupConfirmProfileIds.value = [];
|
||||
cleanupHistoryError.value =
|
||||
cleanupErrorValue instanceof Error
|
||||
? cleanupErrorValue.message
|
||||
: "清理历史文件失败。";
|
||||
historyCleanupResultOpen.value = true;
|
||||
} finally {
|
||||
historyCleanupBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function closeAssociatedProfilesModal() {
|
||||
associatedProfilesModal.value = null;
|
||||
extensionModalSelectedProfileIds.value = [];
|
||||
bookmarkModalSelectedProfileIds.value = [];
|
||||
}
|
||||
|
||||
function toggleBookmarkSelection(url: string) {
|
||||
if (bookmarkSelectedUrls.value.includes(url)) {
|
||||
bookmarkSelectedUrls.value = bookmarkSelectedUrls.value.filter((item) => item !== url);
|
||||
return;
|
||||
}
|
||||
|
||||
bookmarkSelectedUrls.value = [...bookmarkSelectedUrls.value, url];
|
||||
}
|
||||
|
||||
function toggleAllBookmarks() {
|
||||
const bookmarkUrls = currentBrowser.value?.bookmarks.map((bookmark) => bookmark.url) ?? [];
|
||||
const allSelected =
|
||||
bookmarkUrls.length > 0 &&
|
||||
bookmarkUrls.every((url) => bookmarkSelectedUrls.value.includes(url));
|
||||
bookmarkSelectedUrls.value = allSelected ? [] : bookmarkUrls;
|
||||
}
|
||||
|
||||
function toggleBookmarkModalProfileSelection(profileId: string) {
|
||||
if (bookmarkModalSelectedProfileIds.value.includes(profileId)) {
|
||||
bookmarkModalSelectedProfileIds.value = bookmarkModalSelectedProfileIds.value.filter(
|
||||
(id) => id !== profileId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
bookmarkModalSelectedProfileIds.value = [...bookmarkModalSelectedProfileIds.value, profileId];
|
||||
}
|
||||
|
||||
function toggleAllBookmarkModalProfiles() {
|
||||
if (!associatedProfilesModal.value?.isBookmark) return;
|
||||
const profileIds = associatedProfilesModal.value.profiles.map((profile) => profile.id);
|
||||
const allSelected =
|
||||
profileIds.length > 0 &&
|
||||
profileIds.every((profileId) => bookmarkModalSelectedProfileIds.value.includes(profileId));
|
||||
bookmarkModalSelectedProfileIds.value = allSelected ? [] : profileIds;
|
||||
}
|
||||
|
||||
function bookmarkRemovalConfirmBookmarkCount() {
|
||||
return bookmarkRemovalConfirmUrls.value.length;
|
||||
}
|
||||
|
||||
function bookmarkRemovalConfirmProfileCount() {
|
||||
return bookmarkRemovalConfirmProfileIds.value.length;
|
||||
}
|
||||
|
||||
function requestBookmarkRemoval(removals: BookmarkRemovalRequest[]) {
|
||||
if (!removals.length) return;
|
||||
|
||||
bookmarkRemovalConfirmRemovals.value = removals;
|
||||
bookmarkRemovalConfirmUrls.value = [...new Set(removals.map((item) => item.url))];
|
||||
bookmarkRemovalConfirmProfileIds.value = [...new Set(removals.flatMap((item) => item.profileIds))];
|
||||
}
|
||||
|
||||
function resetBookmarkRemovalConfirmState() {
|
||||
bookmarkRemovalConfirmRemovals.value = [];
|
||||
bookmarkRemovalConfirmUrls.value = [];
|
||||
bookmarkRemovalConfirmProfileIds.value = [];
|
||||
}
|
||||
|
||||
function deleteBookmarkFromAllProfiles(url: string) {
|
||||
const bookmark = currentBrowser.value?.bookmarks.find((item) => item.url === url);
|
||||
if (!bookmark) return;
|
||||
|
||||
requestBookmarkRemoval([
|
||||
{
|
||||
url,
|
||||
profileIds: [...bookmark.profileIds],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
function deleteSelectedBookmarks() {
|
||||
const browser = currentBrowser.value;
|
||||
if (!browser || !bookmarkSelectedUrls.value.length) return;
|
||||
|
||||
const removals = browser.bookmarks
|
||||
.filter((bookmark) => bookmarkSelectedUrls.value.includes(bookmark.url))
|
||||
.map((bookmark) => ({
|
||||
url: bookmark.url,
|
||||
profileIds: [...bookmark.profileIds],
|
||||
}));
|
||||
requestBookmarkRemoval(removals);
|
||||
}
|
||||
|
||||
function deleteBookmarkFromProfile(profileId: string) {
|
||||
const modal = associatedProfilesModal.value;
|
||||
if (!modal?.isBookmark || !modal.bookmarkUrl) return;
|
||||
|
||||
requestBookmarkRemoval([
|
||||
{
|
||||
url: modal.bookmarkUrl,
|
||||
profileIds: [profileId],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
function deleteSelectedBookmarkProfiles() {
|
||||
const modal = associatedProfilesModal.value;
|
||||
if (!modal?.isBookmark || !modal.bookmarkUrl || !bookmarkModalSelectedProfileIds.value.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
requestBookmarkRemoval([
|
||||
{
|
||||
url: modal.bookmarkUrl,
|
||||
profileIds: [...bookmarkModalSelectedProfileIds.value],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
function closeBookmarkRemovalConfirm() {
|
||||
if (bookmarkDeleteBusy.value) return;
|
||||
resetBookmarkRemovalConfirmState();
|
||||
}
|
||||
|
||||
function closeBookmarkRemovalResult() {
|
||||
bookmarkRemovalResultOpen.value = false;
|
||||
bookmarkRemovalResults.value = [];
|
||||
bookmarkRemovalError.value = "";
|
||||
}
|
||||
|
||||
function applyBookmarkRemovalResults(results: RemoveBookmarksResponse["results"]) {
|
||||
const browser = currentBrowser.value;
|
||||
if (!browser) return;
|
||||
|
||||
for (const result of results) {
|
||||
if (result.error || result.removedCount === 0) continue;
|
||||
const bookmark = browser.bookmarks.find((item) => item.url === result.url);
|
||||
if (!bookmark) continue;
|
||||
|
||||
bookmark.profileIds = bookmark.profileIds.filter((id) => id !== result.profileId);
|
||||
bookmark.profiles = bookmark.profiles.filter((profile) => profile.id !== result.profileId);
|
||||
}
|
||||
|
||||
browser.bookmarks = browser.bookmarks.filter((bookmark) => bookmark.profileIds.length > 0);
|
||||
browser.stats.bookmarkCount = browser.bookmarks.length;
|
||||
|
||||
bookmarkSelectedUrls.value = bookmarkSelectedUrls.value.filter((selectedUrl) =>
|
||||
browser.bookmarks.some((bookmark) => bookmark.url === selectedUrl),
|
||||
);
|
||||
|
||||
if (associatedProfilesModal.value?.isBookmark) {
|
||||
const currentBookmark = browser.bookmarks.find(
|
||||
(bookmark) => bookmark.url === associatedProfilesModal.value?.bookmarkUrl,
|
||||
);
|
||||
if (!currentBookmark) {
|
||||
associatedProfilesModal.value = null;
|
||||
bookmarkModalSelectedProfileIds.value = [];
|
||||
} else {
|
||||
associatedProfilesModal.value = {
|
||||
...associatedProfilesModal.value,
|
||||
title: currentBookmark.title,
|
||||
profiles: currentBookmark.profiles,
|
||||
};
|
||||
bookmarkModalSelectedProfileIds.value = bookmarkModalSelectedProfileIds.value.filter((id) =>
|
||||
currentBookmark.profiles.some((profile) => profile.id === id),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmBookmarkRemoval() {
|
||||
const browser = currentBrowser.value;
|
||||
const removals = bookmarkRemovalConfirmRemovals.value.map((item) => ({
|
||||
url: item.url,
|
||||
profileIds: [...item.profileIds],
|
||||
}));
|
||||
if (!browser || !removals.length) return;
|
||||
|
||||
bookmarkDeleteBusy.value = true;
|
||||
bookmarkRemovalError.value = "";
|
||||
bookmarkRemovalResults.value = [];
|
||||
bookmarkRemovalResultOpen.value = false;
|
||||
|
||||
try {
|
||||
const input: RemoveBookmarksInput = {
|
||||
browserId: browser.browserId,
|
||||
removals,
|
||||
};
|
||||
const result = await invoke<RemoveBookmarksResponse>("remove_bookmarks", { input });
|
||||
applyBookmarkRemovalResults(result.results);
|
||||
bookmarkRemovalResults.value = result.results;
|
||||
resetBookmarkRemovalConfirmState();
|
||||
bookmarkRemovalResultOpen.value = true;
|
||||
} catch (removeError) {
|
||||
resetBookmarkRemovalConfirmState();
|
||||
bookmarkRemovalError.value =
|
||||
removeError instanceof Error ? removeError.message : "删除书签失败。";
|
||||
bookmarkRemovalResultOpen.value = true;
|
||||
} finally {
|
||||
bookmarkDeleteBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleExtensionSelection(extensionId: string) {
|
||||
if (extensionSelectedIds.value.includes(extensionId)) {
|
||||
extensionSelectedIds.value = extensionSelectedIds.value.filter((id) => id !== extensionId);
|
||||
return;
|
||||
}
|
||||
|
||||
extensionSelectedIds.value = [...extensionSelectedIds.value, extensionId];
|
||||
}
|
||||
|
||||
function toggleAllExtensions() {
|
||||
const extensionIds = currentBrowser.value?.extensions.map((extension) => extension.id) ?? [];
|
||||
const allSelected =
|
||||
extensionIds.length > 0 &&
|
||||
extensionIds.every((extensionId) => extensionSelectedIds.value.includes(extensionId));
|
||||
extensionSelectedIds.value = allSelected ? [] : extensionIds;
|
||||
}
|
||||
|
||||
function toggleExtensionModalProfileSelection(profileId: string) {
|
||||
if (extensionModalSelectedProfileIds.value.includes(profileId)) {
|
||||
extensionModalSelectedProfileIds.value = extensionModalSelectedProfileIds.value.filter(
|
||||
(id) => id !== profileId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
extensionModalSelectedProfileIds.value = [
|
||||
...extensionModalSelectedProfileIds.value,
|
||||
profileId,
|
||||
];
|
||||
}
|
||||
|
||||
function toggleAllExtensionModalProfiles() {
|
||||
if (!associatedProfilesModal.value?.isExtension) return;
|
||||
const profileIds = associatedProfilesModal.value.profiles.map((profile) => profile.id);
|
||||
const allSelected =
|
||||
profileIds.length > 0 &&
|
||||
profileIds.every((profileId) => extensionModalSelectedProfileIds.value.includes(profileId));
|
||||
extensionModalSelectedProfileIds.value = allSelected ? [] : profileIds;
|
||||
}
|
||||
|
||||
function extensionRemovalConfirmExtensions() {
|
||||
const browser = currentBrowser.value;
|
||||
if (!browser) return [];
|
||||
return browser.extensions.filter((extension) =>
|
||||
extensionRemovalConfirmExtensionIds.value.includes(extension.id),
|
||||
);
|
||||
}
|
||||
|
||||
function extensionRemovalConfirmProfiles() {
|
||||
const browser = currentBrowser.value;
|
||||
if (!browser) return [];
|
||||
return browser.profiles.filter((profile) =>
|
||||
extensionRemovalConfirmProfileIds.value.includes(profile.id),
|
||||
);
|
||||
}
|
||||
|
||||
function requestExtensionRemoval(removals: ExtensionRemovalRequest[]) {
|
||||
if (!removals.length) return;
|
||||
|
||||
extensionRemovalConfirmRemovals.value = removals;
|
||||
extensionRemovalConfirmExtensionIds.value = [...new Set(removals.map((item) => item.extensionId))];
|
||||
extensionRemovalConfirmProfileIds.value = [
|
||||
...new Set(removals.flatMap((item) => item.profileIds)),
|
||||
];
|
||||
}
|
||||
|
||||
function resetExtensionRemovalConfirmState() {
|
||||
extensionRemovalConfirmRemovals.value = [];
|
||||
extensionRemovalConfirmExtensionIds.value = [];
|
||||
extensionRemovalConfirmProfileIds.value = [];
|
||||
}
|
||||
|
||||
function deleteExtensionFromAllProfiles(extensionId: string) {
|
||||
const extension = currentBrowser.value?.extensions.find((item) => item.id === extensionId);
|
||||
if (!extension) return;
|
||||
requestExtensionRemoval([
|
||||
{
|
||||
extensionId,
|
||||
profileIds: [...extension.profileIds],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
function deleteSelectedExtensions() {
|
||||
const browser = currentBrowser.value;
|
||||
if (!browser || !extensionSelectedIds.value.length) return;
|
||||
|
||||
const removals = browser.extensions
|
||||
.filter((extension) => extensionSelectedIds.value.includes(extension.id))
|
||||
.map((extension) => ({
|
||||
extensionId: extension.id,
|
||||
profileIds: [...extension.profileIds],
|
||||
}));
|
||||
requestExtensionRemoval(removals);
|
||||
}
|
||||
|
||||
function deleteExtensionFromProfile(profileId: string) {
|
||||
const modal = associatedProfilesModal.value;
|
||||
if (!modal?.isExtension || !modal.extensionId) {
|
||||
return;
|
||||
}
|
||||
requestExtensionRemoval([
|
||||
{
|
||||
extensionId: modal.extensionId,
|
||||
profileIds: [profileId],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
function deleteSelectedExtensionProfiles() {
|
||||
const modal = associatedProfilesModal.value;
|
||||
if (
|
||||
!modal?.isExtension ||
|
||||
!modal.extensionId ||
|
||||
!extensionModalSelectedProfileIds.value.length
|
||||
) {
|
||||
return;
|
||||
}
|
||||
requestExtensionRemoval([
|
||||
{
|
||||
extensionId: modal.extensionId,
|
||||
profileIds: [...extensionModalSelectedProfileIds.value],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
function closeExtensionRemovalConfirm() {
|
||||
if (extensionDeleteBusy.value) return;
|
||||
resetExtensionRemovalConfirmState();
|
||||
}
|
||||
|
||||
function closeExtensionRemovalResult() {
|
||||
extensionRemovalResultOpen.value = false;
|
||||
extensionRemovalResults.value = [];
|
||||
extensionRemovalError.value = "";
|
||||
}
|
||||
|
||||
function applyExtensionRemovalResults(results: RemoveExtensionsResponse["results"]) {
|
||||
const browser = currentBrowser.value;
|
||||
if (!browser) return;
|
||||
|
||||
for (const result of results) {
|
||||
if (result.error) continue;
|
||||
const extension = browser.extensions.find((item) => item.id === result.extensionId);
|
||||
if (!extension) continue;
|
||||
|
||||
extension.profileIds = extension.profileIds.filter((id) => id !== result.profileId);
|
||||
extension.profiles = extension.profiles.filter((profile) => profile.id !== result.profileId);
|
||||
}
|
||||
|
||||
browser.extensions = browser.extensions.filter((extension) => extension.profileIds.length > 0);
|
||||
browser.stats.extensionCount = browser.extensions.length;
|
||||
|
||||
extensionSelectedIds.value = extensionSelectedIds.value.filter((selectedId) =>
|
||||
browser.extensions.some((extension) => extension.id === selectedId),
|
||||
);
|
||||
|
||||
if (associatedProfilesModal.value?.isExtension && "extensionId" in associatedProfilesModal.value) {
|
||||
const currentExtension = browser.extensions.find(
|
||||
(extension) => extension.id === associatedProfilesModal.value?.extensionId,
|
||||
);
|
||||
if (!currentExtension) {
|
||||
associatedProfilesModal.value = null;
|
||||
extensionModalSelectedProfileIds.value = [];
|
||||
} else {
|
||||
associatedProfilesModal.value = {
|
||||
...associatedProfilesModal.value,
|
||||
profiles: currentExtension.profiles,
|
||||
};
|
||||
extensionModalSelectedProfileIds.value = extensionModalSelectedProfileIds.value.filter((id) =>
|
||||
currentExtension.profiles.some((profile) => profile.id === id),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmExtensionRemoval() {
|
||||
const browser = currentBrowser.value;
|
||||
const removals = extensionRemovalConfirmRemovals.value.map((item) => ({
|
||||
extensionId: item.extensionId,
|
||||
profileIds: [...item.profileIds],
|
||||
}));
|
||||
if (!browser || !removals.length) return;
|
||||
|
||||
extensionDeleteBusy.value = true;
|
||||
extensionRemovalError.value = "";
|
||||
extensionRemovalResults.value = [];
|
||||
extensionRemovalResultOpen.value = false;
|
||||
|
||||
try {
|
||||
const input: RemoveExtensionsInput = {
|
||||
browserId: browser.browserId,
|
||||
removals,
|
||||
};
|
||||
const result = await invoke<RemoveExtensionsResponse>("remove_extensions", { input });
|
||||
applyExtensionRemovalResults(result.results);
|
||||
extensionRemovalResults.value = result.results;
|
||||
resetExtensionRemovalConfirmState();
|
||||
extensionRemovalResultOpen.value = true;
|
||||
} catch (removeError) {
|
||||
resetExtensionRemovalConfirmState();
|
||||
extensionRemovalError.value =
|
||||
removeError instanceof Error ? removeError.message : "删除插件失败。";
|
||||
extensionRemovalResultOpen.value = true;
|
||||
} finally {
|
||||
extensionDeleteBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -317,6 +947,14 @@ export function useBrowserManager() {
|
||||
activeSection,
|
||||
associatedProfilesModal,
|
||||
bookmarkSortKey,
|
||||
bookmarkDeleteBusy,
|
||||
bookmarkModalSelectedProfileIds,
|
||||
bookmarkRemovalConfirmBookmarkCount: computed(bookmarkRemovalConfirmBookmarkCount),
|
||||
bookmarkRemovalConfirmProfileCount: computed(bookmarkRemovalConfirmProfileCount),
|
||||
bookmarkRemovalError,
|
||||
bookmarkRemovalResultOpen,
|
||||
bookmarkRemovalResults,
|
||||
bookmarkSelectedUrls,
|
||||
browserConfigs,
|
||||
browserMonogram,
|
||||
browsers,
|
||||
@@ -327,10 +965,35 @@ export function useBrowserManager() {
|
||||
createCustomBrowserConfig,
|
||||
currentBrowser,
|
||||
deleteCustomBrowserConfig,
|
||||
domainFromUrl,
|
||||
deleteBookmarkFromAllProfiles,
|
||||
deleteBookmarkFromProfile,
|
||||
deleteSelectedBookmarkProfiles,
|
||||
deleteSelectedBookmarks,
|
||||
deleteExtensionFromAllProfiles,
|
||||
deleteExtensionFromProfile,
|
||||
deleteSelectedExtensionProfiles,
|
||||
deleteSelectedExtensions,
|
||||
error,
|
||||
extensionMonogram,
|
||||
extensionDeleteBusy,
|
||||
extensionModalSelectedProfileIds,
|
||||
extensionRemovalConfirmExtensions: computed(extensionRemovalConfirmExtensions),
|
||||
extensionRemovalConfirmProfiles: computed(extensionRemovalConfirmProfiles),
|
||||
extensionRemovalError,
|
||||
extensionRemovalResultOpen,
|
||||
extensionRemovalResults,
|
||||
extensionSelectedIds,
|
||||
extensionSortKey,
|
||||
cleanupHistoryError,
|
||||
cleanupHistoryResults,
|
||||
cleanupHistorySelectedProfiles,
|
||||
cleanupSelectedHistoryProfiles,
|
||||
closeHistoryCleanupConfirm,
|
||||
closeHistoryCleanupResult,
|
||||
confirmHistoryCleanup,
|
||||
historyCleanupBusy,
|
||||
historyCleanupConfirmProfiles: computed(historyCleanupConfirmProfiles),
|
||||
historyCleanupResultOpen,
|
||||
isDeletingConfig,
|
||||
isOpeningProfile,
|
||||
loading,
|
||||
@@ -339,6 +1002,7 @@ export function useBrowserManager() {
|
||||
page,
|
||||
pickExecutablePath,
|
||||
pickUserDataPath,
|
||||
passwordSiteSortKey,
|
||||
profileSortKey,
|
||||
refreshAll,
|
||||
savingConfig,
|
||||
@@ -346,9 +1010,28 @@ export function useBrowserManager() {
|
||||
selectedBrowserId,
|
||||
showBookmarkProfilesModal,
|
||||
showExtensionProfilesModal,
|
||||
showPasswordSiteProfilesModal,
|
||||
sortedBookmarks,
|
||||
sortedExtensions,
|
||||
sortedPasswordSites,
|
||||
sortedProfiles,
|
||||
closeExtensionRemovalConfirm,
|
||||
closeExtensionRemovalResult,
|
||||
closeBookmarkRemovalConfirm,
|
||||
closeBookmarkRemovalResult,
|
||||
confirmExtensionRemoval,
|
||||
confirmBookmarkRemoval,
|
||||
cleanupHistoryForProfile,
|
||||
toggleAllBookmarks,
|
||||
toggleAllExtensions,
|
||||
toggleAllBookmarkModalProfiles,
|
||||
toggleAllExtensionModalProfiles,
|
||||
toggleBookmarkModalProfileSelection,
|
||||
toggleBookmarkSelection,
|
||||
toggleExtensionModalProfileSelection,
|
||||
toggleExtensionSelection,
|
||||
toggleAllHistoryProfiles,
|
||||
toggleHistoryProfile,
|
||||
closeAssociatedProfilesModal,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar,
|
||||
.content-panel {
|
||||
.sidebar {
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
}
|
||||
@@ -19,7 +18,7 @@
|
||||
gap: 10px;
|
||||
min-height: 0;
|
||||
padding: 4px 0;
|
||||
overflow: hidden;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.content-section,
|
||||
@@ -86,7 +85,7 @@
|
||||
|
||||
.content-scroll-area {
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
overflow: visible;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
@@ -174,6 +173,148 @@
|
||||
padding: 28px;
|
||||
}
|
||||
|
||||
.scanning-panel {
|
||||
justify-items: center;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
background:
|
||||
radial-gradient(circle at top, rgba(47, 111, 237, 0.16), transparent 38%),
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(243, 247, 252, 0.9));
|
||||
}
|
||||
|
||||
.scan-hero {
|
||||
position: relative;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 148px;
|
||||
height: 148px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.scan-core {
|
||||
position: relative;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 82px;
|
||||
height: 82px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(229, 238, 255, 0.92));
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.72),
|
||||
0 16px 40px rgba(47, 111, 237, 0.14);
|
||||
}
|
||||
|
||||
.scan-core-ring {
|
||||
position: absolute;
|
||||
inset: 12px;
|
||||
border: 1px solid rgba(47, 111, 237, 0.18);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.scan-core-ring.secondary {
|
||||
inset: 22px;
|
||||
border-color: rgba(16, 24, 40, 0.08);
|
||||
}
|
||||
|
||||
.scan-orbit {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: 50%;
|
||||
border: 1px solid rgba(47, 111, 237, 0.12);
|
||||
}
|
||||
|
||||
.orbit-one {
|
||||
animation: scan-spin 10s linear infinite;
|
||||
}
|
||||
|
||||
.orbit-two {
|
||||
inset: 18px;
|
||||
border-color: rgba(37, 99, 235, 0.18);
|
||||
animation: scan-spin-reverse 7.5s linear infinite;
|
||||
}
|
||||
|
||||
.scan-dot {
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, #2f6fed, #7db4ff);
|
||||
box-shadow: 0 0 0 6px rgba(47, 111, 237, 0.1);
|
||||
}
|
||||
|
||||
.dot-one {
|
||||
top: -4px;
|
||||
}
|
||||
|
||||
.dot-two {
|
||||
right: 6px;
|
||||
bottom: 14px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
.dot-three {
|
||||
left: 10px;
|
||||
bottom: 10px;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
}
|
||||
|
||||
.state-panel h2,
|
||||
.empty-card h3 {
|
||||
margin: 0;
|
||||
font-size: 1.12rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.state-panel p,
|
||||
.empty-card p {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.loading-steps {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.loading-steps span {
|
||||
width: 36px;
|
||||
height: 6px;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(90deg, rgba(47, 111, 237, 0.16), rgba(47, 111, 237, 0.44));
|
||||
animation: loading-pulse 1.6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.loading-steps span:nth-child(2) {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
.loading-steps span:nth-child(3) {
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
|
||||
.empty-card {
|
||||
min-height: 220px;
|
||||
place-content: center;
|
||||
justify-items: center;
|
||||
padding: 28px;
|
||||
border: 1px dashed rgba(148, 163, 184, 0.26);
|
||||
border-radius: 22px;
|
||||
background:
|
||||
radial-gradient(circle at top, rgba(47, 111, 237, 0.08), transparent 42%),
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(244, 247, 251, 0.78));
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty-card p {
|
||||
max-width: 460px;
|
||||
font-size: 0.94rem;
|
||||
}
|
||||
|
||||
.browser-nav,
|
||||
.styled-scrollbar {
|
||||
scrollbar-width: thin;
|
||||
@@ -201,8 +342,51 @@
|
||||
background: linear-gradient(180deg, rgba(254, 242, 242, 0.92), rgba(255, 255, 255, 0.86));
|
||||
}
|
||||
|
||||
@keyframes scan-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes scan-spin-reverse {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: rotate(-360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes loading-pulse {
|
||||
0%,
|
||||
100% {
|
||||
transform: scaleX(0.82);
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scaleX(1);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.sort-bar {
|
||||
justify-content: stretch;
|
||||
}
|
||||
|
||||
.scan-hero {
|
||||
width: 132px;
|
||||
height: 132px;
|
||||
}
|
||||
|
||||
.empty-card {
|
||||
min-height: 180px;
|
||||
padding: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ export type BrowserStats = {
|
||||
profileCount: number;
|
||||
extensionCount: number;
|
||||
bookmarkCount: number;
|
||||
passwordSiteCount: number;
|
||||
historyCleanupProfileCount: number;
|
||||
};
|
||||
|
||||
export type ProfileSummary = {
|
||||
@@ -14,6 +16,7 @@ export type ProfileSummary = {
|
||||
defaultAvatarStrokeColor: number | null;
|
||||
avatarLabel: string;
|
||||
path: string;
|
||||
historyCleanup: HistoryCleanupSummary;
|
||||
};
|
||||
|
||||
export type ExtensionSummary = {
|
||||
@@ -22,7 +25,7 @@ export type ExtensionSummary = {
|
||||
version: string | null;
|
||||
iconDataUrl: string | null;
|
||||
profileIds: string[];
|
||||
profiles: AssociatedProfileSummary[];
|
||||
profiles: ExtensionAssociatedProfileSummary[];
|
||||
};
|
||||
|
||||
export type BookmarkSummary = {
|
||||
@@ -32,6 +35,83 @@ export type BookmarkSummary = {
|
||||
profiles: BookmarkAssociatedProfileSummary[];
|
||||
};
|
||||
|
||||
export type PasswordSiteSummary = {
|
||||
url: string;
|
||||
domain: string;
|
||||
profileIds: string[];
|
||||
profiles: AssociatedProfileSummary[];
|
||||
};
|
||||
|
||||
export type HistoryCleanupSummary = {
|
||||
history: CleanupFileStatus;
|
||||
topSites: CleanupFileStatus;
|
||||
visitedLinks: CleanupFileStatus;
|
||||
sessions: CleanupFileStatus;
|
||||
};
|
||||
|
||||
export type CleanupFileStatus = "found" | "missing";
|
||||
|
||||
export type CleanupHistoryInput = {
|
||||
browserId: string;
|
||||
profileIds: string[];
|
||||
};
|
||||
|
||||
export type CleanupHistoryResult = {
|
||||
profileId: string;
|
||||
deletedFiles: string[];
|
||||
skippedFiles: string[];
|
||||
error: string | null;
|
||||
};
|
||||
|
||||
export type CleanupHistoryResponse = {
|
||||
results: CleanupHistoryResult[];
|
||||
};
|
||||
|
||||
export type RemoveExtensionsInput = {
|
||||
browserId: string;
|
||||
removals: ExtensionRemovalRequest[];
|
||||
};
|
||||
|
||||
export type RemoveBookmarksInput = {
|
||||
browserId: string;
|
||||
removals: BookmarkRemovalRequest[];
|
||||
};
|
||||
|
||||
export type ExtensionRemovalRequest = {
|
||||
extensionId: string;
|
||||
profileIds: string[];
|
||||
};
|
||||
|
||||
export type BookmarkRemovalRequest = {
|
||||
url: string;
|
||||
profileIds: string[];
|
||||
};
|
||||
|
||||
export type RemoveExtensionsResponse = {
|
||||
results: RemoveExtensionResult[];
|
||||
};
|
||||
|
||||
export type RemoveBookmarksResponse = {
|
||||
results: RemoveBookmarkResult[];
|
||||
};
|
||||
|
||||
export type RemoveExtensionResult = {
|
||||
extensionId: string;
|
||||
profileId: string;
|
||||
removedFiles: string[];
|
||||
skippedFiles: string[];
|
||||
error: string | null;
|
||||
};
|
||||
|
||||
export type RemoveBookmarkResult = {
|
||||
url: string;
|
||||
profileId: string;
|
||||
removedCount: number;
|
||||
removedFiles: string[];
|
||||
skippedFiles: string[];
|
||||
error: string | null;
|
||||
};
|
||||
|
||||
export type AssociatedProfileSummary = {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -42,6 +122,19 @@ export type AssociatedProfileSummary = {
|
||||
avatarLabel: string;
|
||||
};
|
||||
|
||||
export type ExtensionInstallSource = "store" | "external";
|
||||
|
||||
export type ExtensionAssociatedProfileSummary = {
|
||||
id: string;
|
||||
name: string;
|
||||
avatarDataUrl: string | null;
|
||||
avatarIcon: string | null;
|
||||
defaultAvatarFillColor: number | null;
|
||||
defaultAvatarStrokeColor: number | null;
|
||||
avatarLabel: string;
|
||||
installSource: ExtensionInstallSource;
|
||||
};
|
||||
|
||||
export type BookmarkAssociatedProfileSummary = {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -56,8 +149,9 @@ export type BookmarkAssociatedProfileSummary = {
|
||||
export type ProfileSortKey = "name" | "email" | "id";
|
||||
export type ExtensionSortKey = "name" | "id";
|
||||
export type BookmarkSortKey = "title" | "url";
|
||||
export type PasswordSiteSortKey = "domain" | "url";
|
||||
export type AssociatedProfileSortKey = "id" | "name";
|
||||
export type ActiveSection = "profiles" | "extensions" | "bookmarks";
|
||||
export type ActiveSection = "profiles" | "extensions" | "bookmarks" | "passwords" | "history";
|
||||
export type AppPage = "browserData" | "configuration";
|
||||
export type BrowserConfigSource = "default" | "custom";
|
||||
|
||||
@@ -92,6 +186,7 @@ export type BrowserView = {
|
||||
profiles: ProfileSummary[];
|
||||
extensions: ExtensionSummary[];
|
||||
bookmarks: BookmarkSummary[];
|
||||
passwordSites: PasswordSiteSummary[];
|
||||
stats: BrowserStats;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,9 +3,12 @@ import type {
|
||||
BookmarkSummary,
|
||||
ExtensionSortKey,
|
||||
ExtensionSummary,
|
||||
PasswordSiteSortKey,
|
||||
PasswordSiteSummary,
|
||||
AssociatedProfileSortKey,
|
||||
AssociatedProfileSummary,
|
||||
BookmarkAssociatedProfileSummary,
|
||||
ExtensionAssociatedProfileSummary,
|
||||
ProfileSortKey,
|
||||
ProfileSummary,
|
||||
} from "../types/browser";
|
||||
@@ -76,8 +79,22 @@ export function sortBookmarks(items: BookmarkSummary[], sortKey: BookmarkSortKey
|
||||
});
|
||||
}
|
||||
|
||||
export function sortPasswordSites(items: PasswordSiteSummary[], sortKey: PasswordSiteSortKey) {
|
||||
const passwordSites = [...items];
|
||||
return passwordSites.sort((left, right) => {
|
||||
if (sortKey === "url") {
|
||||
return compareOptionalText(left.url, right.url) || compareText(left.domain, right.domain);
|
||||
}
|
||||
return compareOptionalText(left.domain, right.domain) || compareText(left.url, right.url);
|
||||
});
|
||||
}
|
||||
|
||||
export function sortAssociatedProfiles(
|
||||
items: (AssociatedProfileSummary | BookmarkAssociatedProfileSummary)[],
|
||||
items: (
|
||||
| AssociatedProfileSummary
|
||||
| BookmarkAssociatedProfileSummary
|
||||
| ExtensionAssociatedProfileSummary
|
||||
)[],
|
||||
sortKey: AssociatedProfileSortKey,
|
||||
) {
|
||||
const profiles = [...items];
|
||||
|
||||
2
src/vite-env.d.ts
vendored
@@ -5,3 +5,5 @@ declare module "*.vue" {
|
||||
const component: DefineComponent<{}, {}, any>;
|
||||
export default component;
|
||||
}
|
||||
|
||||
declare const __APP_VERSION__: string;
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import { defineConfig } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
// @ts-expect-error process is a nodejs global
|
||||
const host = process.env.TAURI_DEV_HOST;
|
||||
const packageJson = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf-8"));
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig(async () => ({
|
||||
plugins: [vue()],
|
||||
define: {
|
||||
__APP_VERSION__: JSON.stringify(packageJson.version),
|
||||
},
|
||||
|
||||
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
||||
//
|
||||
|
||||