mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-26 09:20:18 +08:00
feat: implement store filter based on launch arguments
- Added a new function to determine the store filter based on the `--no-apm` and `--no-spark` launch arguments. - Integrated IPC to retrieve the store filter in the main process and updated the Vue component to reflect the selected filter. - Adjusted logic in the app loading functions to conditionally display apps based on the determined filter.
This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -20,7 +20,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Debug Main Process",
|
"name": "Debug Main Process",
|
||||||
"type": "node",
|
"type": "node",
|
||||||
@@ -31,6 +30,7 @@
|
|||||||
// },
|
// },
|
||||||
"runtimeArgs": [
|
"runtimeArgs": [
|
||||||
"--remote-debugging-port=9229",
|
"--remote-debugging-port=9229",
|
||||||
|
"--no-spark",
|
||||||
"."
|
"."
|
||||||
],
|
],
|
||||||
"envFile": "${workspaceFolder}/.vscode/.debug.env",
|
"envFile": "${workspaceFolder}/.vscode/.debug.env",
|
||||||
|
|||||||
@@ -74,6 +74,22 @@ const getUserAgent = (): string => {
|
|||||||
|
|
||||||
logger.info("User Agent: " + getUserAgent());
|
logger.info("User Agent: " + getUserAgent());
|
||||||
|
|
||||||
|
/** 根据启动参数 --no-apm / --no-spark 决定只展示的来源 */
|
||||||
|
function getStoreFilterFromArgv(): "spark" | "apm" | "both" {
|
||||||
|
const argv = process.argv;
|
||||||
|
const noApm = argv.includes("--no-apm");
|
||||||
|
const noSpark = argv.includes("--no-spark");
|
||||||
|
if (noApm && noSpark) return "both";
|
||||||
|
if (noApm) return "spark";
|
||||||
|
if (noSpark) return "apm";
|
||||||
|
return "both";
|
||||||
|
}
|
||||||
|
|
||||||
|
ipcMain.handle(
|
||||||
|
"get-store-filter",
|
||||||
|
(): "spark" | "apm" | "both" => getStoreFilterFromArgv(),
|
||||||
|
);
|
||||||
|
|
||||||
async function createWindow() {
|
async function createWindow() {
|
||||||
win = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
title: "星火应用商店",
|
title: "星火应用商店",
|
||||||
|
|||||||
11
src/App.vue
11
src/App.vue
@@ -241,6 +241,9 @@ const updateError = ref("");
|
|||||||
const showUninstallModal = ref(false);
|
const showUninstallModal = ref(false);
|
||||||
const uninstallTargetApp: Ref<App | null> = ref(null);
|
const uninstallTargetApp: Ref<App | null> = ref(null);
|
||||||
|
|
||||||
|
/** 启动参数 --no-apm => 仅 Spark;--no-spark => 仅 APM;由主进程 IPC 提供 */
|
||||||
|
const storeFilter = ref<"spark" | "apm" | "both">("both");
|
||||||
|
|
||||||
// 计算属性
|
// 计算属性
|
||||||
const filteredApps = computed(() => {
|
const filteredApps = computed(() => {
|
||||||
let result = [...apps.value];
|
let result = [...apps.value];
|
||||||
@@ -509,7 +512,8 @@ const loadHome = async () => {
|
|||||||
homeLists.value = [];
|
homeLists.value = [];
|
||||||
try {
|
try {
|
||||||
const arch = window.apm_store.arch || "amd64";
|
const arch = window.apm_store.arch || "amd64";
|
||||||
const modes: Array<"spark" | "apm"> = ["spark", "apm"]; // 只保留混合模式
|
const modes: Array<"spark" | "apm"> =
|
||||||
|
storeFilter.value === "both" ? ["spark", "apm"] : [storeFilter.value];
|
||||||
|
|
||||||
for (const mode of modes) {
|
for (const mode of modes) {
|
||||||
const finalArch = mode === "spark" ? `${arch}-store` : `${arch}-apm`;
|
const finalArch = mode === "spark" ? `${arch}-store` : `${arch}-apm`;
|
||||||
@@ -915,7 +919,8 @@ const openDownloadedApp = (pkgname: string, origin?: "spark" | "apm") => {
|
|||||||
const loadCategories = async () => {
|
const loadCategories = async () => {
|
||||||
try {
|
try {
|
||||||
const arch = window.apm_store.arch || "amd64";
|
const arch = window.apm_store.arch || "amd64";
|
||||||
const modes: Array<"spark" | "apm"> = ["spark", "apm"];
|
const modes: Array<"spark" | "apm"> =
|
||||||
|
storeFilter.value === "both" ? ["spark", "apm"] : [storeFilter.value];
|
||||||
|
|
||||||
const categoryData: Record<string, { zh: string; origins: string[] }> = {};
|
const categoryData: Record<string, { zh: string; origins: string[] }> = {};
|
||||||
|
|
||||||
@@ -1039,6 +1044,8 @@ const handleSearchFocus = () => {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
initTheme();
|
initTheme();
|
||||||
|
|
||||||
|
// 从主进程获取启动参数(--no-apm / --no-spark),再加载数据
|
||||||
|
storeFilter.value = await window.ipcRenderer.invoke("get-store-filter");
|
||||||
await loadCategories();
|
await loadCategories();
|
||||||
|
|
||||||
// 分类目录加载后,并行加载主页数据和所有应用列表
|
// 分类目录加载后,并行加载主页数据和所有应用列表
|
||||||
|
|||||||
1
src/vite-env.d.ts
vendored
1
src/vite-env.d.ts
vendored
@@ -12,7 +12,6 @@ interface Window {
|
|||||||
ipcRenderer: import("electron").IpcRenderer;
|
ipcRenderer: import("electron").IpcRenderer;
|
||||||
apm_store: {
|
apm_store: {
|
||||||
arch: string;
|
arch: string;
|
||||||
[k: string]: any;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user