Skip to content

Commit e8fae2d

Browse files
author
linyuan.yang
committed
sbox
1 parent 6d821b6 commit e8fae2d

24 files changed

Lines changed: 2119 additions & 370 deletions

File tree

‎.github/workflows/deploy-docs.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ jobs:
2222
build:
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@v4
26-
- uses: pnpm/action-setup@v4
25+
- uses: actions/checkout@v5
26+
- uses: pnpm/action-setup@v6
2727
with:
2828
version: 10.33.0
29-
- uses: actions/setup-node@v4
29+
- uses: actions/setup-node@v5
3030
with:
3131
node-version: 24
3232
cache: pnpm
3333
- run: pnpm install --frozen-lockfile
3434
- run: pnpm run docs:build
35-
- uses: actions/configure-pages@v5
35+
- uses: actions/configure-pages@v6
3636
with:
3737
enablement: true
38-
- uses: actions/upload-pages-artifact@v3
38+
- uses: actions/upload-pages-artifact@v5
3939
with:
4040
path: docs
4141

@@ -47,4 +47,4 @@ jobs:
4747
url: ${{ steps.deployment.outputs.page_url }}
4848
steps:
4949
- id: deployment
50-
uses: actions/deploy-pages@v4
50+
uses: actions/deploy-pages@v5

‎.vscode/extensions.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"rust-lang.rust-analyzer",
4+
"vue.volar",
5+
"ms-vscode.cpptools",
6+
"vadimcn.vscode-lldb"
7+
]
8+
}

‎.vscode/launch.json‎

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,20 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"type": "node-terminal",
5+
"type": "cppvsdbg",
66
"request": "launch",
7-
"name": "Launch sbox (dev)",
8-
"command": "pnpm dev",
9-
"cwd": "${workspaceFolder}"
7+
"name": "Tauri Debug (dev) · Windows",
8+
"preLaunchTask": "tauri:before:dev",
9+
"program": "${workspaceFolder}/src-tauri/target/debug/sbox.exe",
10+
"cwd": "${workspaceFolder}/src-tauri"
1011
},
1112
{
1213
"type": "lldb",
1314
"request": "launch",
14-
"name": "Tauri Debug (dev)",
15-
"cargo": {
16-
"args": [
17-
"build",
18-
"--manifest-path=${workspaceFolder}/src-tauri/Cargo.toml",
19-
"--no-default-features"
20-
]
21-
},
22-
"preLaunchTask": "ui:dev"
23-
},
24-
{
25-
"type": "lldb",
26-
"request": "launch",
27-
"name": "Tauri Debug (release)",
28-
"cargo": {
29-
"args": [
30-
"build",
31-
"--release",
32-
"--manifest-path=${workspaceFolder}/src-tauri/Cargo.toml"
33-
]
34-
},
35-
"preLaunchTask": "ui:build"
15+
"name": "Tauri Debug (dev) · macOS",
16+
"preLaunchTask": "tauri:before:dev",
17+
"program": "${workspaceFolder}/src-tauri/target/debug/sbox",
18+
"cwd": "${workspaceFolder}/src-tauri"
3619
}
3720
]
3821
}

‎.vscode/tasks.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@
2424
"command": "pnpm",
2525
"args": ["vite", "build"],
2626
"options": { "cwd": "${workspaceFolder}" }
27+
},
28+
{
29+
"label": "rust:build:dev",
30+
"type": "shell",
31+
"command": "cargo",
32+
"args": [
33+
"build",
34+
"--manifest-path=${workspaceFolder}/src-tauri/Cargo.toml",
35+
"--no-default-features"
36+
],
37+
"problemMatcher": ["$rustc"]
38+
},
39+
{
40+
"label": "tauri:before:dev",
41+
"dependsOn": ["ui:dev", "rust:build:dev"],
42+
"dependsOrder": "parallel"
2743
}
2844
]
2945
}

‎README.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ sbot 配套桌面工具箱(Tauri + Vue 3)。内置小工具:
44

