mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-08-06 12:03:57 +08:00
!400 投稿器用自渲染对话框替换alert修复选择deb后无法编辑信息的问题、拆分投稿器源码
Merge pull request !400 from gfdgd xi/Erotica
This commit is contained in:
File diff suppressed because it is too large
Load Diff
+12
-904
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
app,
|
app,
|
||||||
BrowserWindow,
|
BrowserWindow,
|
||||||
dialog,
|
|
||||||
ipcMain,
|
ipcMain,
|
||||||
Menu,
|
Menu,
|
||||||
nativeImage,
|
nativeImage,
|
||||||
@@ -15,7 +14,6 @@ import path from "node:path";
|
|||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import pino from "pino";
|
import pino from "pino";
|
||||||
import https from "node:https";
|
|
||||||
import { handleCommandLine } from "./deeplink.js";
|
import { handleCommandLine } from "./deeplink.js";
|
||||||
import { isLoaded } from "../global.js";
|
import { isLoaded } from "../global.js";
|
||||||
import { tasks } from "./backend/install-manager.js";
|
import { tasks } from "./backend/install-manager.js";
|
||||||
@@ -25,6 +23,7 @@ import {
|
|||||||
getMainWindowCloseAction,
|
getMainWindowCloseAction,
|
||||||
type MainWindowCloseGuardState,
|
type MainWindowCloseGuardState,
|
||||||
} from "./window-close-guard.js";
|
} from "./window-close-guard.js";
|
||||||
|
import { registerSubmitterHandlers } from "./backend/submitter.js";
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
process.env.APP_ROOT = path.join(__dirname, "../..");
|
process.env.APP_ROOT = path.join(__dirname, "../..");
|
||||||
@@ -106,7 +105,6 @@ if (!app.requestSingleInstanceLock()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let win: BrowserWindow | null = null;
|
let win: BrowserWindow | null = null;
|
||||||
let submitterWin: BrowserWindow | null = null;
|
|
||||||
let allowAppExit = false;
|
let allowAppExit = false;
|
||||||
const preload = path.join(__dirname, "../preload/index.mjs");
|
const preload = path.join(__dirname, "../preload/index.mjs");
|
||||||
const indexHtml = path.join(RENDERER_DIST, "index.html");
|
const indexHtml = path.join(RENDERER_DIST, "index.html");
|
||||||
@@ -115,6 +113,17 @@ const getUserAgent = (): string => {
|
|||||||
return `Spark-Store/${getAppVersion()}`;
|
return `Spark-Store/${getAppVersion()}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let submitterWin: BrowserWindow | null = null;
|
||||||
|
registerSubmitterHandlers(
|
||||||
|
preload,
|
||||||
|
indexHtml,
|
||||||
|
VITE_DEV_SERVER_URL,
|
||||||
|
() => submitterWin,
|
||||||
|
(w) => {
|
||||||
|
submitterWin = w;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
logger.info("User Agent: " + getUserAgent());
|
logger.info("User Agent: " + getUserAgent());
|
||||||
|
|
||||||
/** 根据启动参数 --no-apm / --no-spark 决定只展示的来源 */
|
/** 根据启动参数 --no-apm / --no-spark 决定只展示的来源 */
|
||||||
@@ -432,907 +441,6 @@ ipcMain.handle("check-for-updates", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 启动投稿器窗口
|
// 启动投稿器窗口
|
||||||
ipcMain.handle("launch-submitter", async () => {
|
|
||||||
try {
|
|
||||||
if (submitterWin && !submitterWin.isDestroyed()) {
|
|
||||||
submitterWin.show();
|
|
||||||
submitterWin.focus();
|
|
||||||
return { success: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
submitterWin = new BrowserWindow({
|
|
||||||
title: "星火应用商店 - 投稿应用",
|
|
||||||
width: 800,
|
|
||||||
height: 900,
|
|
||||||
frame: false,
|
|
||||||
autoHideMenuBar: true,
|
|
||||||
icon: path.join(process.env.VITE_PUBLIC, "favicon.ico"),
|
|
||||||
webPreferences: {
|
|
||||||
preload,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (VITE_DEV_SERVER_URL) {
|
|
||||||
submitterWin.loadURL(`${VITE_DEV_SERVER_URL}#submitter`);
|
|
||||||
} else {
|
|
||||||
submitterWin.loadFile(indexHtml, { hash: "submitter" });
|
|
||||||
}
|
|
||||||
|
|
||||||
submitterWin.on("closed", () => {
|
|
||||||
submitterWin = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
submitterWin.webContents.setWindowOpenHandler(({ url }) => {
|
|
||||||
if (url.startsWith("https:")) shell.openExternal(url);
|
|
||||||
return { action: "deny" };
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.info("Submitter window opened");
|
|
||||||
return { success: true };
|
|
||||||
} catch (err) {
|
|
||||||
logger.error({ err }, "Failed to open submitter window");
|
|
||||||
return { success: false, message: (err as Error)?.message || String(err) };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.on("close-submitter-window", () => {
|
|
||||||
submitterWin?.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
interface DebInfo {
|
|
||||||
pkgname: string;
|
|
||||||
version: string;
|
|
||||||
author: string;
|
|
||||||
maintainer: string;
|
|
||||||
homepage: string;
|
|
||||||
description: string;
|
|
||||||
architecture: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HistoryAppInfo {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
pkgname: string;
|
|
||||||
version: string;
|
|
||||||
store: string;
|
|
||||||
author: string;
|
|
||||||
contributor: string;
|
|
||||||
website: string;
|
|
||||||
category: string;
|
|
||||||
tags: string;
|
|
||||||
more: string;
|
|
||||||
icon: string;
|
|
||||||
imgs: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
ipcMain.handle("select-deb-file", async (_event) => {
|
|
||||||
try {
|
|
||||||
const result = await dialog.showOpenDialog({
|
|
||||||
title: "选择 deb 安装包",
|
|
||||||
filters: [{ name: "Debian 包", extensions: ["deb"] }],
|
|
||||||
properties: ["openFile"],
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!result.canceled && result.filePaths.length > 0) {
|
|
||||||
return { success: true, filePath: result.filePaths[0] };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { success: false, message: "用户取消选择" };
|
|
||||||
} catch (err) {
|
|
||||||
logger.error({ err }, "Failed to select deb file");
|
|
||||||
return { success: false, message: (err as Error)?.message || "选择文件失败" };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle("parse-deb-file", async (_event, debPath: string) => {
|
|
||||||
try {
|
|
||||||
logger.info({ debPath }, "[Submitter] Starting parse-deb-file handler");
|
|
||||||
|
|
||||||
const { exec } = await import("node:child_process");
|
|
||||||
const util = await import("util");
|
|
||||||
const execAsync = util.promisify(exec);
|
|
||||||
|
|
||||||
const absoluteDebPath = path.resolve(debPath);
|
|
||||||
logger.info({ debPath, absoluteDebPath }, "[Submitter] Resolved absolute deb path");
|
|
||||||
|
|
||||||
if (!fs.existsSync(absoluteDebPath)) {
|
|
||||||
logger.error({ debPath, absoluteDebPath }, "[Submitter] Deb file not found");
|
|
||||||
return { success: false, message: `文件不存在: ${absoluteDebPath}` };
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info({ absoluteDebPath }, "[Submitter] Deb file exists, executing dpkg-deb command");
|
|
||||||
|
|
||||||
const { stdout, stderr } = await execAsync(
|
|
||||||
`dpkg-deb -f "${absoluteDebPath}" Package Version Maintainer Homepage Description Architecture`,
|
|
||||||
);
|
|
||||||
|
|
||||||
logger.info({ stdout, stderr }, "[Submitter] dpkg-deb command executed");
|
|
||||||
|
|
||||||
if (stderr) {
|
|
||||||
logger.error({ stderr }, "[Submitter] dpkg-deb returned error");
|
|
||||||
return { success: false, message: stderr };
|
|
||||||
}
|
|
||||||
|
|
||||||
const lines = stdout.trim().split("\n");
|
|
||||||
logger.info({ lineCount: lines.length, rawOutput: stdout }, "[Submitter] Parsing dpkg-deb output");
|
|
||||||
|
|
||||||
const debInfo: DebInfo = {
|
|
||||||
pkgname: "",
|
|
||||||
version: "",
|
|
||||||
author: "",
|
|
||||||
maintainer: "",
|
|
||||||
homepage: "",
|
|
||||||
description: "",
|
|
||||||
architecture: "",
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const line of lines) {
|
|
||||||
const [key, ...valueParts] = line.split(":");
|
|
||||||
const value = valueParts.join(":").trim();
|
|
||||||
logger.debug({ line, key, value }, "[Submitter] Processing dpkg-deb line");
|
|
||||||
|
|
||||||
switch (key.trim()) {
|
|
||||||
case "Package":
|
|
||||||
debInfo.pkgname = value.toLowerCase();
|
|
||||||
logger.info({ pkgname: debInfo.pkgname }, "[Submitter] Found Package name");
|
|
||||||
break;
|
|
||||||
case "Version":
|
|
||||||
debInfo.version = value;
|
|
||||||
logger.info({ version: debInfo.version }, "[Submitter] Found Version");
|
|
||||||
break;
|
|
||||||
case "Maintainer":
|
|
||||||
debInfo.maintainer = value;
|
|
||||||
debInfo.author = value;
|
|
||||||
logger.info({ maintainer: debInfo.maintainer }, "[Submitter] Found Maintainer");
|
|
||||||
break;
|
|
||||||
case "Homepage":
|
|
||||||
debInfo.homepage = value;
|
|
||||||
logger.info({ homepage: debInfo.homepage }, "[Submitter] Found Homepage");
|
|
||||||
break;
|
|
||||||
case "Description":
|
|
||||||
debInfo.description = value;
|
|
||||||
logger.info({ description: debInfo.description.substring(0, 100) + "..." }, "[Submitter] Found Description");
|
|
||||||
break;
|
|
||||||
case "Architecture":
|
|
||||||
debInfo.architecture = value;
|
|
||||||
logger.info({ architecture: debInfo.architecture }, "[Submitter] Found Architecture");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info({ debInfo }, "[Submitter] Deb file parsing completed successfully");
|
|
||||||
|
|
||||||
return { success: true, data: debInfo };
|
|
||||||
} catch (err) {
|
|
||||||
logger.error({ err, debPath }, "[Submitter] Failed to parse deb file with exception");
|
|
||||||
return {
|
|
||||||
success: false,
|
|
||||||
message: (err as Error)?.message || "解析deb文件失败",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle("search-history-app", async (_event, pkgname: string, useMirror = false) => {
|
|
||||||
try {
|
|
||||||
const baseUrl = useMirror
|
|
||||||
? "https://mirrors.sdu.edu.cn/spark-store"
|
|
||||||
: "https://spk-json.spark-app.store";
|
|
||||||
const storeArchs = ["store", "aarch64-store", "loong64-store"];
|
|
||||||
const categories = [
|
|
||||||
"chat",
|
|
||||||
"development",
|
|
||||||
"games",
|
|
||||||
"image_graphics",
|
|
||||||
"music",
|
|
||||||
"network",
|
|
||||||
"office",
|
|
||||||
"others",
|
|
||||||
"reading",
|
|
||||||
"themes",
|
|
||||||
"tools",
|
|
||||||
"video",
|
|
||||||
];
|
|
||||||
const results: HistoryAppInfo[] = [];
|
|
||||||
|
|
||||||
logger.info("[Submitter] ============== SEARCH HISTORY APP START ==============");
|
|
||||||
logger.info({ pkgname, useMirror, baseUrl, storeArchs, categories }, "[Submitter] Search parameters");
|
|
||||||
|
|
||||||
const allPromises: Promise<void>[] = [];
|
|
||||||
|
|
||||||
for (const arch of storeArchs) {
|
|
||||||
for (const category of categories) {
|
|
||||||
const url = `${baseUrl}/${arch}/${category}/${pkgname}/app.json`;
|
|
||||||
logger.info({ arch, category, url }, "[Submitter] Starting search request");
|
|
||||||
|
|
||||||
const promise = fetch(url, {
|
|
||||||
headers: { "User-Agent": getUserAgent() },
|
|
||||||
})
|
|
||||||
.then(async (response) => {
|
|
||||||
logger.info({ arch, category, status: response.status }, "[Submitter] Fetch completed");
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
const json = await response.json();
|
|
||||||
logger.info({ arch, category, rawJson: JSON.stringify(json, null, 2) }, "[Submitter] Response parsed");
|
|
||||||
|
|
||||||
const appPkgname = json?.pkgname || json?.Pkgname || json?.packageName || "";
|
|
||||||
logger.info({ arch, category, appPkgname, searchPkgname: pkgname }, "[Submitter] Comparing pkgname");
|
|
||||||
|
|
||||||
if (appPkgname.toLowerCase() === pkgname.toLowerCase()) {
|
|
||||||
logger.info({ arch, category, item: json }, "[Submitter] Found matching item");
|
|
||||||
|
|
||||||
let iconUrl = json.icons || json.icon || "";
|
|
||||||
let imgs = json.imgUrls || json.imgs || json.img_urls || [];
|
|
||||||
|
|
||||||
if (typeof imgs === "string") {
|
|
||||||
try {
|
|
||||||
imgs = JSON.parse(imgs);
|
|
||||||
logger.info({ arch, category, parsedImgsCount: Array.isArray(imgs) ? imgs.length : 0 }, "[Submitter] Parsed img_urls from string");
|
|
||||||
} catch {
|
|
||||||
imgs = [];
|
|
||||||
logger.warn({ arch, category, imgsString: imgs }, "[Submitter] Failed to parse img_urls string");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iconUrl && typeof iconUrl === "string") {
|
|
||||||
if (useMirror) {
|
|
||||||
iconUrl = iconUrl.replace("spk-json.spark-app.store", "mirrors.sdu.edu.cn/spark-store");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(imgs)) {
|
|
||||||
imgs = imgs.map((img: string) => {
|
|
||||||
if (useMirror && typeof img === "string") {
|
|
||||||
return img.replace("spk-json.spark-app.store", "mirrors.sdu.edu.cn/spark-store");
|
|
||||||
}
|
|
||||||
return img;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
results.push({
|
|
||||||
id: json.id || json.Id || 0,
|
|
||||||
name: json.name || json.Name || "",
|
|
||||||
pkgname: json.pkgname || json.Pkgname || "",
|
|
||||||
version: json.version || json.Version || "",
|
|
||||||
store: arch,
|
|
||||||
author: json.author || json.Author || "",
|
|
||||||
contributor: json.contributor || json.Contributor || "",
|
|
||||||
website: json.website || json.Website || "",
|
|
||||||
category: category,
|
|
||||||
tags: json.tags || json.Tags || "",
|
|
||||||
more: json.more || json.More || "",
|
|
||||||
icon: iconUrl,
|
|
||||||
imgs: imgs,
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.info({ arch, count: results.length }, "[Submitter] Added to results");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
logger.warn({ arch, category, error }, "[Submitter] Request failed or exception caught");
|
|
||||||
});
|
|
||||||
|
|
||||||
allPromises.push(promise);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(allPromises);
|
|
||||||
|
|
||||||
logger.info("[Submitter] ============== SEARCH COMPLETED ==============");
|
|
||||||
logger.info({ totalResults: results.length, results }, "[Submitter] Search results");
|
|
||||||
|
|
||||||
return { success: true, data: results };
|
|
||||||
} catch (err) {
|
|
||||||
logger.error("[Submitter] ============== SEARCH FAILED ==============");
|
|
||||||
logger.error({ errorType: (err as Error)?.name, errorMessage: (err as Error)?.message, errorStack: (err as Error)?.stack }, "[Submitter] Exception caught");
|
|
||||||
return {
|
|
||||||
success: false,
|
|
||||||
message: (err as Error)?.message || "搜索历史信息失败",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle("get-category-list", async () => {
|
|
||||||
try {
|
|
||||||
const apiUrl = "https://upload.deepinos.org.cn/api/index/getTypeList";
|
|
||||||
logger.info("[Submitter] ============== GET CATEGORY LIST START ==============");
|
|
||||||
logger.info({ apiUrl, userAgent: getUserAgent() }, "[Submitter] Request parameters");
|
|
||||||
|
|
||||||
const startTime = Date.now();
|
|
||||||
const response = await fetch(apiUrl, {
|
|
||||||
headers: { "User-Agent": getUserAgent() },
|
|
||||||
});
|
|
||||||
const endTime = Date.now();
|
|
||||||
|
|
||||||
logger.info({ status: response.status, statusText: response.statusText, duration: endTime - startTime }, "[Submitter] Fetch completed");
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const errorText = await response.text();
|
|
||||||
logger.error({ status: response.status, errorBody: errorText }, "[Submitter] Request failed");
|
|
||||||
return { success: false, message: `获取分类列表失败 (${response.status})` };
|
|
||||||
}
|
|
||||||
|
|
||||||
const json = await response.json();
|
|
||||||
logger.info({ code: json?.code, msg: json?.msg, dataType: typeof json?.data, dataLength: json?.data?.length || "N/A", response: json }, "[Submitter] Response parsed");
|
|
||||||
|
|
||||||
return { success: true, data: json };
|
|
||||||
} catch (err) {
|
|
||||||
logger.error({ errorType: (err as Error)?.name, errorMessage: (err as Error)?.message, errorStack: (err as Error)?.stack }, "[Submitter] Exception caught");
|
|
||||||
return {
|
|
||||||
success: false,
|
|
||||||
message: (err as Error)?.message || "获取分类列表失败",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle("get-tags-list", async () => {
|
|
||||||
try {
|
|
||||||
const apiUrl = "https://upload.deepinos.org.cn/api/index/getTagsList";
|
|
||||||
logger.info("[Submitter] ============== GET TAGS LIST START ==============");
|
|
||||||
logger.info({ apiUrl, userAgent: getUserAgent() }, "[Submitter] Request parameters");
|
|
||||||
|
|
||||||
const startTime = Date.now();
|
|
||||||
const response = await fetch(apiUrl, {
|
|
||||||
headers: { "User-Agent": getUserAgent() },
|
|
||||||
});
|
|
||||||
const endTime = Date.now();
|
|
||||||
|
|
||||||
logger.info({ status: response.status, statusText: response.statusText, duration: endTime - startTime }, "[Submitter] Fetch completed");
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const errorText = await response.text();
|
|
||||||
logger.error({ status: response.status, errorBody: errorText }, "[Submitter] Request failed");
|
|
||||||
return { success: false, message: `获取标签列表失败 (${response.status})` };
|
|
||||||
}
|
|
||||||
|
|
||||||
const json = await response.json();
|
|
||||||
logger.info({ code: json?.code, msg: json?.msg, dataType: typeof json?.data, dataLength: json?.data?.length || "N/A", response: json }, "[Submitter] Response parsed");
|
|
||||||
|
|
||||||
return { success: true, data: json };
|
|
||||||
} catch (err) {
|
|
||||||
logger.error({ errorType: (err as Error)?.name, errorMessage: (err as Error)?.message, errorStack: (err as Error)?.stack }, "[Submitter] Exception caught");
|
|
||||||
return {
|
|
||||||
success: false,
|
|
||||||
message: (err as Error)?.message || "获取标签列表失败",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
interface OssUploadMetadata {
|
|
||||||
code: number;
|
|
||||||
msg: string;
|
|
||||||
data: {
|
|
||||||
dir: string;
|
|
||||||
host: string;
|
|
||||||
ossAccessKeyId: string;
|
|
||||||
policy: string;
|
|
||||||
signature: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const categoryNameToIdMap: Record<string, number> = {
|
|
||||||
"network": 3,
|
|
||||||
"chat": 9,
|
|
||||||
"music": 2,
|
|
||||||
"video": 12,
|
|
||||||
"image_graphics": 6,
|
|
||||||
"games": 1,
|
|
||||||
"office": 4,
|
|
||||||
"reading": 8,
|
|
||||||
"development": 7,
|
|
||||||
"tools": 11,
|
|
||||||
"themes": 10,
|
|
||||||
"others": 5,
|
|
||||||
};
|
|
||||||
|
|
||||||
function getCategoryIdByName(categoryName: string): number {
|
|
||||||
return categoryNameToIdMap[categoryName];
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateUUID(): string {
|
|
||||||
const hexChars = "0123456789abcdef";
|
|
||||||
let uuid = "";
|
|
||||||
for (let i = 0; i < 32; i++) {
|
|
||||||
uuid += hexChars[Math.floor(Math.random() * 16)];
|
|
||||||
}
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUUIDFileNameSuggestIcoPic(filePath: string): string {
|
|
||||||
const ext = path.extname(filePath).toLowerCase().replace(".", "");
|
|
||||||
const uuid = generateUUID();
|
|
||||||
return `${uuid}.${ext}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUUIDFileNameSuggestDeb(_filePath: string): string {
|
|
||||||
const uuid = generateUUID();
|
|
||||||
return `${uuid}.deb`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getOssUploadMetadata(type: "icons" | "pic" | "deb"): Promise<OssUploadMetadata> {
|
|
||||||
const startTime = Date.now();
|
|
||||||
const pathMap: Record<string, string> = {
|
|
||||||
icons: "upload_icons",
|
|
||||||
pic: "upload_pic",
|
|
||||||
deb: "upload_deb",
|
|
||||||
};
|
|
||||||
const url = `https://upload.deepinos.org.cn/api/index/${pathMap[type]}`;
|
|
||||||
logger.info(`[Submitter] ============== GET OSS METADATA START (${type}) ==============`);
|
|
||||||
logger.info({ url, timestamp: new Date().toISOString() }, `[Submitter] Getting OSS metadata for ${type}`);
|
|
||||||
|
|
||||||
const response = await fetch(url, {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"User-Agent": getUserAgent(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const duration = Date.now() - startTime;
|
|
||||||
logger.info({ status: response.status, statusText: response.statusText, duration }, `[Submitter] OSS metadata response for ${type}`);
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const errorText = await response.text();
|
|
||||||
logger.error({ errorText }, `[Submitter] Failed to get OSS metadata for ${type}`);
|
|
||||||
throw new Error(`获取 ${type} 上传签名失败: ${response.status} - ${errorText.substring(0, 200)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const responseText = await response.text();
|
|
||||||
logger.info({ responseTextLength: responseText.length, responseText: responseText.substring(0, 1000) }, `[Submitter] Raw OSS metadata response for ${type}`);
|
|
||||||
|
|
||||||
let result: unknown;
|
|
||||||
try {
|
|
||||||
result = JSON.parse(responseText);
|
|
||||||
logger.info({ resultType: typeof result, resultKeys: typeof result === "object" && result !== null ? Object.keys(result as object) : [] }, `[Submitter] Parsed OSS metadata result type for ${type}`);
|
|
||||||
} catch (parseError) {
|
|
||||||
logger.error({ parseError: (parseError as Error)?.message }, `[Submitter] Failed to parse OSS metadata response for ${type}`);
|
|
||||||
throw new Error(`解析 ${type} 上传签名响应失败: ${(parseError as Error)?.message}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof result !== "object" || result === null) {
|
|
||||||
logger.error({ result }, `[Submitter] OSS metadata response is not an object for ${type}`);
|
|
||||||
throw new Error(`${type} 上传签名响应格式错误`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const resultObj = result as Record<string, unknown>;
|
|
||||||
if (resultObj.data === undefined || resultObj.data === null) {
|
|
||||||
logger.error({ result }, `[Submitter] OSS metadata response data field is undefined for ${type}`);
|
|
||||||
throw new Error(`${type} 上传签名响应缺少 data 字段`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const dataObj = resultObj.data as Record<string, unknown>;
|
|
||||||
if (!dataObj.host || !dataObj.dir) {
|
|
||||||
logger.error({ data: resultObj.data }, `[Submitter] OSS metadata response data missing host or dir for ${type}`);
|
|
||||||
throw new Error(`${type} 上传签名响应 data 字段缺少 host 或 dir`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const ossMetadata: OssUploadMetadata = {
|
|
||||||
code: Number(resultObj.code) || 0,
|
|
||||||
msg: String(resultObj.msg || ""),
|
|
||||||
data: {
|
|
||||||
dir: String(dataObj.dir),
|
|
||||||
host: String(dataObj.host),
|
|
||||||
ossAccessKeyId: String(dataObj.OSSAccessKeyId || dataObj.ossAccessKeyId || dataObj.oss_access_key_id || ""),
|
|
||||||
policy: String(dataObj.policy || ""),
|
|
||||||
signature: String(dataObj.signature || ""),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
logger.info(`[Submitter] ============== OSS METADATA RECEIVED (${type}) ==============`);
|
|
||||||
logger.info({ code: ossMetadata.code, msg: ossMetadata.msg }, `[Submitter] OSS metadata result for ${type}`);
|
|
||||||
logger.info({ host: ossMetadata.data.host, dir: ossMetadata.data.dir }, `[Submitter] OSS upload host and dir for ${type}`);
|
|
||||||
logger.info({ ossAccessKeyIdLength: ossMetadata.data.ossAccessKeyId.length, policyLength: ossMetadata.data.policy.length, signatureLength: ossMetadata.data.signature.length }, `[Submitter] OSS credential lengths for ${type}`);
|
|
||||||
|
|
||||||
return ossMetadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
type UploadProgressCallback = (progress: number, fileType: string) => void;
|
|
||||||
|
|
||||||
async function uploadFileToOss(
|
|
||||||
metadata: OssUploadMetadata,
|
|
||||||
filePath: string,
|
|
||||||
fileName: string,
|
|
||||||
mimeType: string,
|
|
||||||
fileType: string,
|
|
||||||
progressCallback?: UploadProgressCallback
|
|
||||||
): Promise<string> {
|
|
||||||
const startTime = Date.now();
|
|
||||||
const { host, dir, ossAccessKeyId, policy, signature } = metadata.data;
|
|
||||||
const uploadUrl = host;
|
|
||||||
const objectKey = `${dir}${fileName}`;
|
|
||||||
|
|
||||||
logger.info(`[Submitter] ============== UPLOAD FILE START (${fileType}) ==============`);
|
|
||||||
logger.info({ uploadUrl, objectKey, filePath, fileName, mimeType, timestamp: new Date().toISOString() }, `[Submitter] Starting upload for ${fileType}`);
|
|
||||||
|
|
||||||
const fileStat = fs.statSync(filePath);
|
|
||||||
const fileSize = fileStat.size;
|
|
||||||
logger.info({ fileSize, fileSizeHuman: `${(fileSize / 1024 / 1024).toFixed(2)} MB` }, `[Submitter] File size for ${fileType}`);
|
|
||||||
|
|
||||||
const fileBuffer = fs.readFileSync(filePath);
|
|
||||||
logger.info({ bufferSize: fileBuffer.length }, `[Submitter] File buffer ready for ${fileType}`);
|
|
||||||
|
|
||||||
const boundary = `----SparkStoreUploadBoundary${Date.now().toString(36)}`;
|
|
||||||
const CRLF = Buffer.from("\r\n", "ascii");
|
|
||||||
|
|
||||||
const encodeField = (str: string) => Buffer.from(str, "utf8");
|
|
||||||
|
|
||||||
const headerBuffers: Buffer[] = [];
|
|
||||||
headerBuffers.push(encodeField(`--${boundary}\r\n`));
|
|
||||||
headerBuffers.push(encodeField(`Content-Disposition: form-data; name="key"\r\n\r\n`));
|
|
||||||
headerBuffers.push(encodeField(objectKey));
|
|
||||||
headerBuffers.push(CRLF);
|
|
||||||
|
|
||||||
headerBuffers.push(encodeField(`--${boundary}\r\n`));
|
|
||||||
headerBuffers.push(encodeField(`Content-Disposition: form-data; name="ossAccessKeyId"\r\n\r\n`));
|
|
||||||
headerBuffers.push(encodeField(ossAccessKeyId));
|
|
||||||
headerBuffers.push(CRLF);
|
|
||||||
|
|
||||||
headerBuffers.push(encodeField(`--${boundary}\r\n`));
|
|
||||||
headerBuffers.push(encodeField(`Content-Disposition: form-data; name="policy"\r\n\r\n`));
|
|
||||||
headerBuffers.push(encodeField(policy));
|
|
||||||
headerBuffers.push(CRLF);
|
|
||||||
|
|
||||||
headerBuffers.push(encodeField(`--${boundary}\r\n`));
|
|
||||||
headerBuffers.push(encodeField(`Content-Disposition: form-data; name="signature"\r\n\r\n`));
|
|
||||||
headerBuffers.push(encodeField(signature));
|
|
||||||
headerBuffers.push(CRLF);
|
|
||||||
|
|
||||||
headerBuffers.push(encodeField(`--${boundary}\r\n`));
|
|
||||||
headerBuffers.push(encodeField(`Content-Disposition: form-data; name="success_action_status"\r\n\r\n`));
|
|
||||||
headerBuffers.push(encodeField("200"));
|
|
||||||
headerBuffers.push(CRLF);
|
|
||||||
|
|
||||||
headerBuffers.push(encodeField(`--${boundary}\r\n`));
|
|
||||||
headerBuffers.push(encodeField(`Content-Disposition: form-data; name="file"; filename="${fileName}"\r\n`));
|
|
||||||
headerBuffers.push(encodeField(`Content-Type: ${mimeType}\r\n\r\n`));
|
|
||||||
|
|
||||||
const formHeaderBuffer = Buffer.concat(headerBuffers);
|
|
||||||
const formFooterBuffer = Buffer.concat([CRLF, encodeField(`--${boundary}--\r\n`)]);
|
|
||||||
const totalLength = formHeaderBuffer.length + fileBuffer.length + formFooterBuffer.length;
|
|
||||||
|
|
||||||
logger.info({ formHeaderLength: formHeaderBuffer.length, formFooterLength: formFooterBuffer.length, totalLength, fileSize }, `[Submitter] Form lengths for ${fileType}`);
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const url = new URL(uploadUrl);
|
|
||||||
const options: https.RequestOptions = {
|
|
||||||
hostname: url.hostname,
|
|
||||||
port: url.port ? parseInt(url.port) : 443,
|
|
||||||
path: url.pathname + url.search,
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"User-Agent": getUserAgent(),
|
|
||||||
"Content-Type": `multipart/form-data; boundary=${boundary}`,
|
|
||||||
"Content-Length": totalLength,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
logger.info(`[Submitter] ============== SENDING UPLOAD REQUEST (${fileType}) ==============`);
|
|
||||||
|
|
||||||
const req = https.request(options, (res) => {
|
|
||||||
let responseData = "";
|
|
||||||
res.on("data", (chunk) => {
|
|
||||||
responseData += chunk;
|
|
||||||
});
|
|
||||||
res.on("end", () => {
|
|
||||||
const duration = Date.now() - startTime;
|
|
||||||
logger.info(`[Submitter] ============== UPLOAD RESPONSE RECEIVED (${fileType}) ==============`);
|
|
||||||
logger.info({ status: res.statusCode, duration }, `[Submitter] Upload response for ${fileType}`);
|
|
||||||
logger.info({ responseHeaders: res.headers }, `[Submitter] Response headers for ${fileType}`);
|
|
||||||
logger.info({ responseBody: responseData.substring(0, 1000) }, `[Submitter] Response body for ${fileType}`);
|
|
||||||
|
|
||||||
if (res.statusCode !== 200) {
|
|
||||||
logger.error({ errorText: responseData.substring(0, 500) }, `[Submitter] Upload failed for ${fileType}`);
|
|
||||||
reject(new Error(`${fileType} 上传失败: ${res.statusCode} - ${responseData.substring(0, 500)}`));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const finalUrl = `${host}${objectKey}`;
|
|
||||||
logger.info({ finalUrl }, `[Submitter] ${fileType} upload successful, URL: ${finalUrl}`);
|
|
||||||
resolve(finalUrl);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
req.on("error", (err) => {
|
|
||||||
logger.error({ err }, `[Submitter] Upload request error for ${fileType}`);
|
|
||||||
reject(new Error(`${fileType} 上传失败: ${err.message}`));
|
|
||||||
});
|
|
||||||
|
|
||||||
req.write(formHeaderBuffer);
|
|
||||||
|
|
||||||
let uploadedBytes = formHeaderBuffer.length;
|
|
||||||
|
|
||||||
const chunkSize = 1024 * 1024;
|
|
||||||
for (let offset = 0; offset < fileBuffer.length; offset += chunkSize) {
|
|
||||||
const chunk = fileBuffer.slice(offset, Math.min(offset + chunkSize, fileBuffer.length));
|
|
||||||
req.write(chunk);
|
|
||||||
uploadedBytes += chunk.length;
|
|
||||||
|
|
||||||
if (progressCallback) {
|
|
||||||
const progress = Math.min((uploadedBytes / totalLength) * 100, 100);
|
|
||||||
progressCallback(progress, fileType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
req.write(formFooterBuffer);
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ipcMain.handle("submit-app", async (event, formData: unknown) => {
|
|
||||||
try {
|
|
||||||
const startTime = Date.now();
|
|
||||||
logger.info("[Submitter] ============== SUBMIT APP START ==============");
|
|
||||||
logger.info({ timestamp: new Date().toISOString() }, "[Submitter] Submission started at");
|
|
||||||
|
|
||||||
if (typeof formData !== "object" || formData === null) {
|
|
||||||
logger.error("[Submitter] Form data is not an object");
|
|
||||||
return { success: false, message: "表单数据格式错误" };
|
|
||||||
}
|
|
||||||
|
|
||||||
const dataObj = formData as Record<string, unknown>;
|
|
||||||
logger.info("[Submitter] ============== FORM DATA RECEIVED ==============");
|
|
||||||
logger.info({ name: dataObj.name }, "[Submitter] App name");
|
|
||||||
logger.info({ pkgname: dataObj.pkgname }, "[Submitter] Package name");
|
|
||||||
logger.info({ version: dataObj.version }, "[Submitter] Version");
|
|
||||||
logger.info({ author: dataObj.author }, "[Submitter] Author");
|
|
||||||
logger.info({ contributor: dataObj.contributor }, "[Submitter] Contributor");
|
|
||||||
logger.info({ website: dataObj.website }, "[Submitter] Website");
|
|
||||||
logger.info({ debFilePath: dataObj.debFilePath }, "[Submitter] Deb file path");
|
|
||||||
logger.info({ iconPath: dataObj.iconPath }, "[Submitter] Icon path");
|
|
||||||
logger.info({ category: dataObj.category }, "[Submitter] Category");
|
|
||||||
logger.info({ tags: dataObj.tags }, "[Submitter] Tags");
|
|
||||||
logger.info({ descriptionLength: typeof dataObj.description === "string" ? dataObj.description.length : 0 }, "[Submitter] Description length");
|
|
||||||
logger.info({ screenshotsCount: Array.isArray(dataObj.screenshots) ? dataObj.screenshots.length : 0 }, "[Submitter] Screenshots count");
|
|
||||||
|
|
||||||
const debFilePath = String(dataObj.debFilePath || "");
|
|
||||||
const iconPath = String(dataObj.iconPath || "");
|
|
||||||
const screenshots = Array.isArray(dataObj.screenshots) ? dataObj.screenshots : [];
|
|
||||||
|
|
||||||
if (!debFilePath) {
|
|
||||||
logger.error("[Submitter] Deb file path is empty");
|
|
||||||
return { success: false, message: "请选择 deb 文件" };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fs.existsSync(debFilePath)) {
|
|
||||||
logger.error({ debFilePath }, "[Submitter] Deb file does not exist");
|
|
||||||
return { success: false, message: `deb 文件不存在: ${debFilePath}` };
|
|
||||||
}
|
|
||||||
|
|
||||||
const sendUploadProgress = (step: string, progress: number, message: string) => {
|
|
||||||
event.sender.send("submit-upload-progress", { step, progress, message });
|
|
||||||
};
|
|
||||||
|
|
||||||
let iconUrl = "";
|
|
||||||
if (iconPath) {
|
|
||||||
logger.info("[Submitter] ============== STEP 1: UPLOAD ICON ==============");
|
|
||||||
let iconFilePath = iconPath;
|
|
||||||
|
|
||||||
if (iconPath.startsWith("http://") || iconPath.startsWith("https://")) {
|
|
||||||
logger.info({ iconPath }, "[Submitter] Icon is a remote URL, downloading first");
|
|
||||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "spark-store-submitter-"));
|
|
||||||
iconFilePath = path.join(tempDir, "icon.png");
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(iconPath);
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`下载图标失败: ${response.status}`);
|
|
||||||
}
|
|
||||||
const blob = await response.blob();
|
|
||||||
const buffer = Buffer.from(await blob.arrayBuffer());
|
|
||||||
fs.writeFileSync(iconFilePath, buffer);
|
|
||||||
logger.info({ iconFilePath, size: buffer.length }, "[Submitter] Icon downloaded successfully");
|
|
||||||
} catch (err) {
|
|
||||||
logger.error({ err, iconPath }, "[Submitter] Failed to download icon from URL");
|
|
||||||
return { success: false, message: `下载图标失败: ${(err as Error).message}` };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fs.existsSync(iconFilePath)) {
|
|
||||||
const iconMetadata = await getOssUploadMetadata("icons");
|
|
||||||
const iconFileName = getUUIDFileNameSuggestIcoPic(iconFilePath);
|
|
||||||
sendUploadProgress("icon", 0, "正在上传图标...");
|
|
||||||
iconUrl = await uploadFileToOss(iconMetadata, iconFilePath, iconFileName, "image/png", "icon", (progress) => {
|
|
||||||
sendUploadProgress("icon", progress, `正在上传图标... ${Math.floor(progress)}%`);
|
|
||||||
});
|
|
||||||
sendUploadProgress("icon", 100, "图标上传完成");
|
|
||||||
logger.info({ iconUrl }, "[Submitter] Icon upload completed");
|
|
||||||
|
|
||||||
if (iconPath.startsWith("http://") || iconPath.startsWith("https://")) {
|
|
||||||
fs.unlinkSync(iconFilePath);
|
|
||||||
fs.rmdirSync(path.dirname(iconFilePath));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.error({ iconFilePath }, "[Submitter] Icon file does not exist");
|
|
||||||
return { success: false, message: `图标文件不存在: ${iconFilePath}` };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const screenshotUrls: string[] = [];
|
|
||||||
for (let i = 0; i < screenshots.length; i++) {
|
|
||||||
const screenshot = screenshots[i];
|
|
||||||
logger.info({ index: i, screenshot }, "[Submitter] Processing screenshot");
|
|
||||||
|
|
||||||
if (typeof screenshot === "string") {
|
|
||||||
logger.info(`[Submitter] ============== STEP 2: UPLOAD SCREENSHOT ${i + 1} ==============`);
|
|
||||||
let screenshotFilePath = screenshot;
|
|
||||||
|
|
||||||
if (screenshot.startsWith("http://") || screenshot.startsWith("https://")) {
|
|
||||||
logger.info({ screenshot }, "[Submitter] Screenshot is a remote URL, downloading first");
|
|
||||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "spark-store-submitter-"));
|
|
||||||
screenshotFilePath = path.join(tempDir, `screen_${i + 1}.png`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(screenshot);
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`下载截图失败: ${response.status}`);
|
|
||||||
}
|
|
||||||
const blob = await response.blob();
|
|
||||||
const buffer = Buffer.from(await blob.arrayBuffer());
|
|
||||||
fs.writeFileSync(screenshotFilePath, buffer);
|
|
||||||
logger.info({ screenshotFilePath, size: buffer.length }, "[Submitter] Screenshot downloaded successfully");
|
|
||||||
} catch (err) {
|
|
||||||
logger.error({ err, screenshot }, "[Submitter] Failed to download screenshot from URL");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fs.existsSync(screenshotFilePath)) {
|
|
||||||
const picMetadata = await getOssUploadMetadata("pic");
|
|
||||||
const picFileName = getUUIDFileNameSuggestIcoPic(screenshotFilePath);
|
|
||||||
sendUploadProgress(`screenshot-${i}`, 0, `正在上传截图 ${i + 1}...`);
|
|
||||||
const picUrl = await uploadFileToOss(picMetadata, screenshotFilePath, picFileName, "image/png", `screenshot ${i + 1}`, (progress) => {
|
|
||||||
sendUploadProgress(`screenshot-${i}`, progress, `正在上传截图 ${i + 1}... ${Math.floor(progress)}%`);
|
|
||||||
});
|
|
||||||
sendUploadProgress(`screenshot-${i}`, 100, `截图 ${i + 1} 上传完成`);
|
|
||||||
screenshotUrls.push(picUrl);
|
|
||||||
logger.info({ picUrl }, `[Submitter] Screenshot ${i + 1} upload completed`);
|
|
||||||
|
|
||||||
if (screenshot.startsWith("http://") || screenshot.startsWith("https://")) {
|
|
||||||
fs.unlinkSync(screenshotFilePath);
|
|
||||||
fs.rmdirSync(path.dirname(screenshotFilePath));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.warn({ screenshotFilePath }, "[Submitter] Screenshot file does not exist, skipping");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("[Submitter] ============== STEP 3: UPLOAD DEB ==============");
|
|
||||||
logger.info({ debFilePath, debFileName: getUUIDFileNameSuggestDeb(debFilePath) }, "[Submitter] Starting deb upload");
|
|
||||||
const debMetadata = await getOssUploadMetadata("deb");
|
|
||||||
const debFileName = getUUIDFileNameSuggestDeb(debFilePath);
|
|
||||||
sendUploadProgress("deb", 0, "正在上传安装包...");
|
|
||||||
const debUrl = await uploadFileToOss(debMetadata, debFilePath, debFileName, "application/vnd.debian.binary-package", "deb", (progress) => {
|
|
||||||
sendUploadProgress("deb", progress, `正在上传安装包... ${Math.floor(progress)}%`);
|
|
||||||
});
|
|
||||||
sendUploadProgress("deb", 100, "安装包上传完成");
|
|
||||||
logger.info("[Submitter] ============== DEB UPLOAD SUCCESSFUL ==============");
|
|
||||||
logger.info({ debUrl, debFileName }, "[Submitter] Deb upload completed successfully");
|
|
||||||
|
|
||||||
logger.info("[Submitter] ============== STEP 4: SUBMIT APPLICATION ==============");
|
|
||||||
|
|
||||||
const debFileStat = fs.statSync(debFilePath);
|
|
||||||
|
|
||||||
const categoryName = String(dataObj.category || "");
|
|
||||||
const categoryId = getCategoryIdByName(categoryName);
|
|
||||||
logger.info({ categoryName, categoryId }, "[Submitter] Category name and ID");
|
|
||||||
|
|
||||||
const tagsString = String(dataObj.tags || "");
|
|
||||||
const tagsArray = tagsString ? tagsString.split(";").map((t: string) => t.trim()).filter((t: string) => t) : [];
|
|
||||||
logger.info({ tagsString, tagsArray }, "[Submitter] Tags conversion");
|
|
||||||
|
|
||||||
const submitData = {
|
|
||||||
application_name: String(dataObj.pkgname || ""),
|
|
||||||
application_name_zh: String(dataObj.name || ""),
|
|
||||||
contributor: String(dataObj.contributor || ""),
|
|
||||||
icons: iconUrl,
|
|
||||||
size: debFileStat.size,
|
|
||||||
file_name: path.basename(debFilePath).replace(/\s+/g, "_plus_"),
|
|
||||||
website: String(dataObj.website || ""),
|
|
||||||
version: String(dataObj.version || ""),
|
|
||||||
more: String(dataObj.description || ""),
|
|
||||||
type_id: categoryId,
|
|
||||||
author: String(dataObj.author || ""),
|
|
||||||
remark: (dataObj.remark as string || "") + " - (来自于投稿器_v" + getAppVersion() + ")",
|
|
||||||
img_urls: screenshotUrls,
|
|
||||||
deb_url: debUrl,
|
|
||||||
mail: String(dataObj.mail || dataObj.contributor || ""),
|
|
||||||
tags: tagsArray,
|
|
||||||
};
|
|
||||||
|
|
||||||
logger.info("[Submitter] ============== VALIDATING SUBMISSION DATA ==============");
|
|
||||||
const requiredFields = ["application_name", "application_name_zh", "contributor", "icons", "size", "file_name", "version", "type_id", "author", "deb_url"];
|
|
||||||
const missingFields = requiredFields.filter((field) => !submitData[field as keyof typeof submitData]);
|
|
||||||
if (missingFields.length > 0) {
|
|
||||||
logger.error({ missingFields }, "[Submitter] Missing required fields");
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("[Submitter] ============== PREPARING SUBMISSION REQUEST ==============");
|
|
||||||
logger.info({ submitData }, "[Submitter] Final submission data");
|
|
||||||
|
|
||||||
const submitterApiUrl = "https://upload.deepinos.org.cn/api/index/upload_application";
|
|
||||||
logger.info({ submitterApiUrl }, "[Submitter] Submission API URL");
|
|
||||||
|
|
||||||
logger.info("[Submitter] ============== SENDING SUBMISSION REQUEST ==============");
|
|
||||||
logger.info({ submitterApiUrl, timestamp: new Date().toISOString() }, "[Submitter] Submission request sent to API");
|
|
||||||
|
|
||||||
const response = await fetch(submitterApiUrl, {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"User-Agent": getUserAgent(),
|
|
||||||
},
|
|
||||||
body: JSON.stringify(submitData),
|
|
||||||
});
|
|
||||||
|
|
||||||
const requestDuration = Date.now() - startTime;
|
|
||||||
logger.info("[Submitter] ============== SUBMISSION RESPONSE RECEIVED ==============");
|
|
||||||
logger.info({ status: response.status, statusText: response.statusText }, "[Submitter] Submission response status");
|
|
||||||
logger.info({ duration: requestDuration }, "[Submitter] Total submission duration (ms)");
|
|
||||||
|
|
||||||
const responseText = await response.text();
|
|
||||||
logger.info({ responseTextLength: responseText.length }, "[Submitter] Submission response text length");
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
logger.error("[Submitter] ============== SUBMISSION FAILED ==============");
|
|
||||||
logger.error({ status: response.status, statusText: response.statusText }, "[Submitter] Submission failed with status");
|
|
||||||
logger.error({ responseText: responseText.substring(0, 2000) }, "[Submitter] Submission API error response (full)");
|
|
||||||
|
|
||||||
let message = "提交失败";
|
|
||||||
let apiResponse: unknown = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
apiResponse = JSON.parse(responseText);
|
|
||||||
logger.error({ apiResponse }, "[Submitter] Parsed API error response");
|
|
||||||
} catch (parseError) {
|
|
||||||
logger.warn({ parseError: (parseError as Error)?.message }, "[Submitter] Failed to parse error response as JSON");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.status === 521) {
|
|
||||||
message = "服务器暂时不可用,请稍后重试";
|
|
||||||
} else if (response.status === 400) {
|
|
||||||
if (typeof apiResponse === "object" && apiResponse !== null) {
|
|
||||||
const errorObj = apiResponse as Record<string, unknown>;
|
|
||||||
message = String(errorObj.msg || errorObj.message || "请求参数错误");
|
|
||||||
} else {
|
|
||||||
message = responseText.substring(0, 200) || "请求参数错误";
|
|
||||||
}
|
|
||||||
} else if (response.status === 401) {
|
|
||||||
message = "未授权,请登录后再试";
|
|
||||||
} else if (response.status === 403) {
|
|
||||||
message = "权限不足";
|
|
||||||
} else if (response.status === 429) {
|
|
||||||
message = "请求过于频繁,请稍后重试";
|
|
||||||
} else {
|
|
||||||
message = `提交失败 [${response.status}]: ${responseText.substring(0, 200)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.error({ finalMessage: message }, "[Submitter] Final error message to user");
|
|
||||||
return { success: false, message, apiResponse };
|
|
||||||
}
|
|
||||||
|
|
||||||
let result: unknown;
|
|
||||||
try {
|
|
||||||
result = JSON.parse(responseText);
|
|
||||||
} catch (parseError) {
|
|
||||||
logger.warn({ parseError: (parseError as Error)?.message }, "[Submitter] Failed to parse success response as JSON");
|
|
||||||
result = responseText;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("[Submitter] ============== SUBMISSION SUCCESSFUL ==============");
|
|
||||||
logger.info({ result }, "[Submitter] Submission API response content");
|
|
||||||
logger.info({ duration: requestDuration }, "[Submitter] Total duration (ms)");
|
|
||||||
|
|
||||||
return { success: true, data: result };
|
|
||||||
} catch (err) {
|
|
||||||
logger.error("[Submitter] ============== EXCEPTION CAUGHT ==============");
|
|
||||||
logger.error({ errorType: (err as Error)?.name }, "[Submitter] Error type");
|
|
||||||
logger.error({ errorMessage: (err as Error)?.message }, "[Submitter] Error message");
|
|
||||||
logger.error({ errorStack: (err as Error)?.stack }, "[Submitter] Error stack");
|
|
||||||
|
|
||||||
return { success: false, message: (err as Error)?.message || "提交失败" };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Register custom protocol handlers
|
// Register custom protocol handlers
|
||||||
if (process.defaultApp) {
|
if (process.defaultApp) {
|
||||||
if (process.argv.length >= 2) {
|
if (process.argv.length >= 2) {
|
||||||
|
|||||||
+2
-2
@@ -57,7 +57,7 @@
|
|||||||
"@vue/test-utils": "^2.4.3",
|
"@vue/test-utils": "^2.4.3",
|
||||||
"conventional-changelog": "^7.1.1",
|
"conventional-changelog": "^7.1.1",
|
||||||
"conventional-changelog-angular": "^8.1.0",
|
"conventional-changelog-angular": "^8.1.0",
|
||||||
"electron": "^39.2.7",
|
"electron": "^28.2.1",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^9.39.2",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-prettier": "^5.5.5",
|
"eslint-plugin-prettier": "^5.5.5",
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tailwindcss/vite": "^4.1.18",
|
"@tailwindcss/vite": "^4.1.18",
|
||||||
"axios": "^1.13.2",
|
"axios": "^1.13.2",
|
||||||
"pino": "^10.3.0",
|
"pino": "^9.14.0",
|
||||||
"tailwindcss": "^4.1.18",
|
"tailwindcss": "^4.1.18",
|
||||||
"vue-virtual-scroller": "^2.0.0-beta.8"
|
"vue-virtual-scroller": "^2.0.0-beta.8"
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -2,11 +2,11 @@
|
|||||||
<SubmitterWindow v-if="isSubmitterView" />
|
<SubmitterWindow v-if="isSubmitterView" />
|
||||||
<div
|
<div
|
||||||
v-else
|
v-else
|
||||||
class="flex min-h-screen flex-col bg-slate-50 text-slate-900 transition-colors duration-300 dark:bg-slate-950 dark:text-slate-100"
|
class="flex h-screen flex-col overflow-hidden bg-slate-50 text-slate-900 transition-colors duration-300 dark:bg-slate-950 dark:text-slate-100"
|
||||||
>
|
>
|
||||||
<WindowTitleBar />
|
<WindowTitleBar />
|
||||||
|
|
||||||
<div class="flex flex-1 flex-col lg:flex-row">
|
<div class="flex min-h-0 flex-1 flex-col lg:flex-row">
|
||||||
<!-- 移动端侧边栏遮罩 -->
|
<!-- 移动端侧边栏遮罩 -->
|
||||||
<div
|
<div
|
||||||
v-if="isSidebarOpen"
|
v-if="isSidebarOpen"
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
/>
|
/>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<main class="flex-1">
|
<main class="h-full min-h-0 flex-1">
|
||||||
<div
|
<div
|
||||||
class="sticky top-10 z-30 border-b border-slate-200/70 bg-slate-50/95 px-4 py-4 backdrop-blur lg:px-10 dark:border-slate-800/70 dark:bg-slate-950/95"
|
class="sticky top-10 z-30 border-b border-slate-200/70 bg-slate-50/95 px-4 py-4 backdrop-blur lg:px-10 dark:border-slate-800/70 dark:bg-slate-950/95"
|
||||||
>
|
>
|
||||||
@@ -86,6 +86,7 @@
|
|||||||
@open-detail="openDetail"
|
@open-detail="openDetail"
|
||||||
/>
|
/>
|
||||||
<template v-else-if="activeTab === 'home'">
|
<template v-else-if="activeTab === 'home'">
|
||||||
|
<div class="max-h-[calc(100vh-8rem)] overflow-y-auto pr-2 scrollbar-nowidth">
|
||||||
<HomeView
|
<HomeView
|
||||||
:links="homeLinks"
|
:links="homeLinks"
|
||||||
:lists="homeLists"
|
:lists="homeLists"
|
||||||
@@ -94,6 +95,7 @@
|
|||||||
:store-filter="storeFilter"
|
:store-filter="storeFilter"
|
||||||
@open-detail="openDetail"
|
@open-detail="openDetail"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<AppGrid
|
<AppGrid
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
background-color: var(--color-surface-light);
|
background-color: var(--color-surface-light);
|
||||||
color: #0f172a;
|
color: #0f172a;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root.dark body {
|
:root.dark body {
|
||||||
|
|||||||
+460
-118
@@ -88,7 +88,20 @@
|
|||||||
<input
|
<input
|
||||||
v-model="formData.contributor"
|
v-model="formData.contributor"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="你的名字或邮箱"
|
placeholder="你的名字"
|
||||||
|
class="w-full px-4 py-2.5 rounded-lg border border-slate-200 bg-white dark:bg-slate-800 dark:border-slate-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label
|
||||||
|
class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2"
|
||||||
|
>联系邮箱</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-model="formData.mail"
|
||||||
|
type="email"
|
||||||
|
placeholder="your@email.com"
|
||||||
class="w-full px-4 py-2.5 rounded-lg border border-slate-200 bg-white dark:bg-slate-800 dark:border-slate-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
class="w-full px-4 py-2.5 rounded-lg border border-slate-200 bg-white dark:bg-slate-800 dark:border-slate-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -136,9 +149,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<i class="fas fa-cloud-upload text-4xl text-slate-400 mb-4"></i>
|
<i class="fas fa-cloud-upload text-4xl text-slate-400 mb-4"></i>
|
||||||
<p class="text-slate-600 dark:text-slate-400">
|
<p class="text-slate-600 dark:text-slate-400">点击浏览</p>
|
||||||
点击浏览
|
|
||||||
</p>
|
|
||||||
<p v-if="formData.debFilePath" class="mt-2 text-sm text-blue-500">
|
<p v-if="formData.debFilePath" class="mt-2 text-sm text-blue-500">
|
||||||
{{ formData.debFilePath.split("/").pop() }}
|
{{ formData.debFilePath.split("/").pop() }}
|
||||||
</p>
|
</p>
|
||||||
@@ -273,6 +284,19 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label
|
||||||
|
class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2"
|
||||||
|
>测试情况</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-model="formData.remark"
|
||||||
|
type="text"
|
||||||
|
placeholder="写明在何种平台的测试情况"
|
||||||
|
class="w-full px-4 py-2.5 rounded-lg border border-slate-200 bg-white dark:bg-slate-800 dark:border-slate-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label
|
<label
|
||||||
class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2"
|
class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2"
|
||||||
@@ -282,23 +306,45 @@
|
|||||||
v-model="formData.category"
|
v-model="formData.category"
|
||||||
class="w-full px-4 py-2.5 rounded-lg border border-slate-200 bg-white dark:bg-slate-800 dark:border-slate-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
class="w-full px-4 py-2.5 rounded-lg border border-slate-200 bg-white dark:bg-slate-800 dark:border-slate-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||||
>
|
>
|
||||||
<option v-for="category in categoriesList" :key="category.id" :value="category.name">
|
<option
|
||||||
|
v-for="category in categoriesList"
|
||||||
|
:key="category.id"
|
||||||
|
:value="category.name"
|
||||||
|
>
|
||||||
{{ category.name }}
|
{{ category.name }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex gap-4 pt-4">
|
<div class="flex gap-3 pt-4">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="flex-1 px-6 py-3 rounded-lg border border-slate-200 bg-white text-slate-700 font-medium hover:bg-slate-50 dark:bg-slate-800 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700 transition-colors"
|
class="px-5 py-3 rounded-lg border border-slate-200 bg-white text-slate-700 font-medium hover:bg-slate-50 dark:bg-slate-800 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700 transition-colors"
|
||||||
@click="resetForm"
|
@click="resetForm"
|
||||||
>
|
>
|
||||||
重置
|
重置
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="flex-1 px-6 py-3 rounded-lg bg-blue-500 text-white font-medium hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
class="flex-1 px-5 py-3 rounded-lg border-2 border-emerald-500 bg-emerald-50 text-emerald-700 font-medium hover:bg-emerald-100 disabled:opacity-50 disabled:cursor-not-allowed transition-colors dark:bg-emerald-900/20 dark:border-emerald-600 dark:text-emerald-400 dark:hover:bg-emerald-900/30"
|
||||||
|
:disabled="isPackaging || !isFormValid"
|
||||||
|
@click="showArchPackDialog = true"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
v-if="isPackaging"
|
||||||
|
class="flex items-center justify-center gap-2"
|
||||||
|
>
|
||||||
|
<i class="fas fa-spinner fa-spin"></i>
|
||||||
|
打包中...
|
||||||
|
</span>
|
||||||
|
<span v-else class="flex items-center justify-center gap-2">
|
||||||
|
<i class="fas fa-box-archive"></i>
|
||||||
|
打包 tar.gz
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="flex-1 px-5 py-3 rounded-lg bg-blue-500 text-white font-medium hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||||
:disabled="isSubmitting || !isFormValid"
|
:disabled="isSubmitting || !isFormValid"
|
||||||
@click="submitForm"
|
@click="submitForm"
|
||||||
>
|
>
|
||||||
@@ -309,7 +355,10 @@
|
|||||||
<i class="fas fa-spinner fa-spin"></i>
|
<i class="fas fa-spinner fa-spin"></i>
|
||||||
提交中...
|
提交中...
|
||||||
</span>
|
</span>
|
||||||
<span v-else>提交投稿</span>
|
<span v-else class="flex items-center justify-center gap-2">
|
||||||
|
<i class="fas fa-paper-plane"></i>
|
||||||
|
提交投稿
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -334,9 +383,95 @@
|
|||||||
<span>{{ submitError }}</span>
|
<span>{{ submitError }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="packageSuccess"
|
||||||
|
class="p-4 bg-emerald-50 border border-emerald-200 rounded-lg dark:bg-emerald-900/20 dark:border-emerald-800"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex items-center gap-2 text-emerald-700 dark:text-emerald-400"
|
||||||
|
>
|
||||||
|
<i class="fas fa-check-circle"></i>
|
||||||
|
<span
|
||||||
|
>打包完成!文件已保存到: {{ packageResult?.tarFileName }}</span
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="packageError"
|
||||||
|
class="p-4 bg-red-50 border border-red-200 rounded-lg dark:bg-red-900/20 dark:border-red-800"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2 text-red-700 dark:text-red-400">
|
||||||
|
<i class="fas fa-exclamation-circle"></i>
|
||||||
|
<span>{{ packageError }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Teleport to="body">
|
||||||
|
<div
|
||||||
|
v-if="showArchPackDialog"
|
||||||
|
data-submitter-arch-pack-dialog
|
||||||
|
class="fixed inset-0 z-50 flex items-center justify-center p-4"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="absolute inset-0 bg-black/50"
|
||||||
|
@click="showArchPackDialog = false"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
class="relative bg-white dark:bg-slate-900 rounded-xl shadow-2xl w-full max-w-md p-6"
|
||||||
|
>
|
||||||
|
<div class="flex items-center justify-between mb-6">
|
||||||
|
<h2
|
||||||
|
class="text-lg font-semibold text-slate-900 dark:text-slate-100"
|
||||||
|
>
|
||||||
|
选择打包架构
|
||||||
|
</h2>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="text-slate-400 hover:text-slate-600 dark:hover:text-slate-300"
|
||||||
|
@click="showArchPackDialog = false"
|
||||||
|
>
|
||||||
|
<i class="fas fa-times"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="text-slate-600 dark:text-slate-400 mb-4">
|
||||||
|
请选择目标架构以生成对应的 tar.gz 包:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="space-y-3 mb-6">
|
||||||
|
<button
|
||||||
|
v-for="arch in packArchOptions"
|
||||||
|
:key="arch.store"
|
||||||
|
type="button"
|
||||||
|
class="w-full p-4 rounded-lg border-2 border-slate-200 dark:border-slate-700 hover:border-emerald-500 transition-colors text-left"
|
||||||
|
@click="selectPackArch(arch)"
|
||||||
|
>
|
||||||
|
<div class="font-medium text-slate-900 dark:text-slate-100">
|
||||||
|
{{ getArchDisplayName(arch.store) }}
|
||||||
|
</div>
|
||||||
|
<div class="text-sm text-slate-500 dark:text-slate-400 mt-1">
|
||||||
|
输出: {{ formData.pkgname }}-{{ arch.store }}.tar.gz
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex gap-3">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="flex-1 px-4 py-2 rounded-lg border border-slate-200 bg-white text-slate-700 dark:bg-slate-800 dark:border-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-700"
|
||||||
|
@click="showArchPackDialog = false"
|
||||||
|
>
|
||||||
|
取消
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<div
|
<div
|
||||||
v-if="showArchDialog"
|
v-if="showArchDialog"
|
||||||
@@ -430,6 +565,7 @@ const formData = reactive({
|
|||||||
version: "",
|
version: "",
|
||||||
author: "",
|
author: "",
|
||||||
contributor: "",
|
contributor: "",
|
||||||
|
mail: "",
|
||||||
website: "",
|
website: "",
|
||||||
debFilePath: "",
|
debFilePath: "",
|
||||||
iconPath: "",
|
iconPath: "",
|
||||||
@@ -437,6 +573,7 @@ const formData = reactive({
|
|||||||
description: "",
|
description: "",
|
||||||
tags: "",
|
tags: "",
|
||||||
category: "",
|
category: "",
|
||||||
|
remark: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
const isSubmitting = ref(false);
|
const isSubmitting = ref(false);
|
||||||
@@ -449,6 +586,22 @@ const availableArchs = ref<HistoryArchInfo[]>([]);
|
|||||||
const currentDebArch = ref("");
|
const currentDebArch = ref("");
|
||||||
const iconPreview = ref("");
|
const iconPreview = ref("");
|
||||||
|
|
||||||
|
const isPackaging = ref(false);
|
||||||
|
const packageSuccess = ref(false);
|
||||||
|
const packageError = ref("");
|
||||||
|
const showArchPackDialog = ref(false);
|
||||||
|
const packageResult = ref<{
|
||||||
|
tarPath: string;
|
||||||
|
tempDir: string;
|
||||||
|
tarFileName: string;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
|
const packArchOptions = [
|
||||||
|
{ store: "store", label: "AMD64 (x86_64)" },
|
||||||
|
{ store: "aarch64-store", label: "ARM64 (aarch64)" },
|
||||||
|
{ store: "loong64-store", label: "LoongArch64" },
|
||||||
|
];
|
||||||
|
|
||||||
interface Category {
|
interface Category {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -483,7 +636,9 @@ const getArchDisplayName = (store: string): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loadCategoriesList = async () => {
|
const loadCategoriesList = async () => {
|
||||||
console.log("[Submitter] ============== LOAD CATEGORIES START ==============");
|
console.log(
|
||||||
|
"[Submitter] ============== LOAD CATEGORIES START ==============",
|
||||||
|
);
|
||||||
console.log("[Submitter] Calling IPC: get-category-list");
|
console.log("[Submitter] Calling IPC: get-category-list");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -491,7 +646,9 @@ const loadCategoriesList = async () => {
|
|||||||
const result = await window.ipcRenderer.invoke("get-category-list");
|
const result = await window.ipcRenderer.invoke("get-category-list");
|
||||||
const endTime = Date.now();
|
const endTime = Date.now();
|
||||||
|
|
||||||
console.log("[Submitter] ============== IPC RESPONSE RECEIVED ==============");
|
console.log(
|
||||||
|
"[Submitter] ============== IPC RESPONSE RECEIVED ==============",
|
||||||
|
);
|
||||||
console.log("[Submitter] Request duration:", endTime - startTime, "ms");
|
console.log("[Submitter] Request duration:", endTime - startTime, "ms");
|
||||||
console.log("[Submitter] Result success:", result?.success);
|
console.log("[Submitter] Result success:", result?.success);
|
||||||
console.log("[Submitter] Result message:", result?.message);
|
console.log("[Submitter] Result message:", result?.message);
|
||||||
@@ -499,31 +656,55 @@ const loadCategoriesList = async () => {
|
|||||||
|
|
||||||
if (result?.success && result.data) {
|
if (result?.success && result.data) {
|
||||||
const data = result.data;
|
const data = result.data;
|
||||||
console.log("[Submitter] ============== PROCESSING RESPONSE ==============");
|
console.log(
|
||||||
|
"[Submitter] ============== PROCESSING RESPONSE ==============",
|
||||||
|
);
|
||||||
console.log("[Submitter] Response code:", data.code);
|
console.log("[Submitter] Response code:", data.code);
|
||||||
console.log("[Submitter] Response message:", data.msg);
|
console.log("[Submitter] Response message:", data.msg);
|
||||||
console.log("[Submitter] Data type:", typeof data.data);
|
console.log("[Submitter] Data type:", typeof data.data);
|
||||||
console.log("[Submitter] Data length:", data.data?.length);
|
console.log("[Submitter] Data length:", data.data?.length);
|
||||||
console.log("[Submitter] Raw data:", JSON.stringify(data.data, null, 2));
|
console.log("[Submitter] Raw data:", JSON.stringify(data.data, null, 2));
|
||||||
|
|
||||||
if (data.code === 200 && data.data) {
|
if (data.code === 0 && data.data) {
|
||||||
categoriesList.value = data.data.map((item: { id: number; name: string; value: string }, index: number) => ({
|
categoriesList.value = data.data.map(
|
||||||
|
(
|
||||||
|
item: { id: number; name: string; value: string },
|
||||||
|
index: number,
|
||||||
|
) => ({
|
||||||
id: typeof item.id === "number" ? item.id : index + 1,
|
id: typeof item.id === "number" ? item.id : index + 1,
|
||||||
name: item.name || item.value || "",
|
name: item.name || item.value || "",
|
||||||
}));
|
}),
|
||||||
console.log("[Submitter] ============== CATEGORIES LOADED ==============");
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] ============== CATEGORIES LOADED ==============",
|
||||||
|
);
|
||||||
console.log("[Submitter] Categories list:", categoriesList.value);
|
console.log("[Submitter] Categories list:", categoriesList.value);
|
||||||
console.log("[Submitter] Categories count:", categoriesList.value.length);
|
console.log(
|
||||||
} else if (data.code === 200 && Array.isArray(data)) {
|
"[Submitter] Categories count:",
|
||||||
categoriesList.value = data.map((item: { id: number; name: string; value: string }, index: number) => ({
|
categoriesList.value.length,
|
||||||
|
);
|
||||||
|
} else if (data.code === 0 && Array.isArray(data)) {
|
||||||
|
categoriesList.value = data.map(
|
||||||
|
(
|
||||||
|
item: { id: number; name: string; value: string },
|
||||||
|
index: number,
|
||||||
|
) => ({
|
||||||
id: typeof item.id === "number" ? item.id : index + 1,
|
id: typeof item.id === "number" ? item.id : index + 1,
|
||||||
name: item.name || item.value || "",
|
name: item.name || item.value || "",
|
||||||
}));
|
}),
|
||||||
console.log("[Submitter] ============== CATEGORIES LOADED (direct array) ==============");
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] ============== CATEGORIES LOADED (direct array) ==============",
|
||||||
|
);
|
||||||
console.log("[Submitter] Categories list:", categoriesList.value);
|
console.log("[Submitter] Categories list:", categoriesList.value);
|
||||||
console.log("[Submitter] Categories count:", categoriesList.value.length);
|
console.log(
|
||||||
|
"[Submitter] Categories count:",
|
||||||
|
categoriesList.value.length,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
console.error("[Submitter] ============== INVALID RESPONSE CODE ==============");
|
console.error(
|
||||||
|
"[Submitter] ============== INVALID RESPONSE CODE ==============",
|
||||||
|
);
|
||||||
console.error("[Submitter] Expected code 200, got:", data.code);
|
console.error("[Submitter] Expected code 200, got:", data.code);
|
||||||
console.error("[Submitter] Response message:", data.msg);
|
console.error("[Submitter] Response message:", data.msg);
|
||||||
categoriesList.value = [
|
categoriesList.value = [
|
||||||
@@ -540,11 +721,15 @@ const loadCategoriesList = async () => {
|
|||||||
{ id: 11, name: "tools" },
|
{ id: 11, name: "tools" },
|
||||||
{ id: 12, name: "video" },
|
{ id: 12, name: "video" },
|
||||||
];
|
];
|
||||||
console.log("[Submitter] ============== USING FALLBACK CATEGORIES ==============");
|
console.log(
|
||||||
|
"[Submitter] ============== USING FALLBACK CATEGORIES ==============",
|
||||||
|
);
|
||||||
console.log("[Submitter] Categories list:", categoriesList.value);
|
console.log("[Submitter] Categories list:", categoriesList.value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("[Submitter] ============== IPC CALL FAILED ==============");
|
console.error(
|
||||||
|
"[Submitter] ============== IPC CALL FAILED ==============",
|
||||||
|
);
|
||||||
console.error("[Submitter] Success:", result?.success);
|
console.error("[Submitter] Success:", result?.success);
|
||||||
console.error("[Submitter] Message:", result?.message);
|
console.error("[Submitter] Message:", result?.message);
|
||||||
console.error("[Submitter] Data:", result?.data);
|
console.error("[Submitter] Data:", result?.data);
|
||||||
@@ -562,7 +747,9 @@ const loadCategoriesList = async () => {
|
|||||||
{ id: 11, name: "tools" },
|
{ id: 11, name: "tools" },
|
||||||
{ id: 12, name: "video" },
|
{ id: 12, name: "video" },
|
||||||
];
|
];
|
||||||
console.log("[Submitter] ============== USING FALLBACK CATEGORIES ==============");
|
console.log(
|
||||||
|
"[Submitter] ============== USING FALLBACK CATEGORIES ==============",
|
||||||
|
);
|
||||||
console.log("[Submitter] Categories list:", categoriesList.value);
|
console.log("[Submitter] Categories list:", categoriesList.value);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -584,7 +771,9 @@ const loadCategoriesList = async () => {
|
|||||||
{ id: 11, name: "tools" },
|
{ id: 11, name: "tools" },
|
||||||
{ id: 12, name: "video" },
|
{ id: 12, name: "video" },
|
||||||
];
|
];
|
||||||
console.log("[Submitter] ============== USING FALLBACK CATEGORIES ==============");
|
console.log(
|
||||||
|
"[Submitter] ============== USING FALLBACK CATEGORIES ==============",
|
||||||
|
);
|
||||||
console.log("[Submitter] Categories list:", categoriesList.value);
|
console.log("[Submitter] Categories list:", categoriesList.value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -598,7 +787,9 @@ const loadTagsList = async () => {
|
|||||||
const result = await window.ipcRenderer.invoke("get-tags-list");
|
const result = await window.ipcRenderer.invoke("get-tags-list");
|
||||||
const endTime = Date.now();
|
const endTime = Date.now();
|
||||||
|
|
||||||
console.log("[Submitter] ============== IPC RESPONSE RECEIVED ==============");
|
console.log(
|
||||||
|
"[Submitter] ============== IPC RESPONSE RECEIVED ==============",
|
||||||
|
);
|
||||||
console.log("[Submitter] Request duration:", endTime - startTime, "ms");
|
console.log("[Submitter] Request duration:", endTime - startTime, "ms");
|
||||||
console.log("[Submitter] Result success:", result?.success);
|
console.log("[Submitter] Result success:", result?.success);
|
||||||
console.log("[Submitter] Result message:", result?.message);
|
console.log("[Submitter] Result message:", result?.message);
|
||||||
@@ -606,28 +797,36 @@ const loadTagsList = async () => {
|
|||||||
|
|
||||||
if (result?.success && result.data) {
|
if (result?.success && result.data) {
|
||||||
const data = result.data;
|
const data = result.data;
|
||||||
console.log("[Submitter] ============== PROCESSING RESPONSE ==============");
|
console.log(
|
||||||
|
"[Submitter] ============== PROCESSING RESPONSE ==============",
|
||||||
|
);
|
||||||
console.log("[Submitter] Response code:", data.code);
|
console.log("[Submitter] Response code:", data.code);
|
||||||
console.log("[Submitter] Response message:", data.msg);
|
console.log("[Submitter] Response message:", data.msg);
|
||||||
console.log("[Submitter] Data type:", typeof data.data);
|
console.log("[Submitter] Data type:", typeof data.data);
|
||||||
console.log("[Submitter] Data length:", data.data?.length);
|
console.log("[Submitter] Data length:", data.data?.length);
|
||||||
console.log("[Submitter] Raw data:", JSON.stringify(data.data, null, 2));
|
console.log("[Submitter] Raw data:", JSON.stringify(data.data, null, 2));
|
||||||
|
|
||||||
if (data.code === 200 && data.data) {
|
if (data.code === 0 && data.data) {
|
||||||
tagsList.value = data.data.map((item: { name: string; value: string }) => ({
|
tagsList.value = data.data.map(
|
||||||
|
(item: { name: string; value: string }) => ({
|
||||||
name: item.name,
|
name: item.name,
|
||||||
value: item.value,
|
value: item.value,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
console.log("[Submitter] ============== TAGS LOADED ==============");
|
console.log("[Submitter] ============== TAGS LOADED ==============");
|
||||||
console.log("[Submitter] Tags list:", tagsList.value);
|
console.log("[Submitter] Tags list:", tagsList.value);
|
||||||
console.log("[Submitter] Tags count:", tagsList.value.length);
|
console.log("[Submitter] Tags count:", tagsList.value.length);
|
||||||
} else {
|
} else {
|
||||||
console.error("[Submitter] ============== INVALID RESPONSE CODE ==============");
|
console.error(
|
||||||
console.error("[Submitter] Expected code 200, got:", data.code);
|
"[Submitter] ============== INVALID RESPONSE CODE ==============",
|
||||||
|
);
|
||||||
|
console.error("[Submitter] Expected code 0, got:", data.code);
|
||||||
console.error("[Submitter] Response message:", data.msg);
|
console.error("[Submitter] Response message:", data.msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("[Submitter] ============== IPC CALL FAILED ==============");
|
console.error(
|
||||||
|
"[Submitter] ============== IPC CALL FAILED ==============",
|
||||||
|
);
|
||||||
console.error("[Submitter] Success:", result?.success);
|
console.error("[Submitter] Success:", result?.success);
|
||||||
console.error("[Submitter] Message:", result?.message);
|
console.error("[Submitter] Message:", result?.message);
|
||||||
console.error("[Submitter] Data:", result?.data);
|
console.error("[Submitter] Data:", result?.data);
|
||||||
@@ -671,13 +870,136 @@ const selectDebFile = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const useMirror = ref(false);
|
const useMirror = ref(true);
|
||||||
|
|
||||||
const selectMirrorSource = () => {
|
const searchHistoryApp = async () => {
|
||||||
const useMirrorSource = window.confirm(
|
console.log(
|
||||||
"是否使用镜像源搜索历史信息?\n\n镜像源:mirrors.sdu.edu.cn\n主站:spk-json.spark-app.store\n\n建议在中国内地使用镜像源以获得更好的网络体验。",
|
"[Submitter] ============== SEARCHING HISTORY INFO ==============",
|
||||||
);
|
);
|
||||||
useMirror.value = useMirrorSource;
|
console.log(
|
||||||
|
"[Submitter] pkgname is not empty, searching history with:",
|
||||||
|
formData.pkgname,
|
||||||
|
);
|
||||||
|
console.log("[Submitter] Using mirror:", useMirror.value);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"[Submitter] Calling IPC: search-history-app with pkgname:",
|
||||||
|
formData.pkgname,
|
||||||
|
);
|
||||||
|
const historyResult = await window.ipcRenderer.invoke(
|
||||||
|
"search-history-app",
|
||||||
|
formData.pkgname,
|
||||||
|
useMirror.value,
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] Received history search response:",
|
||||||
|
JSON.stringify(historyResult, null, 2),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
historyResult?.success &&
|
||||||
|
historyResult.data &&
|
||||||
|
historyResult.data.length > 0
|
||||||
|
) {
|
||||||
|
console.log(
|
||||||
|
"[Submitter] ============== HISTORY INFO FOUND ==============",
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] History info count:",
|
||||||
|
historyResult.data.length,
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] Available archs data:",
|
||||||
|
JSON.stringify(historyResult.data, null, 2),
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"[Submitter] ============== BEFORE SETTING STATE ==============",
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] availableArchs before:",
|
||||||
|
availableArchs.value,
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] showArchDialog before:",
|
||||||
|
showArchDialog.value,
|
||||||
|
);
|
||||||
|
|
||||||
|
availableArchs.value = historyResult.data;
|
||||||
|
console.log(
|
||||||
|
"[Submitter] availableArchs after:",
|
||||||
|
availableArchs.value,
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] availableArchs length:",
|
||||||
|
availableArchs.value.length,
|
||||||
|
);
|
||||||
|
|
||||||
|
showArchDialog.value = true;
|
||||||
|
console.log(
|
||||||
|
"[Submitter] showArchDialog after:",
|
||||||
|
showArchDialog.value,
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"[Submitter] ============== DIALOG SHOULD BE SHOWING ==============",
|
||||||
|
);
|
||||||
|
console.log("[Submitter] Dialog visibility:", showArchDialog.value);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] Available architectures to display:",
|
||||||
|
availableArchs.value.map((a) => a.store),
|
||||||
|
);
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
console.log(
|
||||||
|
"[Submitter] ============== AFTER NEXT TICK ==============",
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] showArchDialog in nextTick:",
|
||||||
|
showArchDialog.value,
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] availableArchs in nextTick:",
|
||||||
|
availableArchs.value,
|
||||||
|
);
|
||||||
|
|
||||||
|
const dialogElement = document.querySelector(
|
||||||
|
"[data-submitter-arch-dialog]",
|
||||||
|
);
|
||||||
|
console.log("[Submitter] Dialog element found:", !!dialogElement);
|
||||||
|
if (dialogElement) {
|
||||||
|
console.log("[Submitter] Dialog element:", dialogElement);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] Dialog element style:",
|
||||||
|
window.getComputedStyle(dialogElement),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
"[Submitter] ============== NO HISTORY INFO FOUND ==============",
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] historyResult.success:",
|
||||||
|
historyResult?.success,
|
||||||
|
);
|
||||||
|
console.log("[Submitter] historyResult.data:", historyResult?.data);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] historyResult.data.length:",
|
||||||
|
historyResult?.data?.length,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (historyResult?.success === true && historyResult.data) {
|
||||||
|
console.log("[Submitter] Success is true but no data found");
|
||||||
|
console.log("[Submitter] Data is:", historyResult.data);
|
||||||
|
console.log("[Submitter] Data type:", typeof historyResult.data);
|
||||||
|
} else if (!historyResult?.success) {
|
||||||
|
console.log(
|
||||||
|
"[Submitter] Search failed with message:",
|
||||||
|
historyResult?.message,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const parseDebFileAndSearchHistory = async (debPath: string) => {
|
const parseDebFileAndSearchHistory = async (debPath: string) => {
|
||||||
@@ -685,7 +1007,9 @@ const parseDebFileAndSearchHistory = async (debPath: string) => {
|
|||||||
debParseError.value = "";
|
debParseError.value = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log("[Submitter] ============== STARTING DEB FILE PARSING ==============");
|
console.log(
|
||||||
|
"[Submitter] ============== STARTING DEB FILE PARSING ==============",
|
||||||
|
);
|
||||||
console.log("[Submitter] Input debPath:", debPath);
|
console.log("[Submitter] Input debPath:", debPath);
|
||||||
console.log("[Submitter] debPath type:", typeof debPath);
|
console.log("[Submitter] debPath type:", typeof debPath);
|
||||||
console.log("[Submitter] debPath length:", debPath.length);
|
console.log("[Submitter] debPath length:", debPath.length);
|
||||||
@@ -695,11 +1019,17 @@ const parseDebFileAndSearchHistory = async (debPath: string) => {
|
|||||||
"parse-deb-file",
|
"parse-deb-file",
|
||||||
debPath,
|
debPath,
|
||||||
);
|
);
|
||||||
console.log("[Submitter] Received IPC response:", JSON.stringify(parseResult, null, 2));
|
console.log(
|
||||||
|
"[Submitter] Received IPC response:",
|
||||||
|
JSON.stringify(parseResult, null, 2),
|
||||||
|
);
|
||||||
|
|
||||||
if (parseResult?.success && parseResult.data) {
|
if (parseResult?.success && parseResult.data) {
|
||||||
const debInfo = parseResult.data;
|
const debInfo = parseResult.data;
|
||||||
console.log("[Submitter] Parsed debInfo successfully:", JSON.stringify(debInfo, null, 2));
|
console.log(
|
||||||
|
"[Submitter] Parsed debInfo successfully:",
|
||||||
|
JSON.stringify(debInfo, null, 2),
|
||||||
|
);
|
||||||
|
|
||||||
console.log("[Submitter] Setting form data from debInfo:");
|
console.log("[Submitter] Setting form data from debInfo:");
|
||||||
console.log("[Submitter] pkgname:", debInfo.pkgname);
|
console.log("[Submitter] pkgname:", debInfo.pkgname);
|
||||||
@@ -718,76 +1048,13 @@ const parseDebFileAndSearchHistory = async (debPath: string) => {
|
|||||||
formData.description = debInfo.description || "";
|
formData.description = debInfo.description || "";
|
||||||
currentDebArch.value = debInfo.architecture || "";
|
currentDebArch.value = debInfo.architecture || "";
|
||||||
|
|
||||||
console.log("[Submitter] Form data after setting:", JSON.stringify(formData, null, 2));
|
console.log(
|
||||||
|
"[Submitter] Form data after setting:",
|
||||||
selectMirrorSource();
|
JSON.stringify(formData, null, 2),
|
||||||
console.log("[Submitter] Mirror source selected:", useMirror.value);
|
);
|
||||||
|
|
||||||
if (formData.pkgname) {
|
if (formData.pkgname) {
|
||||||
console.log("[Submitter] ============== SEARCHING HISTORY INFO ==============");
|
await searchHistoryApp();
|
||||||
console.log("[Submitter] pkgname is not empty, searching history with:", formData.pkgname);
|
|
||||||
console.log("[Submitter] Using mirror:", useMirror.value);
|
|
||||||
|
|
||||||
console.log("[Submitter] Calling IPC: search-history-app with pkgname:", formData.pkgname);
|
|
||||||
const historyResult = await window.ipcRenderer.invoke(
|
|
||||||
"search-history-app",
|
|
||||||
formData.pkgname,
|
|
||||||
useMirror.value,
|
|
||||||
);
|
|
||||||
console.log("[Submitter] Received history search response:", JSON.stringify(historyResult, null, 2));
|
|
||||||
|
|
||||||
if (
|
|
||||||
historyResult?.success &&
|
|
||||||
historyResult.data &&
|
|
||||||
historyResult.data.length > 0
|
|
||||||
) {
|
|
||||||
console.log("[Submitter] ============== HISTORY INFO FOUND ==============");
|
|
||||||
console.log("[Submitter] History info count:", historyResult.data.length);
|
|
||||||
console.log("[Submitter] Available archs data:", JSON.stringify(historyResult.data, null, 2));
|
|
||||||
|
|
||||||
console.log("[Submitter] ============== BEFORE SETTING STATE ==============");
|
|
||||||
console.log("[Submitter] availableArchs before:", availableArchs.value);
|
|
||||||
console.log("[Submitter] showArchDialog before:", showArchDialog.value);
|
|
||||||
|
|
||||||
availableArchs.value = historyResult.data;
|
|
||||||
console.log("[Submitter] availableArchs after:", availableArchs.value);
|
|
||||||
console.log("[Submitter] availableArchs length:", availableArchs.value.length);
|
|
||||||
|
|
||||||
showArchDialog.value = true;
|
|
||||||
console.log("[Submitter] showArchDialog after:", showArchDialog.value);
|
|
||||||
|
|
||||||
console.log("[Submitter] ============== DIALOG SHOULD BE SHOWING ==============");
|
|
||||||
console.log("[Submitter] Dialog visibility:", showArchDialog.value);
|
|
||||||
console.log("[Submitter] Available architectures to display:", availableArchs.value.map((a) => a.store));
|
|
||||||
|
|
||||||
nextTick(() => {
|
|
||||||
console.log("[Submitter] ============== AFTER NEXT TICK ==============");
|
|
||||||
console.log("[Submitter] showArchDialog in nextTick:", showArchDialog.value);
|
|
||||||
console.log("[Submitter] availableArchs in nextTick:", availableArchs.value);
|
|
||||||
|
|
||||||
const dialogElement = document.querySelector('[data-submitter-arch-dialog]');
|
|
||||||
console.log("[Submitter] Dialog element found:", !!dialogElement);
|
|
||||||
if (dialogElement) {
|
|
||||||
console.log("[Submitter] Dialog element:", dialogElement);
|
|
||||||
console.log("[Submitter] Dialog element style:", window.getComputedStyle(dialogElement));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log("[Submitter] ============== NO HISTORY INFO FOUND ==============");
|
|
||||||
console.log("[Submitter] historyResult.success:", historyResult?.success);
|
|
||||||
console.log("[Submitter] historyResult.data:", historyResult?.data);
|
|
||||||
console.log("[Submitter] historyResult.data.length:", historyResult?.data?.length);
|
|
||||||
|
|
||||||
if (historyResult?.success === true && historyResult.data) {
|
|
||||||
console.log("[Submitter] Success is true but no data found");
|
|
||||||
console.log("[Submitter] Data is:", historyResult.data);
|
|
||||||
console.log("[Submitter] Data type:", typeof historyResult.data);
|
|
||||||
} else if (!historyResult?.success) {
|
|
||||||
console.log("[Submitter] Search failed with message:", historyResult?.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log("[Submitter] pkgname is empty, skipping history search");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("[Submitter] Failed to parse deb file");
|
console.error("[Submitter] Failed to parse deb file");
|
||||||
@@ -801,16 +1068,20 @@ const parseDebFileAndSearchHistory = async (debPath: string) => {
|
|||||||
debParseError.value = (error as Error)?.message || "解析deb文件失败";
|
debParseError.value = (error as Error)?.message || "解析deb文件失败";
|
||||||
} finally {
|
} finally {
|
||||||
isParsingDeb.value = false;
|
isParsingDeb.value = false;
|
||||||
console.log("[Submitter] ============== DEB FILE PARSING COMPLETED ==============");
|
console.log(
|
||||||
|
"[Submitter] ============== DEB FILE PARSING COMPLETED ==============",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDebFileSelect = async (_event: Event) => {
|
const handleDebFileSelect = async (_event: Event) => {};
|
||||||
};
|
|
||||||
|
|
||||||
const handleDragOver = (event: DragEvent) => {
|
const handleDragOver = (event: DragEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
console.log("[Submitter] Drag over detected, types available:", event.dataTransfer?.types);
|
console.log(
|
||||||
|
"[Submitter] Drag over detected, types available:",
|
||||||
|
event.dataTransfer?.types,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDragEnter = (event: DragEvent) => {
|
const handleDragEnter = (event: DragEvent) => {
|
||||||
@@ -875,6 +1146,7 @@ const handleDrop = async (event: DragEvent) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const selectArch = (arch: HistoryArchInfo) => {
|
const selectArch = (arch: HistoryArchInfo) => {
|
||||||
|
showArchDialog.value = false;
|
||||||
console.log("[Submitter] selectArch called with:", arch);
|
console.log("[Submitter] selectArch called with:", arch);
|
||||||
|
|
||||||
formData.name = arch.name || formData.name;
|
formData.name = arch.name || formData.name;
|
||||||
@@ -903,7 +1175,10 @@ const selectArch = (arch: HistoryArchInfo) => {
|
|||||||
? `https://mirrors.sdu.edu.cn/spark-store/${arch.store}/${arch.category}/${arch.pkgname}`
|
? `https://mirrors.sdu.edu.cn/spark-store/${arch.store}/${arch.category}/${arch.pkgname}`
|
||||||
: `https://spk-json.spark-app.store/${arch.store}/${arch.category}/${arch.pkgname}`;
|
: `https://spk-json.spark-app.store/${arch.store}/${arch.category}/${arch.pkgname}`;
|
||||||
|
|
||||||
console.log("[Submitter] Building icon and screenshot URLs with baseUrl:", baseUrl);
|
console.log(
|
||||||
|
"[Submitter] Building icon and screenshot URLs with baseUrl:",
|
||||||
|
baseUrl,
|
||||||
|
);
|
||||||
|
|
||||||
if (arch.icon) {
|
if (arch.icon) {
|
||||||
formData.iconPath = `${baseUrl}/icon.png`;
|
formData.iconPath = `${baseUrl}/icon.png`;
|
||||||
@@ -999,6 +1274,7 @@ const resetForm = () => {
|
|||||||
formData.version = "";
|
formData.version = "";
|
||||||
formData.author = "";
|
formData.author = "";
|
||||||
formData.contributor = "";
|
formData.contributor = "";
|
||||||
|
formData.mail = "";
|
||||||
formData.website = "";
|
formData.website = "";
|
||||||
formData.debFilePath = "";
|
formData.debFilePath = "";
|
||||||
formData.iconPath = "";
|
formData.iconPath = "";
|
||||||
@@ -1006,9 +1282,13 @@ const resetForm = () => {
|
|||||||
formData.description = "";
|
formData.description = "";
|
||||||
formData.tags = "";
|
formData.tags = "";
|
||||||
formData.category = "";
|
formData.category = "";
|
||||||
|
formData.remark = "";
|
||||||
submitSuccess.value = false;
|
submitSuccess.value = false;
|
||||||
submitError.value = "";
|
submitError.value = "";
|
||||||
debParseError.value = "";
|
debParseError.value = "";
|
||||||
|
packageSuccess.value = false;
|
||||||
|
packageError.value = "";
|
||||||
|
packageResult.value = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
@@ -1025,6 +1305,7 @@ const submitForm = async () => {
|
|||||||
version: formData.version,
|
version: formData.version,
|
||||||
author: formData.author,
|
author: formData.author,
|
||||||
contributor: formData.contributor,
|
contributor: formData.contributor,
|
||||||
|
mail: formData.mail,
|
||||||
website: formData.website,
|
website: formData.website,
|
||||||
debFilePath: formData.debFilePath,
|
debFilePath: formData.debFilePath,
|
||||||
iconPath: formData.iconPath,
|
iconPath: formData.iconPath,
|
||||||
@@ -1032,11 +1313,18 @@ const submitForm = async () => {
|
|||||||
description: formData.description,
|
description: formData.description,
|
||||||
tags: formData.tags,
|
tags: formData.tags,
|
||||||
category: formData.category,
|
category: formData.category,
|
||||||
|
remark: formData.remark,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("[Submitter] ============== SUBMIT FORM ==============");
|
console.log("[Submitter] ============== SUBMIT FORM ==============");
|
||||||
console.log("[Submitter] Submit data:", JSON.stringify(submitData, null, 2));
|
console.log(
|
||||||
console.log("[Submitter] Screenshots count:", submitData.screenshots.length);
|
"[Submitter] Submit data:",
|
||||||
|
JSON.stringify(submitData, null, 2),
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
"[Submitter] Screenshots count:",
|
||||||
|
submitData.screenshots.length,
|
||||||
|
);
|
||||||
console.log("[Submitter] Icon path:", submitData.iconPath);
|
console.log("[Submitter] Icon path:", submitData.iconPath);
|
||||||
|
|
||||||
const result = await window.ipcRenderer.invoke("submit-app", submitData);
|
const result = await window.ipcRenderer.invoke("submit-app", submitData);
|
||||||
@@ -1054,6 +1342,59 @@ const submitForm = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectPackArch = async (arch: { store: string; label: string }) => {
|
||||||
|
showArchPackDialog.value = false;
|
||||||
|
await packageApp(arch.store);
|
||||||
|
};
|
||||||
|
|
||||||
|
const packageApp = async (storeArch: string) => {
|
||||||
|
if (!isFormValid.value) return;
|
||||||
|
|
||||||
|
isPackaging.value = true;
|
||||||
|
packageSuccess.value = false;
|
||||||
|
packageError.value = "";
|
||||||
|
packageResult.value = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const packageData = {
|
||||||
|
name: formData.name,
|
||||||
|
pkgname: formData.pkgname,
|
||||||
|
version: formData.version,
|
||||||
|
author: formData.author,
|
||||||
|
contributor: formData.contributor,
|
||||||
|
mail: formData.mail,
|
||||||
|
website: formData.website,
|
||||||
|
debFilePath: formData.debFilePath,
|
||||||
|
iconPath: formData.iconPath,
|
||||||
|
screenshots: [...formData.screenshots],
|
||||||
|
description: formData.description,
|
||||||
|
tags: formData.tags,
|
||||||
|
category: formData.category,
|
||||||
|
remark: formData.remark,
|
||||||
|
storeArch,
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("[Submitter] ============== PACKAGE APP ==============");
|
||||||
|
console.log(
|
||||||
|
"[Submitter] Package data:",
|
||||||
|
JSON.stringify(packageData, null, 2),
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = await window.ipcRenderer.invoke("package-app", packageData);
|
||||||
|
|
||||||
|
if (result?.success) {
|
||||||
|
packageSuccess.value = true;
|
||||||
|
packageResult.value = result.data;
|
||||||
|
} else {
|
||||||
|
packageError.value = result?.message || "打包失败";
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
packageError.value = (error as Error)?.message || "打包失败";
|
||||||
|
} finally {
|
||||||
|
isPackaging.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const closeWindow = () => {
|
const closeWindow = () => {
|
||||||
window.ipcRenderer.send("close-submitter-window");
|
window.ipcRenderer.send("close-submitter-window");
|
||||||
};
|
};
|
||||||
@@ -1063,5 +1404,6 @@ import { onMounted, nextTick } from "vue";
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log("[Submitter] Component mounted, loading categories and tags");
|
console.log("[Submitter] Component mounted, loading categories and tags");
|
||||||
loadCategoriesList();
|
loadCategoriesList();
|
||||||
|
loadTagsList();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user