feat:UI及切换后端为http
This commit is contained in:
11
front/package-lock.json
generated
11
front/package-lock.json
generated
@@ -20,6 +20,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tauri-apps/cli": "^2",
|
||||
"@tauri-apps/plugin-shell": "^2.3.1",
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.3",
|
||||
@@ -1384,6 +1385,16 @@
|
||||
"@tauri-apps/api": "^2.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tauri-apps/plugin-shell": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmmirror.com/@tauri-apps/plugin-shell/-/plugin-shell-2.3.1.tgz",
|
||||
"integrity": "sha512-jjs2WGDO/9z2pjNlydY/F5yYhNsscv99K5lCmU5uKjsVvQ3dRlDhhtVYoa4OLDmktLtQvgvbQjCFibMl6tgGfw==",
|
||||
"dev": true,
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tauri-apps/plugin-store": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/@tauri-apps/plugin-store/-/plugin-store-2.4.0.tgz",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"build": "vue-tsc --noEmit && vite build",
|
||||
"preview": "vite preview",
|
||||
"tauri": "tauri",
|
||||
"tauri-dev": "tauri dev",
|
||||
"tauri-dev": "tauri dev --no-watch",
|
||||
"tauri-build": "tauri build"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -24,6 +24,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tauri-apps/cli": "^2",
|
||||
"@tauri-apps/plugin-shell": "^2.3.1",
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.3",
|
||||
|
||||
3
front/src-tauri/.taurignore
Normal file
3
front/src-tauri/.taurignore
Normal file
@@ -0,0 +1,3 @@
|
||||
capabilities/
|
||||
target/debug/
|
||||
target/release/
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
up to date in 749ms
|
||||
up to date in 1s
|
||||
|
||||
16 packages are looking for funding
|
||||
run `npm fund` for details
|
||||
|
||||
73
front/src-tauri/Cargo.lock
generated
73
front/src-tauri/Cargo.lock
generated
@@ -703,6 +703,7 @@ dependencies = [
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-opener",
|
||||
"tauri-plugin-shell",
|
||||
"tauri-plugin-store",
|
||||
]
|
||||
|
||||
@@ -843,6 +844,15 @@ version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7"
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "endi"
|
||||
version = "1.1.0"
|
||||
@@ -2420,6 +2430,16 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "os_pipe"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db335f4760b14ead6290116f2427bf33a14d4f0617d49f78a246de10c1831224"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pango"
|
||||
version = "0.18.3"
|
||||
@@ -3304,12 +3324,44 @@ dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shared_child"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e362d9935bc50f019969e2f9ecd66786612daae13e8f277be7bfb66e8bed3f7"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"sigchld",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "sigchld"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47106eded3c154e70176fc83df9737335c94ce22f821c32d17ed1db1f83badb1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"os_pipe",
|
||||
"signal-hook",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"signal-hook-registry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.6"
|
||||
@@ -3727,6 +3779,27 @@ dependencies = [
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-shell"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54777d0c0d8add34eea3ced84378619ef5b97996bd967d3038c668feefd21071"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"log",
|
||||
"open",
|
||||
"os_pipe",
|
||||
"regex",
|
||||
"schemars 0.8.22",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"shared_child",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror 2.0.16",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-store"
|
||||
version = "2.4.0"
|
||||
|
||||
@@ -24,4 +24,5 @@ serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
open = "5.3.2"
|
||||
tauri-plugin-store = "2"
|
||||
tauri-plugin-shell = "2"
|
||||
|
||||
|
||||
@@ -8,6 +8,20 @@
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"opener:default",
|
||||
"store:default"
|
||||
"store:default",
|
||||
"shell:default",
|
||||
"shell:allow-execute",
|
||||
"shell:allow-spawn",
|
||||
"shell:allow-open",
|
||||
{
|
||||
"identifier": "shell:allow-execute",
|
||||
"allow": [
|
||||
{
|
||||
"name": "core",
|
||||
"cmd": "core.exe",
|
||||
"args": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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_shell::init())
|
||||
.plugin(tauri_plugin_store::Builder::new().build())
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.invoke_handler(tauri::generate_handler![greet])
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
],
|
||||
"externalBin": ["binaries/core"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { nextTick, ref, VNodeRef } from 'vue';
|
||||
import { InboxOutlined } from '@ant-design/icons-vue';
|
||||
import { message, StepsProps } from 'ant-design-vue';
|
||||
import type { UploadFile, UploadChangeParam } from 'ant-design-vue';
|
||||
import type { UploadFile, UploadChangeParam, Upload } from 'ant-design-vue';
|
||||
import * as shell from '@tauri-apps/plugin-shell';
|
||||
interface IWSM {
|
||||
status: "unzip"|"pending"|"changed",
|
||||
result: string
|
||||
}
|
||||
/* 进度显示区 */
|
||||
const disp_steps = ref(true);
|
||||
const setyps_current = ref(0);
|
||||
@@ -45,32 +50,66 @@ function handleUpload() {
|
||||
message.warning('请先拖拽或选择文件')
|
||||
return
|
||||
}
|
||||
let data: ArrayBuffer[] = [];
|
||||
FileList.value[0].originFileObj?.arrayBuffer().then(buffer => {data=[buffer];console.log(data);}) //获取文件内容
|
||||
console.log(data);
|
||||
if (!FileList.value[0].originFileObj){
|
||||
return;
|
||||
}
|
||||
runDeEarthX(FileList.value[0].originFileObj) //获取文件内容
|
||||
BtnisDisabled.value = true; //禁用按钮
|
||||
disp_steps.value = true; //开始显示进度条
|
||||
}
|
||||
|
||||
function runDeEarthX() {
|
||||
reactFL()
|
||||
}
|
||||
|
||||
function reactFL() {
|
||||
FileList.value = [];
|
||||
isDisabled.value = false;
|
||||
}
|
||||
runDeEarthX();
|
||||
/* 获取文件区 */
|
||||
shell.Command.create('core',['start']).spawn()
|
||||
function runDeEarthX(data: Blob) {
|
||||
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)
|
||||
})
|
||||
// shell.Command.create('core',['start',new BigUint64Array(data).toString()]).stdout.on('data',(data)=>{
|
||||
// console.log(data)
|
||||
// })
|
||||
reactFL()
|
||||
}
|
||||
|
||||
function prews(res: object){
|
||||
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})
|
||||
})
|
||||
}
|
||||
|
||||
/* 日志区 */
|
||||
const logs = ref<{message:string}[]>([]);
|
||||
//logs.value.push({message:"114514"})
|
||||
const logContainer = ref<HTMLDivElement>();
|
||||
nextTick(()=>{
|
||||
if(logContainer.value){
|
||||
logContainer.value.scrollTop = logContainer.value.scrollHeight;
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="tw:h-full tw:w-full">
|
||||
<div class="tw:h-full tw:w-full tw:relative">
|
||||
<div class="tw:h-full tw:w-full tw:flex tw:flex-col tw:justify-center tw:items-center">
|
||||
<div>
|
||||
<h1 class="tw:text-4xl tw:text-center tw:animate-pulse">DeEarthX</h1>
|
||||
<h1 class="tw:text-sm tw:text-gray-500 tw:text-center">让开服变成随时随地的事情!</h1>
|
||||
</div>
|
||||
<a-upload-dragger :disabled="isDisabled" class="tw:w-128 tw:h-48" name="file" action="/" :multiple="false"
|
||||
<a-upload-dragger :disabled="isDisabled" class="tw:w-144 tw:h-48" name="file" action="/" :multiple="false"
|
||||
:before-upload="beforeUpload" @change="handleChange" @drop="handleDrop" v-model:fileList="FileList"
|
||||
accept=".zip,.mrpack">
|
||||
<p class="ant-upload-drag-icon">
|
||||
@@ -89,5 +128,11 @@ runDeEarthX();
|
||||
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>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
@@ -1,9 +1,49 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import * as fs from "@tauri-apps/plugin-store"
|
||||
const config = ref({})
|
||||
import { ref, watch } from 'vue';
|
||||
import * as shell from '@tauri-apps/plugin-shell';
|
||||
import { message } from 'ant-design-vue';
|
||||
/* Config */
|
||||
interface IConfig {
|
||||
mirror: {
|
||||
bmclapi: boolean;
|
||||
mcimirror: boolean;
|
||||
};
|
||||
filter: {
|
||||
hashes: boolean;
|
||||
dexpub: boolean;
|
||||
mixins: boolean;
|
||||
};
|
||||
}
|
||||
const config = ref<IConfig>({mirror: {bmclapi: false, mcimirror: false}, filter: {hashes: false, dexpub: false, mixins: false}})
|
||||
fetch('http://localhost:37019/getconfig',{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(res=>res.json()).then(res=>config.value = res)
|
||||
|
||||
const checked = ref(false);
|
||||
let first = true;
|
||||
watch(config,(newv)=>{ //写入Config
|
||||
if(!first){
|
||||
fetch('http://localhost:37019/writeconfig',{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(newv)
|
||||
}).then(res=>{
|
||||
if(res.status === 200){
|
||||
message.success('配置已保存')
|
||||
}
|
||||
})
|
||||
// shell.Command.create('core',['writeconfig',JSON.stringify(newv)]).execute().then(()=>{
|
||||
// message.success('配置已保存')
|
||||
// })
|
||||
console.log(newv)
|
||||
return
|
||||
}
|
||||
first = false;
|
||||
},{deep:true})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -20,15 +60,15 @@ const checked = ref(false);
|
||||
<div class="tw:flex">
|
||||
<div class="tw:flex tw:ml-5 tw:mt-2">
|
||||
<p class="tw:text-gray-600">哈希过滤</p>
|
||||
<a-switch class="tw:left-2" v-model:checked="checked" />
|
||||
<a-switch class="tw:left-2" v-model:checked="config.filter.hashes" />
|
||||
</div>
|
||||
<div class="tw:flex tw:ml-5 tw:mt-2">
|
||||
<p class="tw:text-gray-600">DeP过滤</p>
|
||||
<a-switch class="tw:left-2" v-model:checked="checked" />
|
||||
<a-switch class="tw:left-2" v-model:checked="config.filter.dexpub" />
|
||||
</div>
|
||||
<div class="tw:flex tw:ml-5 tw:mt-2">
|
||||
<p class="tw:text-gray-600">Mixin过滤</p>
|
||||
<a-switch class="tw:left-2" v-model:checked="checked" />
|
||||
<a-switch class="tw:left-2" v-model:checked="config.filter.mixins" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- DeEarth设置 -->
|
||||
@@ -38,7 +78,7 @@ const checked = ref(false);
|
||||
<div class="tw:flex">
|
||||
<div class="tw:flex tw:ml-5 tw:mt-2">
|
||||
<p class="tw:text-gray-600">MCIM镜像源</p>
|
||||
<a-switch class="tw:left-2" v-model:checked="checked" />
|
||||
<a-switch class="tw:left-2" v-model:checked="config.mirror.mcimirror" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user