mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6defb9e0ac | ||
|
|
7751c25e15 | ||
|
|
e598f3806b | ||
|
|
2383178a61 | ||
|
|
2a7f51ccde |
+3
-1
@@ -11,4 +11,6 @@ dist
|
||||
.vscode
|
||||
release
|
||||
|
||||
src-tauri/easytier/logs
|
||||
src-tauri/easytier/logs
|
||||
src-tauri/easytier/tool/ResourcesExtract.exe
|
||||
src-tauri/easytier/tool/ResourcesExtract.cfg
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { basename, extname } from "@tauri-apps/api/path";
|
||||
import { exists } from "@tauri-apps/plugin-fs";
|
||||
import { Command } from "@tauri-apps/plugin-shell";
|
||||
|
||||
export const getIcon = async function (sourcePath: string, icoDirPath: string) {
|
||||
if(sourcePath.endsWith(".url")) return false;
|
||||
let res = await Command.create("ResourcesExtract", [
|
||||
"/Source",
|
||||
sourcePath,
|
||||
"/DestFolder",
|
||||
icoDirPath,
|
||||
"/ExtractIcons",
|
||||
"1",
|
||||
"/ExtractCursors",
|
||||
"0",
|
||||
"/OpenDestFolder",
|
||||
"0",
|
||||
"/MultiFilesMode",
|
||||
"1"
|
||||
]).execute();
|
||||
if (res.code == 0) {
|
||||
let icoPath = icoDirPath + "\\" + (await basename(sourcePath));
|
||||
icoPath = icoPath.replace(`.${await extname(sourcePath)}`, "_1.ico");
|
||||
if (await exists(icoPath)) {
|
||||
return icoPath;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"author": "leizi97",
|
||||
"description": "A simple network initiator based on Easytier",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"scripts": {
|
||||
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
||||
"build": "nuxt generate --dotenv env/.env.prod",
|
||||
|
||||
+165
-29
@@ -16,14 +16,14 @@
|
||||
class="mr-[5px]"
|
||||
@click="handleCreate"
|
||||
>
|
||||
新增本地游戏
|
||||
新增游戏
|
||||
</ElButton>
|
||||
<ElButton
|
||||
size="small"
|
||||
class="mr-[5px]"
|
||||
class="!ml-[0px] mr-[5px]"
|
||||
@click="openCoverDir"
|
||||
>
|
||||
打开封面目录
|
||||
封面目录
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
@@ -37,7 +37,7 @@
|
||||
<ElCard>
|
||||
<template #header>
|
||||
<div class="flex flex-nowrap gap-[0_8px]">
|
||||
<ElTooltip :content="item.name">
|
||||
<ElTooltip :content="item.name" placement="top">
|
||||
<p class="ml-auto flex-1 truncate">
|
||||
<ElText
|
||||
size="default"
|
||||
@@ -56,7 +56,7 @@
|
||||
/>
|
||||
</ElCard>
|
||||
<div
|
||||
class="absolute left-0 top-0 z-[1] hidden h-full w-full flex-col items-center justify-center rounded-[5px] bg-[var(--el-mask-color)] group-hover/card:flex"
|
||||
class="absolute left-0 top-[61px] z-[1] hidden h-[calc(100%-61px)] w-full flex-col items-center justify-center rounded-[5px] bg-[var(--el-mask-color)] group-hover/card:flex"
|
||||
>
|
||||
<ElButton
|
||||
size="large"
|
||||
@@ -92,10 +92,13 @@
|
||||
@click.stop="handleCreate"
|
||||
shadow="hover"
|
||||
>
|
||||
<div class="group/plus flex cursor-pointer items-center justify-center py-[25px]">
|
||||
<div class="group/plus flex cursor-pointer flex-col items-center justify-center py-[25px]">
|
||||
<ElIcon class="!text-[80px] transition-all group-hover/plus:text-[color:var(--el-color-primary)]">
|
||||
<Plus></Plus>
|
||||
</ElIcon>
|
||||
<div>
|
||||
<ElText>支持从桌面拖放新增</ElText>
|
||||
</div>
|
||||
</div>
|
||||
</ElCard>
|
||||
</ElTooltip>
|
||||
@@ -148,7 +151,7 @@
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
label="游戏封面"
|
||||
prop="coverImg"
|
||||
prop="showImg"
|
||||
>
|
||||
<ElBadge :hidden="createGameData.form.showImg == defaultPng">
|
||||
<template #content="{ value }">
|
||||
@@ -162,7 +165,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<img
|
||||
@click.stop="handleBrowser('coverImg')"
|
||||
@click.stop="handleBrowser('showImg')"
|
||||
:src="showImgConvertFileSrc(createGameData.form.showImg)"
|
||||
class="aspect-[1] w-[120px] cursor-pointer object-cover"
|
||||
/>
|
||||
@@ -191,9 +194,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { VideoPlay, DeleteFilled, EditPen, Plus, Delete } from "@element-plus/icons-vue";
|
||||
import { dataSubscribe } from "~/composables/windows";
|
||||
import { BaseDirectory, resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
||||
import { convertFileSrc } from "@tauri-apps/api/core";
|
||||
import { computed, nextTick, reactive, ref, useTemplateRef } from "vue";
|
||||
import { BaseDirectory, basename, extname, resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
||||
import { convertFileSrc, Resource } from "@tauri-apps/api/core";
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, useTemplateRef } from "vue";
|
||||
import useMainStore from "@/stores/index";
|
||||
import { uniqueId } from "lodash-es";
|
||||
import { open as dialogOpen } from "@tauri-apps/plugin-dialog";
|
||||
@@ -202,6 +205,8 @@
|
||||
import { ElConfirmDanger } from "~/utils/element";
|
||||
import { copyFile, exists, mkdir, readDir, remove } from "@tauri-apps/plugin-fs";
|
||||
import { Command, open } from "@tauri-apps/plugin-shell";
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
|
||||
const resourceDir = await getResourceDir();
|
||||
const gameListResourceDir = await join(resourceDir, import.meta.env.VITE_GAME_LIST_PATH);
|
||||
// const defaultLocalIconPath = await join(configPath, "icon.png");
|
||||
@@ -211,7 +216,7 @@
|
||||
const searchValue = ref("");
|
||||
const defaultPng = "/default.png";
|
||||
// const b = bounce(600);
|
||||
type gameItemType = { name: string; exePath: string; coverImg: string; id: string; showImg: string };
|
||||
type gameItemType = { name: string; exePath: string; id: string; showImg: string };
|
||||
const createGameData = reactive({
|
||||
visible: false,
|
||||
isEdit: false,
|
||||
@@ -219,7 +224,6 @@
|
||||
id: "",
|
||||
name: "",
|
||||
exePath: "",
|
||||
coverImg: "",
|
||||
showImg: defaultPng
|
||||
},
|
||||
rules: {
|
||||
@@ -241,29 +245,27 @@
|
||||
id: "",
|
||||
name: "",
|
||||
exePath: "",
|
||||
coverImg: "",
|
||||
showImg: defaultPng
|
||||
};
|
||||
await nextTick();
|
||||
createGameData.visible = true;
|
||||
};
|
||||
|
||||
const handleBrowser = async (type: "coverImg" | "exePath") => {
|
||||
const filters = type === "coverImg" ? [{ name: "", extensions: ["png", "jpg", "jpeg"] }] : [{ name: "", extensions: ["exe"] }];
|
||||
const handleBrowser = async (type: "showImg" | "exePath") => {
|
||||
const filters = type === "showImg" ? [{ name: "", extensions: ["png", "jpg", "jpeg"] }] : [{ name: "", extensions: ["exe"] }];
|
||||
const file = await dialogOpen({
|
||||
multiple: false,
|
||||
directory: false,
|
||||
filters
|
||||
});
|
||||
if (file) {
|
||||
if (type === "coverImg") {
|
||||
createGameData.form.coverImg = file;
|
||||
if (createGameData.form.coverImg) {
|
||||
if (type === "showImg") {
|
||||
if (file) {
|
||||
if (!createGameData.form.id) {
|
||||
const time = new Date().getTime();
|
||||
createGameData.form.id = uniqueId(`${time}`);
|
||||
}
|
||||
let coverImg = createGameData.form.coverImg;
|
||||
let showImg = file;
|
||||
const game_list_path = import.meta.env.VITE_GAME_LIST_PATH;
|
||||
const isExists = await exists(game_list_path, { baseDir: BaseDirectory.Resource });
|
||||
if (!isExists) {
|
||||
@@ -272,14 +274,16 @@
|
||||
} catch (err) {}
|
||||
}
|
||||
const toPath = await join(gameListResourceDir, createGameData.form.id);
|
||||
const suffix = coverImg.split(".").pop();
|
||||
const suffix = showImg.split(".").pop();
|
||||
const toPathFileName = `${toPath}.${suffix}`;
|
||||
if (coverImg != toPathFileName) {
|
||||
await copyFile(coverImg, toPathFileName);
|
||||
if (showImg != toPathFileName) {
|
||||
await copyFile(showImg, toPathFileName);
|
||||
}
|
||||
// console.log(toPathFileName);
|
||||
const isExistsToPath = await exists(toPathFileName);
|
||||
if (isExistsToPath) {
|
||||
createGameData.form = { ...createGameData.form, showImg: `${toPathFileName}` }; // 如果复制正确,那就存储文件名即可
|
||||
const baseName = await basename(toPathFileName);
|
||||
createGameData.form = { ...createGameData.form, showImg: `${baseName}` }; // 如果复制正确,那就存储文件名即可
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -308,7 +312,6 @@
|
||||
if (createGameData.form.showImg == defaultPng) {
|
||||
//删除本地封面图
|
||||
// const toPath = await join(gameListResourceDir, createGameData.form.id);
|
||||
// const suffix = coverImg.split(".").pop();
|
||||
// const imgPath = `${toPath}.${suffix}`;
|
||||
// await remove(imgPath);
|
||||
}
|
||||
@@ -333,23 +336,27 @@
|
||||
|
||||
const handleBadgeDeleteCover = async () => {
|
||||
await removeFileById(createGameData.form.id);
|
||||
createGameData.form = { ...createGameData.form, coverImg: "", showImg: defaultPng };
|
||||
createGameData.form = { ...createGameData.form, showImg: defaultPng };
|
||||
};
|
||||
|
||||
const removeFileById = async (id: string) => {
|
||||
if (!id) return;
|
||||
const isExists = await exists(gameListResourceDir);
|
||||
if (!isExists) return;
|
||||
const entries = await readDir(gameListResourceDir);
|
||||
if (entries.length > 0) {
|
||||
for (const entry of entries) {
|
||||
if (entry.name.includes(id + ".")) {
|
||||
const imgPath = await join(gameListResourceDir, entry.name);
|
||||
const isExists = await exists(imgPath);
|
||||
if (!isExists) continue;
|
||||
await remove(imgPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteItem = async ({ coverImg, id }: gameItemType) => {
|
||||
const handleDeleteItem = async ({ id }: gameItemType) => {
|
||||
if (id) {
|
||||
const [error, _] = await ElConfirmDanger("确定要删除吗?");
|
||||
if (!error) {
|
||||
@@ -383,7 +390,6 @@
|
||||
|
||||
const handleImgError = (item: gameItemType, idx: number) => {
|
||||
item.showImg = defaultPng;
|
||||
item.coverImg = "";
|
||||
mainStore.gameList[idx] = { ...item };
|
||||
mainStore.$patch({
|
||||
gameList: [...mainStore.gameList]
|
||||
@@ -391,7 +397,137 @@
|
||||
};
|
||||
|
||||
const showImgConvertFileSrc = (showImg: string) => {
|
||||
return showImg != defaultPng ? `${convertFileSrc(showImg)}?${new Date().getTime()}` : defaultPng;
|
||||
if (showImg == defaultPng) return defaultPng;
|
||||
showImg = /^[a-z]\:/g.test(showImg.toLowerCase())
|
||||
? `${convertFileSrc(showImg)}?${new Date().getTime()}`
|
||||
: `${convertFileSrc(`${gameListResourceDir}\\${showImg}`)}?${new Date().getTime()}`;
|
||||
return showImg;
|
||||
};
|
||||
|
||||
let unlistenDragDrop: UnlistenFn | null = null;
|
||||
const listenDragDrop = async () => {
|
||||
unlistenDragDrop = await listen<{ paths: string[]; position: { x: number; y: number } }>("tauri://drag-drop", async e => {
|
||||
const AllFiles = e.payload.paths;
|
||||
let result: Array<gameItemType> = [];
|
||||
const date = new Date().getTime();
|
||||
const showImg = defaultPng;
|
||||
const extUrls = [];
|
||||
const lnkFiles = [];
|
||||
for (const item of AllFiles) {
|
||||
if (item.endsWith(".url")) {
|
||||
extUrls.push(item);
|
||||
} else {
|
||||
lnkFiles.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (lnkFiles.length > 0) {
|
||||
// console.log(lnkFiles)
|
||||
let lnkFilesstr = "$lnkFiles = @(";
|
||||
for (let i = 0; i < lnkFiles.length; i++) {
|
||||
lnkFilesstr = lnkFilesstr + `\"${lnkFiles[i]}\"`;
|
||||
if (i == lnkFiles.length - 1) {
|
||||
lnkFilesstr = lnkFilesstr + ");";
|
||||
} else {
|
||||
lnkFilesstr = lnkFilesstr + ",";
|
||||
}
|
||||
}
|
||||
let forstr =
|
||||
lnkFilesstr +
|
||||
`
|
||||
$shell = New-Object -ComObject WScript.Shell;
|
||||
$results = @();
|
||||
foreach ($lnkFile in $lnkFiles) {
|
||||
$shortcut = $shell.CreateShortcut($lnkFile);
|
||||
$targetPath = $shortcut.TargetPath;
|
||||
$iconLocation = $shortcut.IconLocation;
|
||||
$results += [PSCustomObject]@{
|
||||
TargetPath = $targetPath
|
||||
LinkFile = $lnkFile
|
||||
};
|
||||
};
|
||||
$results | ConvertTo-Json
|
||||
`;
|
||||
let outputtarget = await Command.create("powershell", [`${forstr}`], {
|
||||
encoding: "GBK"
|
||||
}).execute();
|
||||
let res: {
|
||||
TargetPath: string;
|
||||
LinkFile: string;
|
||||
}[] = JSON.parse(outputtarget.stdout);
|
||||
if (res && !Array.isArray(res)) {
|
||||
res = [res];
|
||||
}
|
||||
if (res.length > 0) {
|
||||
for (const idx in res) {
|
||||
const item = res[idx];
|
||||
// console.log(item);
|
||||
const id = `${date}-${idx}`;
|
||||
const exePath = item.TargetPath || item.LinkFile;
|
||||
const namePath = item.LinkFile || item.TargetPath;
|
||||
const allName = await basename(namePath);
|
||||
const extName = await extname(namePath);
|
||||
result.push({
|
||||
exePath: exePath,
|
||||
name: allName.replace(`.${extName}`, ""),
|
||||
id,
|
||||
showImg
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (extUrls.length > 0) {
|
||||
for (const idx in extUrls) {
|
||||
const TargetPath = extUrls[idx];
|
||||
const id = `${date}-${idx}-url`;
|
||||
const allName = await basename(TargetPath);
|
||||
const extName = await extname(TargetPath);
|
||||
result.push({
|
||||
exePath: TargetPath,
|
||||
name: allName.replace(`.${extName}`, ""),
|
||||
id,
|
||||
showImg
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (result.length > 0) {
|
||||
mainStore.$patch({
|
||||
gameList: [...mainStore.gameList, ...result]
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 兼容新的存储方式
|
||||
const compatibleGameList = async () => {
|
||||
const gameList = [...mainStore.gameList];
|
||||
if(gameList.length <= 0) return;
|
||||
const newGameList = [];
|
||||
for(const item of gameList) {
|
||||
const newItem = {...item}
|
||||
if(newItem.showImg != defaultPng && /^[a-z]\:/g.test(newItem.showImg.toLowerCase())) {
|
||||
newItem.showImg = await basename(item.showImg);
|
||||
if(Reflect.has(newItem, "coverImg")) {
|
||||
delete newItem['coverImg'];
|
||||
}
|
||||
}
|
||||
newGameList.push(newItem);
|
||||
}
|
||||
mainStore.$patch({
|
||||
gameList: newGameList
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await compatibleGameList();
|
||||
listenDragDrop(); //监听拖放
|
||||
});
|
||||
|
||||
onBeforeUnmount(() =>{
|
||||
unlistenDragDrop && unlistenDragDrop();
|
||||
})
|
||||
|
||||
|
||||
dataSubscribe();
|
||||
</script>
|
||||
|
||||
+36
-3
@@ -437,8 +437,11 @@
|
||||
>
|
||||
<div>
|
||||
<ElText>当前版本: {{ data.coreVersion || "-" }}</ElText>
|
||||
<div v-if="data.update">
|
||||
<ElProgress :percentage="progress"></ElProgress>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-[10px] pb-[5px]">
|
||||
<div class="mt-[5px] pb-[5px]">
|
||||
<ElText class="!mr-[10px]">选择一个内核版本安装</ElText>
|
||||
<ElButton
|
||||
:loading="coreManagementData.loading"
|
||||
@@ -481,7 +484,13 @@
|
||||
<ElInput
|
||||
v-model="mainStore.githubFastUrl"
|
||||
placeholder="请输入github加速地址"
|
||||
></ElInput>
|
||||
>
|
||||
<template #append>
|
||||
<ElTooltip content="github加速链接的发布地址,当前地址失效后,访问它获取最新的地址">
|
||||
<ElButton @click="open('https://ghproxy.link/')">发布地址</ElButton>
|
||||
</ElTooltip>
|
||||
</template>
|
||||
</ElInput>
|
||||
<template #footer>
|
||||
<div class="text-right">
|
||||
<ElButton
|
||||
@@ -682,7 +691,7 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { open, Command } from "@tauri-apps/plugin-shell";
|
||||
import {
|
||||
QuestionFilled,
|
||||
@@ -1024,11 +1033,17 @@
|
||||
// await getReleaseList();
|
||||
};
|
||||
|
||||
let unlistenDownload: UnlistenFn | null = null;
|
||||
let unlistenDownloadError: UnlistenFn | null = null;
|
||||
let progress = ref<number>(0);
|
||||
let size = 0;
|
||||
const handleInstallCore = async () => {
|
||||
try {
|
||||
if (!coreManagementData.data) {
|
||||
return ElMessage.error("请选择一个内核");
|
||||
}
|
||||
progress.value = 0;
|
||||
size = 0;
|
||||
data.update = true;
|
||||
await getCoreVersion();
|
||||
const [isNeedUpdate, downloadUrl, latestVersionFileName] = await checkUpdate();
|
||||
@@ -1036,6 +1051,22 @@
|
||||
if (isNeedUpdate) {
|
||||
await reset();
|
||||
// console.error(downloadUrl);
|
||||
if (unlistenDownload) {
|
||||
await unlistenDownload();
|
||||
}
|
||||
if (unlistenDownloadError) {
|
||||
await unlistenDownloadError();
|
||||
}
|
||||
unlistenDownload = await listen<[number, number]>("download_core_progress", ({ payload }) => {
|
||||
size += payload[0];
|
||||
progress.value = Math.round((size / payload[1]) * 100);
|
||||
});
|
||||
unlistenDownloadError = await listen("download_core_progress_error", () => {
|
||||
data.update = false;
|
||||
progress.value = 0;
|
||||
size = 0;
|
||||
ElMessage.error("发生错误,请重试");
|
||||
});
|
||||
await invoke("download_easytier_zip", { download_url: downloadUrl, file_name: latestVersionFileName });
|
||||
}
|
||||
await getCoreVersion();
|
||||
@@ -1060,6 +1091,7 @@
|
||||
};
|
||||
|
||||
const handleAutoStartByTask = async () => {
|
||||
if (import.meta.env.DEV) return ElMessage.warning("开发环境不支持开机自启");
|
||||
await invoke("spawn_autostart", { enabled: !config.autoStart });
|
||||
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||
config.autoStart = is_enable_by_task;
|
||||
@@ -1070,6 +1102,7 @@
|
||||
let is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
|
||||
if (is_enable_by_task) {
|
||||
// 每次打开Exe重新加载一次开机自启,因为可能路径变了
|
||||
if (import.meta.env.DEV) return ElMessage.warning("开发环境不支持开机自启");
|
||||
await invoke("spawn_autostart", { enabled: false });
|
||||
await invoke("spawn_autostart", { enabled: true });
|
||||
}
|
||||
|
||||
Generated
+1
-1
@@ -1290,7 +1290,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||
|
||||
[[package]]
|
||||
name = "easytier-game"
|
||||
version = "1.4.0"
|
||||
version = "1.4.1"
|
||||
dependencies = [
|
||||
"hashbrown 0.15.2",
|
||||
"log",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "easytier-game"
|
||||
version = "1.4.0"
|
||||
version = "1.4.1"
|
||||
homepage = "https://github.com/EasyTier/EasyTier"
|
||||
repository = "https://github.com/EasyTier/EasytierGame"
|
||||
description = "A simple network initiator based on Easytier"
|
||||
@@ -47,6 +47,7 @@ tauri-plugin-dialog = "2.2.0"
|
||||
# prost = "0.13"
|
||||
# prost-types = "0.13"
|
||||
hashbrown = "0.15.2"
|
||||
# futures-util = "0.3"
|
||||
|
||||
[dependencies.windows]
|
||||
version = "0.58.0"
|
||||
|
||||
@@ -88,11 +88,19 @@
|
||||
"args": true,
|
||||
"cmd": "ping",
|
||||
"name": "ping"
|
||||
},
|
||||
{
|
||||
"args": true,
|
||||
"cmd": "powershell",
|
||||
"name": "powershell"
|
||||
}
|
||||
]
|
||||
},
|
||||
"fs:default",
|
||||
"fs:allow-read-dir",
|
||||
{
|
||||
"identifier": "fs:allow-read-dir",
|
||||
"allow": [{ "path": "$DESKTOP" }, { "path": "$DESKTOP/*" }, { "path": "**/*" }, { "path": "**" }]
|
||||
},
|
||||
"fs:allow-exists",
|
||||
"fs:allow-open",
|
||||
"fs:allow-resource-read",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+18
-8
@@ -3,6 +3,7 @@ use planif::schedule::TaskScheduler as planIfTaskScheduler;
|
||||
use planif::schedule_builder::{Action, ScheduleBuilder};
|
||||
use planif::settings::{Duration, LogonType, PrincipalSettings, RunLevel};
|
||||
use reqwest::{Client, Error};
|
||||
// use futures_util::StreamExt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::fs::{self, File};
|
||||
@@ -325,7 +326,7 @@ async fn get_route_by_cli() -> String {
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
async fn download_easytier_zip(download_url: String, file_name: String) {
|
||||
async fn download_easytier_zip(app_handle: tauri::AppHandle ,download_url: String, file_name: String) {
|
||||
let cache_dir_path = get_tool_exe_path("\\easytier\\cache");
|
||||
let cache_file_name = format!("{}\\{}", cache_dir_path, file_name);
|
||||
let cache_file_name_path = path::Path::new(&cache_file_name);
|
||||
@@ -335,12 +336,12 @@ async fn download_easytier_zip(download_url: String, file_name: String) {
|
||||
}
|
||||
|
||||
let target = format!("{}", download_url);
|
||||
let response = reqwest::get(target)
|
||||
let mut response = reqwest::get(target)
|
||||
.await
|
||||
.expect("error to download easytier url");
|
||||
let easytier_path = get_tool_exe_path("\\easytier");
|
||||
let file_path = format!("{}\\{}", easytier_path, file_name);
|
||||
println!("download easytier to {}", file_path);
|
||||
// println!("download easytier to {}", file_path);
|
||||
|
||||
let easytier_dir = path::Path::new(&easytier_path);
|
||||
if !easytier_dir.exists() {
|
||||
@@ -354,11 +355,20 @@ async fn download_easytier_zip(download_url: String, file_name: String) {
|
||||
Err(why) => panic!("couldn't create {}", why),
|
||||
Ok(file) => file,
|
||||
};
|
||||
|
||||
let content = response.bytes().await.expect("error to bytes easytier");
|
||||
println!("下载完成,开始写入");
|
||||
file.write_all(&content).expect("error to write easytier");
|
||||
println!("写入完成");
|
||||
let context_size: u64 = response.content_length().unwrap();
|
||||
while let Some(item) = response.chunk().await.unwrap() {
|
||||
match file.write_all(&item) {
|
||||
Ok(_) => {
|
||||
app_handle.emit("download_core_progress", [item.len() as u64, context_size]).expect("error to emit download_core_progress");
|
||||
},Err(why) => {
|
||||
log::error!("error to write file: {}", why);
|
||||
app_handle.emit("download_core_progress_error", why.to_string()).expect("error to emit download_core_progress_error");
|
||||
return
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
println!("下载完成");
|
||||
unzip(path);
|
||||
|
||||
let cache_dir_path = path::Path::new(&cache_dir_path);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "easytier-game",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"identifier": "com.tauri.easytier-game",
|
||||
|
||||
"build": {
|
||||
@@ -12,7 +12,7 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "easytier-game 1.4.0",
|
||||
"title": "easytier-game 1.4.1",
|
||||
"label": "main",
|
||||
"minWidth": 340,
|
||||
"width": 340,
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ const store = defineStore("main", {
|
||||
winipBcPid: 0,
|
||||
winipBcStart: false,
|
||||
|
||||
gameList: [] as Array<{name: string, exePath: string, id: string, coverImg: string; showImg: string}>, // 游戏列表
|
||||
gameList: [] as Array<{name: string, exePath: string, id: string, coverImg?: string; showImg: string}>, // 游戏列表
|
||||
};
|
||||
},
|
||||
persist: {
|
||||
|
||||
Reference in New Issue
Block a user