mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
增加easytierGame发布新版的提示
This commit is contained in:
@@ -5,6 +5,9 @@ import pkg from "@/package.json";
|
||||
import { setTheme } from "~/composables/theme";
|
||||
import useMainStore from "@/stores/index";
|
||||
import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
// import { ElConfirmPrimary } from "~/utils/element";
|
||||
// import { open } from "@tauri-apps/plugin-shell";
|
||||
|
||||
const DEFAULT_TRAY_NAME = "main";
|
||||
|
||||
@@ -141,3 +144,19 @@ export async function setTrayTooltip(tray: TrayIcon | null, tooltip?: string | n
|
||||
await tray.setTooltip(`EasyTierGame\n${pkg.version}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const checkNewVersion = async () => {
|
||||
let [tagName, downloadUrl] = await invoke<string[]>("fetch_game_releases");
|
||||
if(tagName && pkg.version !== tagName) {
|
||||
return true; //有新版
|
||||
// const [err] = await ElConfirmPrimary("有新版本是否下载?", "发现新版本", {
|
||||
// confirmButtonText: "下载",
|
||||
// cancelButtonText: "取消",
|
||||
// })
|
||||
// if(!err) {
|
||||
// open(downloadUrl);
|
||||
// }
|
||||
}
|
||||
return false; //没有新版
|
||||
}
|
||||
+1
-2
@@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"author": "leizi97",
|
||||
"description": "A simple network initiator based on Easytier",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"scripts": {
|
||||
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
||||
"build": "nuxt generate --dotenv env/.env.prod",
|
||||
@@ -19,7 +19,6 @@
|
||||
"@tauri-apps/plugin-cli": "^2.0.0",
|
||||
"@tauri-apps/plugin-clipboard-manager": "^2.0.0",
|
||||
"@tauri-apps/plugin-fs": "~2",
|
||||
"@tauri-apps/plugin-http": "^2.0.1",
|
||||
"@tauri-apps/plugin-log": "^2.0.0",
|
||||
"@tauri-apps/plugin-shell": "~2",
|
||||
"@tauri-apps/plugin-window-state": "~2",
|
||||
|
||||
+14
-9
@@ -310,14 +310,17 @@
|
||||
增强工具
|
||||
</ElButton>
|
||||
</div>
|
||||
<ElLink
|
||||
class="ml-[8px] truncate pb-[2px] !text-[9px]"
|
||||
type="info"
|
||||
:underline="false"
|
||||
@click="open('https://github.com/EasyTier/EasytierGame')"
|
||||
>
|
||||
EasytierGame主页
|
||||
</ElLink>
|
||||
|
||||
<ElBadge badge-class="!text-[9px] cursor-pointer" :hidden="!data.hasNewVersion" :offset="[6, 7]" value="N">
|
||||
<ElTooltip :disabled="!data.hasNewVersion" content="有新版发布了!">
|
||||
<ElLink
|
||||
class="ml-[8px] truncate pb-[2px] !text-[9px]"
|
||||
type="info"
|
||||
:underline="false"
|
||||
@click="open('https://github.com/EasyTier/EasytierGame')"
|
||||
>EasytierGame主页</ElLink>
|
||||
</ElTooltip>
|
||||
</ElBadge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -510,7 +513,7 @@
|
||||
Folder
|
||||
} from "@element-plus/icons-vue";
|
||||
import { reactive, onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { useTray, setTrayRunState, setTrayTooltip } from "~/composables/tray";
|
||||
import { useTray, setTrayRunState, setTrayTooltip, checkNewVersion } from "~/composables/tray";
|
||||
import { getMatches } from "@tauri-apps/plugin-cli";
|
||||
import { initStartWinIpBroadcast } from "~/composables/netcard";
|
||||
import useMainStore from "@/stores/index";
|
||||
@@ -548,6 +551,7 @@
|
||||
// console.error(config);
|
||||
const protocols = supportProtocols();
|
||||
const data = reactive<{ [key: string]: any; releaseList: Array<Array<string>> }>({
|
||||
hasNewVersion: false, //easytierGame有没有新版
|
||||
logVisible: false,
|
||||
cidrVisible: false,
|
||||
advanceVisible: false,
|
||||
@@ -988,6 +992,7 @@
|
||||
initPreventSleep();
|
||||
mountedShow(); // 不需要await
|
||||
closePrevent();
|
||||
data.hasNewVersion = await checkNewVersion();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
Generated
-10
@@ -35,9 +35,6 @@ importers:
|
||||
'@tauri-apps/plugin-fs':
|
||||
specifier: ~2
|
||||
version: 2.0.2
|
||||
'@tauri-apps/plugin-http':
|
||||
specifier: ^2.0.1
|
||||
version: 2.0.1
|
||||
'@tauri-apps/plugin-log':
|
||||
specifier: ^2.0.0
|
||||
version: 2.0.0
|
||||
@@ -1159,9 +1156,6 @@ packages:
|
||||
'@tauri-apps/plugin-fs@2.0.2':
|
||||
resolution: {integrity: sha512-4YZaX2j7ta81M5/DL8aN10kTnpUkEpkPo1FTYPT8Dd0ImHe3azM8i8MrtjrDGoyBYLPO3zFv7df/mSCYF8oA0Q==}
|
||||
|
||||
'@tauri-apps/plugin-http@2.0.1':
|
||||
resolution: {integrity: sha512-j6IA3pVBybSCwPpsihpX4z8bs6PluuGtr06ahL/xy4D8HunNBTmRmadJrFOQi0gOAbaig4MkQ15nzNLBLy8R1A==}
|
||||
|
||||
'@tauri-apps/plugin-log@2.0.0':
|
||||
resolution: {integrity: sha512-C+NII9vzswqnOQE8k7oRtnaw0z5TZsMmnirRhXkCKDEhQQH9841Us/PC1WHtGiAaJ8za1A1JB2xXndEq/47X/w==}
|
||||
|
||||
@@ -5063,10 +5057,6 @@ snapshots:
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.1.1
|
||||
|
||||
'@tauri-apps/plugin-http@2.0.1':
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.1.1
|
||||
|
||||
'@tauri-apps/plugin-log@2.0.0':
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.1.1
|
||||
|
||||
Generated
+1
-1
@@ -1227,7 +1227,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||
|
||||
[[package]]
|
||||
name = "easytier-game"
|
||||
version = "1.3.0"
|
||||
version = "1.3.1"
|
||||
dependencies = [
|
||||
"log",
|
||||
"planif",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "easytier-game"
|
||||
version = "1.3.0"
|
||||
version = "1.3.1"
|
||||
homepage = "https://github.com/EasyTier/EasyTier"
|
||||
repository = "https://github.com/EasyTier/EasytierGame"
|
||||
description = "A simple network initiator based on Easytier"
|
||||
|
||||
@@ -78,6 +78,47 @@ pub async fn fetch_releases() -> Result<Vec<Release>, Error> {
|
||||
response.json::<Vec<Release>>().await
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
async fn fetch_game_releases() -> [String; 2] {
|
||||
// 创建HTTP客户端
|
||||
let client = Client::new();
|
||||
// 构建请求的URL
|
||||
let url = format!("https://api.github.com/repos/Easytier/EasytierGame/releases",);
|
||||
|
||||
// 发送HTTP GET请求
|
||||
if let Ok(response) = client
|
||||
.get(&url)
|
||||
.header("User-Agent", "Tauri-fetch")
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
// 反序列化响应体为Release列表
|
||||
match response.json::<Vec<Release>>().await {
|
||||
Ok(releases) => {
|
||||
if releases.len() <= 0 {
|
||||
return [String::from(""), String::from("")];
|
||||
}
|
||||
let release = releases.first().unwrap();
|
||||
let tag_name = release.tag_name.as_str();
|
||||
let browser_download_url = release
|
||||
.assets
|
||||
.first()
|
||||
.unwrap()
|
||||
.browser_download_url
|
||||
.as_str();
|
||||
[String::from(tag_name), String::from(browser_download_url)]
|
||||
}
|
||||
Err(_e) => {
|
||||
log::error!("game release {}", _e.to_string());
|
||||
[String::from(""), String::from("")]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log::error!("failed to get game release");
|
||||
[String::from(""), String::from("")]
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
fn get_core_version() -> String {
|
||||
let core_path = get_tool_exe_path("\\easytier\\easytier-core.exe");
|
||||
@@ -641,6 +682,7 @@ pub fn run() {
|
||||
stop_command,
|
||||
get_core_version,
|
||||
fetch_easytier_list,
|
||||
fetch_game_releases,
|
||||
download_easytier_zip,
|
||||
get_members_by_cli,
|
||||
search_pid_by_pname,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "easytier-game",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"identifier": "com.tauri.easytier-game",
|
||||
|
||||
"build": {
|
||||
@@ -13,7 +13,7 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "easytier-game 1.3.0",
|
||||
"title": "easytier-game 1.3.1",
|
||||
"label": "main",
|
||||
"minWidth": 340,
|
||||
"width": 340,
|
||||
|
||||
Reference in New Issue
Block a user