Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a simple desktop frontend implement base rust+tauri #49

Merged
merged 1 commit into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/desktop-tauri.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@
---

## 预览

Web端:
[![明色主题][product-light-screenshot]](https://www.paopao.info)

[![暗色主题][product-dark-screenshot]](https://www.paopao.info)

更多演示请前往[官网](https://www.paopao.info)体验(谢绝灌水)
更多演示请前往[官网](https://www.paopao.info)体验(谢绝灌水)

桌面端:
![](.github/desktop-tauri.jpeg)

<p align="right">(<a href="#top">back to top</a>)</p>

Expand Down Expand Up @@ -115,6 +118,29 @@ PaoPao主要由以下优秀的开源项目/工具构建

build完成后,可以在dist目录获取编译产出,配置nginx指向至该目录即可

#### 桌面端

1. 进入前端目录 `web`,编辑 `.env` 文件中后端服务地址,下载依赖包

```sh
cd ./web
vim .env
yarn
```

2. 编译前端

```sh
yarn build
```

3. 构建桌面端
```sh
yarn tauri build
```
桌面端是使用[Rust](https://www.rust-lang.org/) + [tauri](https://github.com/tauri-apps/tauri)编写
的,需要Rust编译环境,具体安装指南请参考[https://www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install).

### 其他说明

建议后端服务使用 `supervisor` 守护进程,并通过 `nginx` 反向代理后,提供API给前端服务调用。
Expand Down
4 changes: 3 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
"preview": "vite preview",
"tauri": "tauri"
},
"dependencies": {
"@vicons/carbon": "^0.12.0",
Expand All @@ -29,6 +30,7 @@
"vuex": "^4.0.2"
},
"devDependencies": {
"@tauri-apps/cli": "^1.0.0-rc.7",
"@types/node": "^17.0.35",
"@types/qrcode": "^1.4.2",
"@vitejs/plugin-vue": "^2.3.1",
Expand Down
5 changes: 5 additions & 0 deletions web/src-tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generated by Cargo
# will have compiled files and executables
/target/
WixTools
Cargo.lock
23 changes: 23 additions & 0 deletions web/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "paopao"
version = "0.1.0"
description = "Paopao App"
authors = ["Rocboss"]
license = "MIT License"
repository = "https://github.com/rocboss/paopao-ce"
edition = "2021"
rust-version = "1.57"

[build-dependencies]
tauri-build = { version = "1.0.0-rc.4", features = [] }

[dependencies]
tauri = { version = "1.0.0-rc.4", features = ["api-all"] }

[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
default = [ "custom-protocol" ]
# this feature is used used for production builds where `devPath` points to the filesystem
# DO NOT remove this
custom-protocol = [ "tauri/custom-protocol" ]
3 changes: 3 additions & 0 deletions web/src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
Binary file added web/src-tauri/icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/src-tauri/icons/128x128@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/src-tauri/icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/src-tauri/icons/icon.icns
Binary file not shown.
Binary file added web/src-tauri/icons/icon.ico
Binary file not shown.
52 changes: 52 additions & 0 deletions web/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]

use tauri::api::shell;
use tauri::{CustomMenuItem, Manager, Menu, MenuEntry, MenuItem, Submenu};

fn main() {
let _ctx = tauri::generate_context!();

tauri::Builder::default()
.menu(Menu::with_items([
#[cfg(target_os = "macos")]
MenuEntry::Submenu(Submenu::new(
&_ctx.package_info().name,
Menu::with_items([
MenuItem::Separator.into(),
MenuItem::Services.into(),
MenuItem::Separator.into(),
MenuItem::Hide.into(),
MenuItem::HideOthers.into(),
MenuItem::ShowAll.into(),
MenuItem::Separator.into(),
MenuItem::Quit.into(),
]),
)),
MenuEntry::Submenu(Submenu::new(
"Window",
Menu::with_items([MenuItem::Minimize.into(), MenuItem::Zoom.into()]),
)),
// You should always have a Help menu on macOS because it will automatically
// show a menu search field
MenuEntry::Submenu(Submenu::new(
"Help",
Menu::with_items([CustomMenuItem::new("Learn More", "Learn More").into()]),
)),
]))
.on_menu_event(|event| {
let event_name = event.menu_item_id();
event.window().emit("menu", event_name).unwrap();
match event_name {
"Learn More" => {
let link = "https://github.com/rocboss/paopao-ce".to_string();
shell::open(&event.window().shell_scope(), link, None).unwrap();
}
_ => {}
}
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
74 changes: 74 additions & 0 deletions web/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"package": {
"productName": "Paopao",
"version": "0.1.0"
},
"build": {
"distDir": "../dist",
"beforeDevCommand": "",
"beforeBuildCommand": "",
"withGlobalTauri": true
},
"tauri": {
"bundle": {
"active": true,
"targets": "all",
"identifier": "tauri.paopao.info",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"resources": [],
"externalBin": [],
"copyright": "",
"category": "Social Networking",
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": []
},
"macOS": {
"frameworks": [],
"minimumSystemVersion": "",
"exceptionDomain": "",
"signingIdentity": null,
"providerShortName": null,
"entitlements": null
},
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"updater": {
"active": false
},
"allowlist": {
"all": true,
"http": {
"all": true,
"request": true,
"scope": ["https://**", "http://**"]
},
"notification": {
"all": true
}
},
"windows": [
{
"title": "泡泡 - 闲了,冒个泡",
"width": 1080,
"height": 800,
"resizable": true,
"fullscreen": false
}
],
"security": {
"csp": null
}
}
}
60 changes: 60 additions & 0 deletions web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,66 @@
estree-walker "^2.0.1"
picomatch "^2.2.2"

"@tauri-apps/cli-darwin-arm64@1.0.0-rc.13":
version "1.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.0.0-rc.13.tgz#da73a770835ffd63a149d8becf50d3781e1c97dd"
integrity sha512-/EqOz7ASHOU98H58Ibbkg12pLG/P5oyQz8OlueaMYryajkJdmi+bHTkJ05DfbS0owAaHkRJ6f+NmoW/AnyqUbg==

"@tauri-apps/cli-darwin-x64@1.0.0-rc.13":
version "1.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.0.0-rc.13.tgz#e120cc623fddca3eb9d7fea0c2de057c7440a821"
integrity sha512-bvZ0MBKFD1kc4gdVPXgwUA6tHNKj0EmlQK0Xolk6PYP9vZZeNTP1vejevW0bh2IqxC8DuqUArbG9USXwu+LFbQ==

"@tauri-apps/cli-linux-arm-gnueabihf@1.0.0-rc.13":
version "1.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.0.0-rc.13.tgz#3052a59788ae57ad690d4bc09bf0756bc8808116"
integrity sha512-yODvfUkNvtYYdDTOJSDXMx9fpoEB66I2PTrYx1UKonKTEaLrQDcpw2exD/S9LPQzCYgyTuJ/kHRhG1uLdO/UUQ==

"@tauri-apps/cli-linux-arm64-gnu@1.0.0-rc.13":
version "1.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.0.0-rc.13.tgz#9c4094473890c165a4fb22132229ed8212559f79"
integrity sha512-kVDJHERD8CmTeMcd2VTnD/nVCHdnNAK8a6ur3l0KTR1iF8A1AtN/sPahMQjK4f7Ar00UDjIzTw74liqakOeiZg==

"@tauri-apps/cli-linux-arm64-musl@1.0.0-rc.13":
version "1.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.0.0-rc.13.tgz#16270a6d3b9289993b9b4d837f63dba4991d9be5"
integrity sha512-PFHz+0xKCGMqqn2TmbOSPvTRS61xJQV7srwTZjs5sHBvK536mdBnF/6V6BPEvTn5LzfRnxMu2A5X5GFkYnrZ7w==

"@tauri-apps/cli-linux-x64-gnu@1.0.0-rc.13":
version "1.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.0.0-rc.13.tgz#d2f5031f9597300a5814dc8b4d3c59e8dc25a871"
integrity sha512-EWhTOUNHaaMM7mxp/ue+Osnzn6/o9/7qVle3MSnNI9pGQzumc/dOtBs+sWS/NPXdVEiWKET2mFMK120KJlYcQQ==

"@tauri-apps/cli-linux-x64-musl@1.0.0-rc.13":
version "1.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.0.0-rc.13.tgz#9d8b02de7bd5af71c5d3d5be96ec88f3f29c8fbd"
integrity sha512-i8lsKw5iAGTAhqSQHeUCISLjhRXNrloHPoFCaSZtU0/GAPGbW/qST7u593h7cKWxRooeMwzo74ij4GhgmddClQ==

"@tauri-apps/cli-win32-ia32-msvc@1.0.0-rc.13":
version "1.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.0.0-rc.13.tgz#1fcf6bed5a89af2cb30a2fe2e823ca486ded61b7"
integrity sha512-rJxSqWIQXeeT2oLzSiQyqZPgDKSGH5sK7MUr8cOCBitqy3T0COlOMX4O7hhqF3cJ/5s0aX+MuNZBzF/D0QUcxA==

"@tauri-apps/cli-win32-x64-msvc@1.0.0-rc.13":
version "1.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.0.0-rc.13.tgz#ed2feaf3b3a120c1460cae8941443563d14840bb"
integrity sha512-ifOTrJVQoBAQUYX+EVnE4XJ/FCMHs4FQ8qxGNszqkSxrU24mmT7La6tzj77352q80KnxRa05xjjLL6GGhmzXRg==

"@tauri-apps/cli@^1.0.0-rc.7":
version "1.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.0.0-rc.13.tgz#e58127ebe24c6cc81c3258229219056199421500"
integrity sha512-q7i45Mi1SMv5XllNoX09QS4Q/fYVFwD6piVYmqMSrKY/T5RwedQhytiVH60TxC2xk6o0akVHa7BdYiyJvXNR8A==
optionalDependencies:
"@tauri-apps/cli-darwin-arm64" "1.0.0-rc.13"
"@tauri-apps/cli-darwin-x64" "1.0.0-rc.13"
"@tauri-apps/cli-linux-arm-gnueabihf" "1.0.0-rc.13"
"@tauri-apps/cli-linux-arm64-gnu" "1.0.0-rc.13"
"@tauri-apps/cli-linux-arm64-musl" "1.0.0-rc.13"
"@tauri-apps/cli-linux-x64-gnu" "1.0.0-rc.13"
"@tauri-apps/cli-linux-x64-musl" "1.0.0-rc.13"
"@tauri-apps/cli-win32-ia32-msvc" "1.0.0-rc.13"
"@tauri-apps/cli-win32-x64-msvc" "1.0.0-rc.13"

"@types/jest@^27.0.1":
version "27.4.1"
resolved "https://registry.npmmirror.com/@types/jest/-/jest-27.4.1.tgz"
Expand Down