Track bundled vendor runtime sources
Some checks failed
CI / main (push) Has been cancelled
CI / release-e2e (push) Has been cancelled

This commit is contained in:
2026-07-07 10:05:50 +08:00
parent fbe179ab53
commit 52636c91ae
2111 changed files with 1850012 additions and 14 deletions

View File

@@ -0,0 +1,3 @@
export const CommonConfig = {
darkModeEnable: false,
};

View File

@@ -0,0 +1,17 @@
import contextMenu from "electron-context-menu";
const init = () => {
contextMenu({
showSaveImageAs: false,
showCopyLink: false,
showCopyImage: false,
showSelectAll: false,
showInspectElement: false,
showSearchWithGoogle: false,
showLookUpSelection: false,
});
};
export const ConfigContextMenu = {
init,
};

View File

@@ -0,0 +1,10 @@
import { buildResolve, extraResolve } from "../lib/env";
export const logoPath = buildResolve("logo.png");
export const icoLogoPath = buildResolve("logo.ico");
export const icnsLogoPath = buildResolve("logo.icns");
export const trayPath =
process.platform === "darwin"
? extraResolve("osx/tray/iconTemplate.png")
: extraResolve("common/tray/icon.png");

View File

@@ -0,0 +1,66 @@
import enUS from "./../../src/lang/en-US.json";
import zhCN from "./../../src/lang/zh-CN.json";
import { isDev } from "../lib/env";
import { ConfigMain } from "../mapi/config/main";
export const defaultLocale = "zh-CN";
let locale = defaultLocale;
export const langMessageList = [
{
name: "en-US",
label: "English",
messages: enUS,
},
{
name: "zh-CN",
label: "简体中文",
messages: zhCN,
},
];
const buildMessages = (): any => {
let messages = {};
for (let m of langMessageList) {
messages[m.name] = m.messages;
}
return messages;
};
let messages = buildMessages();
export const t = (text: string, param: object | null = null) => {
if (messages[locale]) {
if (messages[locale][text]) {
if (param) {
return messages[locale][text].replace(
/\{(\w+)\}/g,
function (match, key) {
return key in param ? param[key] : match;
},
);
}
return messages[locale][text];
}
}
if (param) {
return text.replace(/\{(\w+)\}/g, function (match, key) {
return key in param ? param[key] : match;
});
}
return text;
};
const readyAsync = async () => {
locale = await ConfigMain.get("lang", defaultLocale);
};
const getLocale = () => {
return locale;
};
export const ConfigLang = {
readyAsync,
getLocale,
};

102
vendor/aigcpanel/electron/config/menu.ts vendored Normal file
View File

@@ -0,0 +1,102 @@
import { app, Menu } from "electron";
import { isDev, isMac } from "../lib/env";
import { t } from "./lang";
let contextMenu: Electron.Menu;
const ready = () => {
const menuTemplate: Electron.MenuItemConstructorOptions[] = [];
if (isMac) {
menuTemplate.push({
label: app.name,
submenu: [
{ label: `${t("menu.about")}${app.name}`, role: "about" },
{ type: "separator" },
// {
// label: t("设置"),
// click: () => {
// createSettingWindow();
// },
// accelerator: "CmdOrCtrl+,",
// },
// {type: "separator"},
{ label: t("menu.services"), role: "services" },
{ type: "separator" },
{ label: `${t("menu.hide")} ${app.name}`, role: "hide" },
{ label: t("menu.hideOthers"), role: "hideOthers" },
{ label: t("menu.showAll"), role: "unhide" },
{ type: "separator" },
{ label: t("menu.quit"), role: "quit" },
],
});
}
menuTemplate.push({
label: t("menu.edit"),
submenu: [
{ label: t("menu.undo"), accelerator: "CmdOrCtrl+Z", role: "undo" },
{
label: t("menu.redo"),
accelerator: "Shift+CmdOrCtrl+Z",
role: "redo",
},
{ type: "separator" },
{ label: t("menu.cut"), accelerator: "CmdOrCtrl+X", role: "cut" },
{ label: t("menu.copy"), accelerator: "CmdOrCtrl+C", role: "copy" },
{
label: t("menu.paste"),
accelerator: "CmdOrCtrl+V",
role: "paste",
},
{
label: t("menu.selectAll"),
accelerator: "CmdOrCtrl+A",
role: "selectAll",
},
],
});
if (isDev) {
menuTemplate.push({
label: t("menu.view"),
submenu: [
{ label: t("menu.reload"), role: "reload" },
{ label: t("menu.forceReload"), role: "forceReload" },
{ label: t("menu.devTools"), role: "toggleDevTools" },
{ type: "separator" },
{
label: t("menu.actualSize"),
role: "resetZoom",
accelerator: "",
},
{ label: t("menu.zoomIn"), role: "zoomIn" },
{ label: t("menu.zoomOut"), role: "zoomOut" },
{ type: "separator" },
{ label: t("menu.fullscreen"), role: "togglefullscreen" },
],
});
}
// menuTemplate.push({
// label: t("帮助"),
// role: "help",
// submenu: [
// // {
// // label: t("教程帮助"),
// // click: () => {
// // createHelpWindow();
// // },
// // },
// // {type: "separator"},
// // {
// // label: t("关于"),
// // click: () => {
// // PageAbout.open().then()
// // },
// // },
// ],
// })
const menu = Menu.buildFromTemplate(menuTemplate);
Menu.setApplicationMenu(menu);
};
export const ConfigMenu = {
ready,
};

View File

@@ -0,0 +1,75 @@
import { app, Menu, Tray } from "electron";
import { AppConfig } from "../../src/config";
import { isMac, isWin } from "../lib/env";
import { AppRuntime } from "../mapi/env";
import { trayPath } from "./icon";
import { t } from "./lang";
let tray = null;
const showApp = () => {
if (isMac) {
app.dock.show();
}
AppRuntime.mainWindow.show();
};
const hideApp = () => {
if (isMac) {
app.dock.hide();
}
AppRuntime.mainWindow.hide();
};
const quitApp = () => {
// @ts-ignore
app.quitForce = true;
app.quit();
};
const ready = () => {
tray = new Tray(trayPath);
tray.setToolTip(AppConfig.title);
if (isWin) {
tray.on("click", () => {
showApp();
});
}
const contextMenu = Menu.buildFromTemplate([
{
label: t("tray.showMain"),
click: () => {
showApp();
},
},
{
label: t("tray.restart"),
click: () => {
app.relaunch();
quitApp();
},
},
{
label: t("menu.quit"),
click: () => {
quitApp();
},
},
]);
tray.setContextMenu(contextMenu);
};
const show = () => {
if (tray) {
tray.destroy();
tray = null;
}
};
export const ConfigTray = {
ready,
};

View File

@@ -0,0 +1,19 @@
export const WindowConfig = {
alwaysOpenDevTools: !process.env.ELECTRON_NO_DEVTOOLS,
minWidth: 1200,
minHeight: 700,
initWidth: 1200,
initHeight: 700,
aboutWidth: 500,
aboutHeight: 400,
logWidth: 800,
logHeight: 600,
feedbackWidth: 700,
feedbackHeight: 600,
guideWidth: 800,
guideHeight: 540,
paymentWidth: 500,
paymentHeight: 400,
setupWidth: 800,
setupHeight: 540,
};