mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-26 01:10:16 +08:00
@@ -4,6 +4,9 @@ import type { App } from "./typedefinition";
|
||||
export const APM_STORE_BASE_URL: string =
|
||||
import.meta.env.VITE_APM_STORE_BASE_URL || "";
|
||||
|
||||
export const APM_STORE_STATS_BASE_URL: string =
|
||||
import.meta.env.VITE_APM_STORE_STATS_BASE_URL || "";
|
||||
|
||||
// 下面的变量用于存储当前应用的信息,其实用在多个组件中
|
||||
export const currentApp = ref<App | null>(null);
|
||||
export const currentAppIsInstalled = ref(false);
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
// })
|
||||
import pino from "pino";
|
||||
|
||||
import { currentApp, currentAppIsInstalled } from "../global/storeConfig";
|
||||
import {
|
||||
APM_STORE_STATS_BASE_URL,
|
||||
currentApp,
|
||||
currentAppIsInstalled,
|
||||
} from "../global/storeConfig";
|
||||
import { APM_STORE_BASE_URL } from "../global/storeConfig";
|
||||
import { downloads } from "../global/downloadStatus";
|
||||
|
||||
@@ -14,6 +18,7 @@ import {
|
||||
App,
|
||||
DownloadItemStatus,
|
||||
} from "../global/typedefinition";
|
||||
import axios from "axios";
|
||||
|
||||
let downloadIdCounter = 0;
|
||||
const logger = pino({ name: "processInstall.ts" });
|
||||
@@ -53,10 +58,27 @@ export const handleInstall = () => {
|
||||
// Send to main process to start download
|
||||
window.ipcRenderer.send("queue-install", JSON.stringify(download));
|
||||
|
||||
// const encodedPkg = encodeURIComponent(currentApp.value.Pkgname);
|
||||
// openApmStoreUrl(`apmstore://install?pkg=${encodedPkg}`, {
|
||||
// fallbackText: `/usr/bin/apm-installer --install ${currentApp.value.Pkgname}`
|
||||
// });
|
||||
// Send download statistics to server
|
||||
logger.info("发送下载次数统计...");
|
||||
const axiosInstance = axios.create({
|
||||
baseURL: APM_STORE_STATS_BASE_URL,
|
||||
timeout: 5000, // 增加到 5 秒,避免网络波动导致的超时
|
||||
});
|
||||
axiosInstance
|
||||
.post(
|
||||
"/handle_post",
|
||||
{
|
||||
path: `${window.apm_store.arch}/${currentApp.value.category}/${currentApp.value.pkgname}`,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
logger.info("下载次数统计已发送,状态:", response.data);
|
||||
});
|
||||
};
|
||||
|
||||
export const handleRetry = (download_: DownloadItem) => {
|
||||
@@ -124,7 +146,7 @@ window.ipcRenderer.on(
|
||||
if (downloadObj) {
|
||||
downloadObj.progress = payload.progress;
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
window.ipcRenderer.on("install-log", (_event, log: InstallLog) => {
|
||||
|
||||
2
src/vite-env.d.ts
vendored
2
src/vite-env.d.ts
vendored
@@ -12,3 +12,5 @@ interface Window {
|
||||
ipcRenderer: import("electron").IpcRenderer;
|
||||
apm_store: any;
|
||||
}
|
||||
|
||||
declare const __APP_VERSION__: string;
|
||||
|
||||
Reference in New Issue
Block a user