diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e31d89d..374c491 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,4 +11,20 @@ - React v18 - Tailwind CSS v4 -欢迎您从**代码**或**内容**两方面参与贡献,共同完善本项目。 \ No newline at end of file +欢迎您从**代码**或**内容**两方面参与贡献,共同完善本项目。 + +## 贡献指引 + +### 代码贡献 + +1. 【可选】创建 Issue,讨论你的想法。 +2. Fork 本仓库。 +3. 基于 `develop` 分支创建新 `feature/` 分支。 +4. 开始完善你的功能。 +5. 测试功能。 +6. 提交你的代码并通过创建 Pull Request 将代码合并到 `develop` 分支。 +7. 等待上线。 + +### 内容贡献 + +**暂时还没想好怎么提交新内容,等待这里更新再说吧。** diff --git a/README.md b/README.md index 210fca6..978cfff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 骂人宝典 / 祖安语录桌面版 +# 祖安语录桌面版 ![MIT Licence](https://img.shields.io/github/license/zihluwang/zuanbot) @@ -9,7 +9,8 @@ 可以随机输出一条骂人的句子,有**口吐芬芳**与**火力全开**两个模式。 ## 词库下载 -[阿里云盘](https://www.aliyundrive.com/s/StTs9ojDAEF)、[蓝揍云](https://shadiao.lanzouw.com/b0116bgub) `密码hck1` 、 [诚通网盘](https://url08.ctfile.com/d/14688008-46477369-3732e0) `密码9919` + +[GitHub 下载](/src-tauri/resources/data.db)、[阿里云盘](https://www.aliyundrive.com/s/StTs9ojDAEF)、[蓝揍云](https://shadiao.lanzouw.com/b0116bgub) `密码hck1` 、 [诚通网盘](https://url08.ctfile.com/d/14688008-46477369-3732e0) `密码9919` 在线文档:[Notion文档](https://dians.notion.site/d865fac077f1430f9510d020f8713c8e)、[口吐芬芳(谷歌文档)](https://docs.google.com/document/d/1SskgYtDpYL6P_4qmX2A1ndBl8MY5NeDcBaYPxS-yxIo/edit?usp=sharing) 、[火力全开(谷歌文档)](https://docs.google.com/document/d/14YG9qaNDZk275av-Iss6B6YY-eDTdkS5w_my3f7349A/edit?usp=sharing) @@ -17,23 +18,25 @@ 下载对应操作系统的安装包,执行安装即可。 -> 由于作者目前 Rust 水平有限,无法去除打包后的 `en_US` Locale 后缀,但实际语言仍然为中文。 +包类型(文件后缀): + +- Windows: `x64.msi` +- macOS + - Intel: `x64.dmg` + - Apple Silicon: `aarch64.dmg` + +由于没有代码签名,在 Mac 上会因为没有开启允许所有开发者而提示软件损坏,此时可以打开**终端**,并输入 `xattr -d com.apple.quaratine /Applications/zuanbot.app` 再打开软件。 ## 什么原理 收集整理了N条骂人的句子,然后随机读取一条输出即可。 核心代码就一行: + ```sql SELECT * FROM `main` ORDER BY RANDOM() limit 1 ``` ## 词库都是怎么来的 -最初来源于网络收集了一些,后来基本就都是各位用户的投稿了,投稿渠道现已关闭。 -## 写在最后 -还有其他好玩的生成器,比如彩虹屁生成器、毒鸡汤、朋友圈文案等等,请访问 https://shadiao.app 体验。 - -同时也欢迎交流,可以扫码加微信,请备注 `github`,同时有**粉丝群**与**开发者群**,有兴趣可以私聊告知,会尽快拉你。 - -![](http://qiniu.xshwy.cn/ddd.jpg) \ No newline at end of file +最初来源于网络收集了一些,后来基本就都是各位用户的投稿了,投稿渠道现已关闭。 \ No newline at end of file diff --git a/package.json b/package.json index 5b61fc3..8cbcaca 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zuanbot", "private": true, - "version": "0.2.0", + "version": "0.2.1", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 4d460d8..edede48 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -5233,7 +5233,7 @@ dependencies = [ [[package]] name = "zuanbot" -version = "0.2.0" +version = "0.2.1" dependencies = [ "anyhow", "rusqlite", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 76b116d..1cef816 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zuanbot" -version = "0.2.0" +version = "0.2.1" description = "祖安助手" authors = ["zihluwang"] edition = "2021" diff --git a/src-tauri/resources/Licence.txt b/src-tauri/resources/Licence.txt new file mode 100644 index 0000000..e38a625 --- /dev/null +++ b/src-tauri/resources/Licence.txt @@ -0,0 +1,7 @@ +Copyright (c) 2025 Zihlu Wang + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/src-tauri/data.db b/src-tauri/resources/data.db similarity index 100% rename from src-tauri/data.db rename to src-tauri/resources/data.db diff --git a/src-tauri/src/database/mod.rs b/src-tauri/src/database/mod.rs index 2be90ca..ef8df2c 100644 --- a/src-tauri/src/database/mod.rs +++ b/src-tauri/src/database/mod.rs @@ -30,7 +30,7 @@ impl Database { fn get_bundled_database_path(app_handle: &tauri::AppHandle) -> Result { let resource_path = app_handle .path() - .resolve("data.db", tauri::path::BaseDirectory::Resource)?; + .resolve("./resources/data.db", tauri::path::BaseDirectory::Resource)?; println!("Database path: {:?}", resource_path); Ok(resource_path) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 4e6f278..2a740e7 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", - "productName": "zuanbot", - "version": "0.2.0", + "productName": "Zuanbot", + "version": "0.2.1", "identifier": "io.github.zihluwang.zuanbot", "build": { "beforeDevCommand": "pnpm dev", @@ -12,9 +12,13 @@ "app": { "windows": [ { - "title": "骂人宝典", + "title": "祖安语录", "width": 560, - "height": 400 + "maxWidth": 560, + "minWidth": 560, + "height": 400, + "maxHeight": 400, + "minHeight": 400 } ], "security": { @@ -23,7 +27,20 @@ }, "bundle": { "active": true, - "targets": "all", + "publisher": "Zihlu Wang", + "category": "Utility", + "targets": ["dmg", "msi"], + "windows": { + "wix": { + "language": "zh-CN" + }, + "webviewInstallMode": { + "type": "embedBootstrapper" + } + }, + "license": "MIT", + "licenseFile": "./resources/Licence.txt", + "copyright": "Data Collected by @cndiandian, Developed by @zihluwang.", "icon": [ "icons/32x32.png", "icons/128x128.png", @@ -32,7 +49,7 @@ "icons/icon.ico" ], "resources": [ - "./data.db" + "./resources/data.db" ] } } diff --git a/src/App.tsx b/src/App.tsx index 162f0ba..cc2d69b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,10 +1,6 @@ import React, { useEffect, useState } from "react" -import { invoke } from "@tauri-apps/api/core" - -enum Level { - min = "min", - max = "max", -} +import { Level } from "@/types" +import * as service from "@/service" export default function App() { const [text, setText] = useState("") @@ -12,26 +8,41 @@ export default function App() { const [last, setLast] = useState("") useEffect(() => { + // 加载一条祖安语录 ;(async () => { await getMessage() })() + // 第一条消息,禁用上一条功能 + setIsLast(true) }, []) + /** + * 获取一条祖安语录 + * @param level 语录等级 + */ const getMessage = async (level?: Level) => { + // 开放上一条功能 + setIsLast(false) + // 保存上一条信息 setLast(text) // 获取下一条信息 - const nextMessage = await invoke("get_message", { level }) - setText(nextMessage) + const nextZuanMessage = await service.nextZuan(level) + setText(nextZuanMessage) } + /** + * 展示上一条祖安语录 + */ const showLast = () => { setIsLast(true) setText(last) } - // 复制文字到剪贴板 + /** + * 复制文字到剪贴板 + */ const copyToClipboard = () => { if (navigator.clipboard) { navigator.clipboard.writeText(text).then( @@ -43,7 +54,7 @@ export default function App() { } ) } else { - alert("当前浏览器不支持复制功能") + alert("暂时不支持复制功能") } } diff --git a/src/service/index.ts b/src/service/index.ts new file mode 100644 index 0000000..e35ee13 --- /dev/null +++ b/src/service/index.ts @@ -0,0 +1,10 @@ +import { invoke } from "@tauri-apps/api/core" +import { Level } from "@/types" + +/** + * 从服务端获取下一条祖安语录 + * @param level 祖安级别 + */ +export async function nextZuan(level?: Level) { + return await invoke("get_message", { level }) +} diff --git a/src/types/index.ts b/src/types/index.ts new file mode 100644 index 0000000..2d96d48 --- /dev/null +++ b/src/types/index.ts @@ -0,0 +1,4 @@ +export enum Level { + min = "min", + max = "max" +} \ No newline at end of file