55
- **xiaoai-login** — 小爱登录,获取设备 cookie
66
- **keystore-gen** — keystore 生成
7-
- **codec** — 编解码
7+
- **codec** — 编解码(Base64 / URL / Hex / 哈希等)
8+
- **json-convert** — JSON / YAML / TOML 互转与校验
9+
- **jwt** — JWT 解码(header / payload / 时间声明)
10+
- **timestamp** — 时间戳 / 时区转换
11+
- **random-gen** — 密码 / UUID / 随机字符串生成
12+
- **checksum** — 文件校验(计算并比对哈希)
13+
14+
> 新增工具:在 [src/tools/registry.ts](src/tools/registry.ts) 追加一条即可,路由与首页(含搜索/分类)会自动接入。
815
916
## 开发
1017

‎src-tauri/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub fn run() {
1313
tools::xiaoai_login::xiaoai_list_devices,
1414
tools::keystore_gen::keystore_check_java,
1515
tools::keystore_gen::keystore_generate,
16+
tools::save_file::save_base64_file,
1617
])
1718
.run(tauri::generate_context!())
1819
.expect("error while running sbox");

‎src-tauri/src/tools/mod.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pub mod keystore_gen;
2+
pub mod save_file;
23
pub mod xiaoai_login;

‎src-tauri/src/tools/save_file.rs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use base64::Engine;
2+
use std::fs;
3+
4+
/// 把 base64 内容写入指定路径(路径由前端的保存对话框选定)。
5+
/// 前端 WebView 的 <a download> 在 Tauri 中不可靠,统一走此命令落盘。
6+
#[tauri::command]
7+
pub fn save_base64_file(path: String, base64: String) -> Result<(), String> {
8+
let bytes = base64::engine::general_purpose::STANDARD
9+
.decode(base64.trim())
10+
.map_err(|e| format!("base64 解码失败: {e}"))?;
11+
fs::write(&path, bytes).map_err(|e| format!("写入失败: {e}"))?;
12+
Ok(())
13+
}

‎src/router.ts‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import { createRouter, createWebHashHistory } from 'vue-router'
1+
import { createRouter, createWebHashHistory, type RouteRecordRaw } from 'vue-router'
22
import HomeView from './views/HomeView.vue'
3-
import XiaoaiLoginView from './tools/xiaoai-login/XiaoaiLoginView.vue'
4-
import KeystoreGenView from './tools/keystore-gen/KeystoreGenView.vue'
5-
import CodecView from './tools/codec/CodecView.vue'
3+
import { TOOLS } from './tools/registry'
4+
5+
const toolRoutes: RouteRecordRaw[] = TOOLS.map(t => ({
6+
path: `/${t.key}`,
7+
name: t.key,
8+
component: t.component,
9+
}))
610

711
export default createRouter({
812
history: createWebHashHistory(),
913
routes: [
1014
{ path: '/', name: 'home', component: HomeView },
11-
{ path: '/xiaoai-login', name: 'xiaoai-login', component: XiaoaiLoginView },
12-
{ path: '/keystore-gen', name: 'keystore-gen', component: KeystoreGenView },
13-
{ path: '/codec', name: 'codec', component: CodecView },
15+
...toolRoutes,
1416
],
1517
})

‎src/save.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* 文件保存(Tauri)。
3+
* WebView 里的 <a download> 在 Tauri 中不可靠,统一用「保存对话框选路径 → Rust 落盘」。
4+
*/
5+
import { save } from '@tauri-apps/plugin-dialog'
6+
import { invoke } from '@tauri-apps/api/core'
7+
import { stringToBase64 } from './tools/codec/codec'
8+
9+
/** 保存二进制(base64)。返回 false 表示用户取消。 */
10+
export async function saveBase64File(base64: string, defaultName: string): Promise<boolean> {
11+
const path = await save({ defaultPath: defaultName })
12+
if (!path) return false
13+
await invoke('save_base64_file', { path, base64: base64.trim() })
14+
return true
15+
}
16+
17+
/** 保存文本(UTF-8)。返回 false 表示用户取消。 */
18+
export async function saveTextFile(text: string, defaultName: string): Promise<boolean> {
19+
return saveBase64File(stringToBase64(text), defaultName)
20+
}

0 commit comments

Comments
 (0)