feat:大部分功能完成

This commit is contained in:
Tianpao
2025-09-28 00:21:01 +08:00
parent b359fc881e
commit 5f16ee2bfa
22 changed files with 471 additions and 121 deletions

View File

@@ -11,6 +11,7 @@
"@ant-design/icons-vue": "^7.0.1",
"@tailwindcss/vite": "^4.1.13",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-notification": "^2.3.1",
"@tauri-apps/plugin-opener": "^2",
"@tauri-apps/plugin-store": "^2.4.0",
"ant-design-vue": "^4.2.6",
@@ -1376,6 +1377,15 @@
"node": ">= 10"
}
},
"node_modules/@tauri-apps/plugin-notification": {
"version": "2.3.1",
"resolved": "https://registry.npmmirror.com/@tauri-apps/plugin-notification/-/plugin-notification-2.3.1.tgz",
"integrity": "sha512-7gqgfANSREKhh35fY1L4j3TUjUdePmU735FYDqRGeIf8nMXWpcx6j4FhN9/4nYz+m0mv79DCTPLqIPTySggGgg==",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@tauri-apps/api": "^2.8.0"
}
},
"node_modules/@tauri-apps/plugin-opener": {
"version": "2.5.0",
"resolved": "https://registry.npmmirror.com/@tauri-apps/plugin-opener/-/plugin-opener-2.5.0.tgz",

View File

@@ -15,6 +15,7 @@
"@ant-design/icons-vue": "^7.0.1",
"@tailwindcss/vite": "^4.1.13",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-notification": "^2.3.1",
"@tauri-apps/plugin-opener": "^2",
"@tauri-apps/plugin-store": "^2.4.0",
"ant-design-vue": "^4.2.6",

View File

@@ -1,5 +1,5 @@
up to date in 1s
added 1 package in 2s
16 packages are looking for funding
run `npm fund` for details

View File

@@ -702,6 +702,7 @@ dependencies = [
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-notification",
"tauri-plugin-opener",
"tauri-plugin-shell",
"tauri-plugin-store",
@@ -1964,6 +1965,18 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
[[package]]
name = "mac-notification-sys"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "119c8490084af61b44c9eda9d626475847a186737c0378c85e32d77c33a01cd4"
dependencies = [
"cc",
"objc2 0.6.2",
"objc2-foundation 0.3.1",
"time",
]
[[package]]
name = "markup5ever"
version = "0.14.1"
@@ -2113,6 +2126,20 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
name = "notify-rust"
version = "4.11.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6442248665a5aa2514e794af3b39661a8e73033b1cc5e59899e1276117ee4400"
dependencies = [
"futures-lite",
"log",
"mac-notification-sys",
"serde",
"tauri-winrt-notification",
"zbus",
]
[[package]]
name = "num-conv"
version = "0.1.0"
@@ -2677,7 +2704,7 @@ checksum = "3af6b589e163c5a788fab00ce0c0366f6efbb9959c2f9874b224936af7fce7e1"
dependencies = [
"base64 0.22.1",
"indexmap 2.11.1",
"quick-xml",
"quick-xml 0.38.3",
"serde",
"time",
]
@@ -2806,6 +2833,15 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "quick-xml"
version = "0.37.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "331e97a1af0bf59823e6eadffe373d7b27f485be8748f71471c662c1f269b7fb"
dependencies = [
"memchr",
]
[[package]]
name = "quick-xml"
version = "0.38.3"
@@ -2855,6 +2891,16 @@ dependencies = [
"rand_core 0.6.4",
]
[[package]]
name = "rand"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
dependencies = [
"rand_chacha 0.9.0",
"rand_core 0.9.3",
]
[[package]]
name = "rand_chacha"
version = "0.2.2"
@@ -2875,6 +2921,16 @@ dependencies = [
"rand_core 0.6.4",
]
[[package]]
name = "rand_chacha"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
"rand_core 0.9.3",
]
[[package]]
name = "rand_core"
version = "0.5.1"
@@ -2893,6 +2949,15 @@ dependencies = [
"getrandom 0.2.16",
]
[[package]]
name = "rand_core"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
dependencies = [
"getrandom 0.3.3",
]
[[package]]
name = "rand_hc"
version = "0.2.0"
@@ -3757,6 +3822,25 @@ dependencies = [
"walkdir",
]
[[package]]
name = "tauri-plugin-notification"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fbc86b929b5376ab84b25c060f966d146b2fbd59b6af8264027b343c82c219"
dependencies = [
"log",
"notify-rust",
"rand 0.9.2",
"serde",
"serde_json",
"serde_repr",
"tauri",
"tauri-plugin",
"thiserror 2.0.16",
"time",
"url",
]
[[package]]
name = "tauri-plugin-opener"
version = "2.5.0"
@@ -3916,6 +4000,18 @@ dependencies = [
"toml 0.9.5",
]
[[package]]
name = "tauri-winrt-notification"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b1e66e07de489fe43a46678dd0b8df65e0c973909df1b60ba33874e297ba9b9"
dependencies = [
"quick-xml 0.37.5",
"thiserror 2.0.16",
"windows",
"windows-version",
]
[[package]]
name = "tempfile"
version = "3.22.0"

View File

@@ -25,4 +25,5 @@ serde_json = "1"
open = "5.3.2"
tauri-plugin-store = "2"
tauri-plugin-shell = "2"
tauri-plugin-notification = "2"

View File

@@ -22,6 +22,7 @@
"args": true
}
]
}
},
"notification:default"
]
}

View File

@@ -15,6 +15,7 @@ fn open_url(url: &str) {
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_notification::init())
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_store::Builder::new().build())
.plugin(tauri_plugin_opener::init())

View File

@@ -3,9 +3,14 @@ import { nextTick, ref, VNodeRef } from 'vue';
import { InboxOutlined } from '@ant-design/icons-vue';
import { message, StepsProps } from 'ant-design-vue';
import type { UploadFile, UploadChangeParam, Upload } from 'ant-design-vue';
import {
isPermissionGranted,
requestPermission,
sendNotification,
} from '@tauri-apps/plugin-notification';
interface IWSM {
status: "unzip"|"pending"|"changed",
result: string
status: "unzip"|"finish"|"changed"|"downloading",
result: any
}
/* 进度显示区 */
const disp_steps = ref(true);
@@ -64,30 +69,61 @@ function reactFL() {
/* 获取文件区 */
//shell.Command.create('core',['start']).spawn()
function runDeEarthX(data: Blob) {
console.log(data)
//console.log(data)
const fd = new FormData();
fd.append('file', data);
console.log(fd.getAll('file'))
fetch('http://localhost:37019/start',{
method:'POST',
body:fd
}).then(async res=>res.json()).then(res=>{
prews(res)
}).then(async res=>res.json()).then(()=>{
prews()
})
// shell.Command.create('core',['start',new BigUint64Array(data).toString()]).stdout.on('data',(data)=>{
// console.log(data)
// })
reactFL()
}
function prews(res: object){
const prog = ref({status:"active",percent:0,display:true})
const dprog = ref({status:"active",percent:0,display:true})
function prews(){
const ws = new WebSocket('ws://localhost:37019/')
// ws.addEventListener('message',(wsm)=>{
// const _data = JSON.parse(wsm.data) as IWSM
// if (_data.status === "changed") {
// setyps_current.value ++;
// }
// logs.value.push({message:_data.result})
// })
ws.addEventListener('message',(wsm)=>{
const _data = JSON.parse(wsm.data) as IWSM
if (_data.status === "changed") {
const _data = JSON.parse(wsm.data) as IWSM
//console.log(_data)
if (_data.status === "changed") { //状态更改
setyps_current.value ++;
}
logs.value.push({message:_data.result})
if (_data.status === "unzip"){ //解压ZIP
prog.value.percent = Math.round(((_data.result.current / _data.result.total) * 100))
if (_data.result.current === _data.result.total){
prog.value.status = "succees"
setTimeout(()=>{
prog.value.display = false;
},2000)
}
}
if (_data.status === "downloading"){ //下载文件
dprog.value.percent = Math.round((_data.result.index / _data.result.total) * 100)
if(dprog.value.percent === 100){
dprog.value.status = "succees"
setTimeout(()=>{
dprog.value.display = false;
},2000)
}
}
if (_data.status === "finish"){
const time = Math.round(_data.result / 1000 / 1000)
setyps_current.value ++;
sendNotification({ title: 'DeEarthX V3', body: `服务端制作完成!共用时${time}秒!` });
}
})
}
@@ -127,10 +163,20 @@ logContainer.value.scrollTop = logContainer.value.scrollHeight;
class="tw:fixed tw:bottom-2 tw:ml-4 tw:w-272 tw:h-16 tw:flex tw:justify-center tw:items-center tw:text-sm">
<a-steps :current="setyps_current" :items="setps_items" />
</div>
<div v-if="disp_steps" ref="logContainer" class="tw:absolute tw:right-2 tw:bottom-20 tw:h-96 tw:w-56 tw:bg-gray-200 tw:rounded-xl tw:container tw:overflow-y-auto">
<div v-for="log in logs" class="tw:mt-2 tw:last:mb-0">
<span class="tw:text-blue-500">{{ log.message }}</span>
</div>
<!-- <div class="tw:absolute tw:bottom-20 tw:right-2 tw:h-16 tw:w-16">
</div> -->
<div v-if="disp_steps" ref="logContainer" class="tw:absolute tw:right-2 tw:bottom-20 tw:h-80 tw:w-56 tw:rounded-xl tw:container tw:overflow-y-auto">
<a-card title="制作进度" :bordered="true">
<div v-if="prog.display">
<h1>解压进度</h1>
<a-progress :percent="prog.percent" :status="prog.status" size="small" />
</div>
<div v-if="dprog.display">
<h1>下载进度</h1>
<a-progress :percent="dprog.percent" :status="dprog.status" size="small" />
</div>
</a-card>
</div>
</div>