mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-26 01:10:16 +08:00
feat(preload): expose architecture detection to renderer process
add multiarch support
This commit is contained in:
@@ -23,6 +23,17 @@ contextBridge.exposeInMainWorld('ipcRenderer', {
|
|||||||
// ...
|
// ...
|
||||||
})
|
})
|
||||||
|
|
||||||
|
contextBridge.exposeInMainWorld('apm_store', {
|
||||||
|
arch: (() => {
|
||||||
|
const arch = process.arch;
|
||||||
|
if (arch === 'x64') {
|
||||||
|
return 'amd64' + '-apm';
|
||||||
|
} else {
|
||||||
|
return arch + '-apm';
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
});
|
||||||
|
|
||||||
// --------- Preload scripts loading ---------
|
// --------- Preload scripts loading ---------
|
||||||
function domReady(condition: DocumentReadyState[] = ['complete', 'interactive']) {
|
function domReady(condition: DocumentReadyState[] = ['complete', 'interactive']) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "apm-app-store",
|
"name": "apm-app-store",
|
||||||
"version": "1.0.3-beta.0",
|
"version": "1.0.3-beta.1",
|
||||||
"main": "dist-electron/main/index.js",
|
"main": "dist-electron/main/index.js",
|
||||||
"description": "Client for APM App Store",
|
"description": "Client for APM App Store",
|
||||||
"author": "elysia-best <elysia-best@simplelinux.cn.eu.org>",
|
"author": "elysia-best <elysia-best@simplelinux.cn.eu.org>",
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ import DownloadDetail from './components/DownloadDetail.vue';
|
|||||||
import InstalledAppsModal from './components/InstalledAppsModal.vue';
|
import InstalledAppsModal from './components/InstalledAppsModal.vue';
|
||||||
import UpdateAppsModal from './components/UpdateAppsModal.vue';
|
import UpdateAppsModal from './components/UpdateAppsModal.vue';
|
||||||
import UninstallConfirmModal from './components/UninstallConfirmModal.vue';
|
import UninstallConfirmModal from './components/UninstallConfirmModal.vue';
|
||||||
import { APM_STORE_ARCHITECTURE, APM_STORE_BASE_URL, currentApp, currentAppIsInstalled } from './global/storeConfig';
|
import { APM_STORE_BASE_URL, currentApp, currentAppIsInstalled } from './global/storeConfig';
|
||||||
import { downloads } from './global/downloadStatus';
|
import { downloads } from './global/downloadStatus';
|
||||||
import { handleInstall, handleRetry, handleUpgrade } from './modeuls/processInstall';
|
import { handleInstall, handleRetry, handleUpgrade } from './modeuls/processInstall';
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ const checkAppInstalled = (app) => {
|
|||||||
const loadScreenshots = (app) => {
|
const loadScreenshots = (app) => {
|
||||||
screenshots.value = [];
|
screenshots.value = [];
|
||||||
for (let i = 1; i <= 5; i++) {
|
for (let i = 1; i <= 5; i++) {
|
||||||
const screenshotUrl = `${APM_STORE_BASE_URL}/${APM_STORE_ARCHITECTURE}/${app._category}/${app.Pkgname}/screen_${i}.png`;
|
const screenshotUrl = `${APM_STORE_BASE_URL}/${window.apm_store.arch}/${app._category}/${app.Pkgname}/screen_${i}.png`;
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
img.src = screenshotUrl;
|
img.src = screenshotUrl;
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
@@ -480,7 +480,7 @@ const openDownloadedApp = (download) => {
|
|||||||
|
|
||||||
const loadCategories = async () => {
|
const loadCategories = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axiosInstance.get(`/${APM_STORE_ARCHITECTURE}/categories.json`);
|
const response = await axiosInstance.get(`/${window.apm_store.arch}/categories.json`);
|
||||||
categories.value = response.data;
|
categories.value = response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('读取 categories.json 失败', error);
|
logger.error('读取 categories.json 失败', error);
|
||||||
@@ -493,7 +493,7 @@ const loadApps = async () => {
|
|||||||
logger.info('开始加载应用数据...');
|
logger.info('开始加载应用数据...');
|
||||||
const promises = Object.keys(categories.value).map(async category => {
|
const promises = Object.keys(categories.value).map(async category => {
|
||||||
try {
|
try {
|
||||||
const response = await axiosInstance.get(`/${APM_STORE_ARCHITECTURE}/${category}/applist.json`);
|
const response = await axiosInstance.get(`/${window.apm_store.arch}/${category}/applist.json`);
|
||||||
return response.status === 200 ? response.data : [];
|
return response.status === 200 ? response.data : [];
|
||||||
} catch {
|
} catch {
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, defineProps, defineEmits, onMounted, onBeforeUnmount, ref, watch } from 'vue';
|
import { computed, defineProps, defineEmits, onMounted, onBeforeUnmount, ref, watch } from 'vue';
|
||||||
import { APM_STORE_ARCHITECTURE, APM_STORE_BASE_URL } from '../global/storeConfig';
|
import { APM_STORE_BASE_URL } from '../global/storeConfig';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
app: {
|
app: {
|
||||||
@@ -32,7 +32,7 @@ const isLoaded = ref(false);
|
|||||||
const loadedIcon = ref('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"%3E%3Crect fill="%23f0f0f0" width="100" height="100"/%3E%3C/svg%3E');
|
const loadedIcon = ref('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"%3E%3Crect fill="%23f0f0f0" width="100" height="100"/%3E%3C/svg%3E');
|
||||||
|
|
||||||
const iconPath = computed(() => {
|
const iconPath = computed(() => {
|
||||||
return `${APM_STORE_BASE_URL}/${APM_STORE_ARCHITECTURE}/${props.app._category}/${props.app.Pkgname}/icon.png`;
|
return `${APM_STORE_BASE_URL}/${window.apm_store.arch}/${props.app._category}/${props.app.Pkgname}/icon.png`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const description = computed(() => {
|
const description = computed(() => {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, defineProps, defineEmits, useAttrs, ref } from 'vue';
|
import { computed, defineProps, defineEmits, useAttrs, ref } from 'vue';
|
||||||
import { APM_STORE_ARCHITECTURE, APM_STORE_BASE_URL } from '../global/storeConfig';
|
import { APM_STORE_BASE_URL } from '../global/storeConfig';
|
||||||
|
|
||||||
defineOptions({ inheritAttrs: false });
|
defineOptions({ inheritAttrs: false });
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ const props = defineProps({
|
|||||||
const emit = defineEmits(['close', 'install', 'remove', 'open-preview']);
|
const emit = defineEmits(['close', 'install', 'remove', 'open-preview']);
|
||||||
|
|
||||||
const iconPath = computed(() => {
|
const iconPath = computed(() => {
|
||||||
return props.app ? `${APM_STORE_BASE_URL}/${APM_STORE_ARCHITECTURE}/${props.app._category}/${props.app.Pkgname}/icon.png` : '';
|
return props.app ? `${APM_STORE_BASE_URL}/${window.apm_store.arch}/${props.app._category}/${props.app.Pkgname}/icon.png` : '';
|
||||||
});
|
});
|
||||||
|
|
||||||
const closeModal = () => {
|
const closeModal = () => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<img :src="amberLogo" alt="Amber PM" class="h-11 w-11 rounded-2xl bg-white/70 p-2 shadow-sm ring-1 ring-slate-900/5 dark:bg-slate-800" />
|
<img :src="amberLogo" alt="Amber PM" class="h-11 w-11 rounded-2xl bg-white/70 p-2 shadow-sm ring-1 ring-slate-900/5 dark:bg-slate-800" />
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<span class="text-xs uppercase tracking-[0.3em] text-slate-500 dark:text-slate-400">APM Store</span>
|
<span class="text-xs uppercase tracking-[0.3em] text-slate-500 dark:text-slate-400">APM Store</span>
|
||||||
<span class="text-lg font-semibold text-slate-900 dark:text-white">APM x86 客户端商店</span>
|
<span class="text-lg font-semibold text-slate-900 dark:text-white">APM 客户端商店</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
export const APM_STORE_BASE_URL=import.meta.env.VITE_APM_STORE_BASE_URL;
|
export const APM_STORE_BASE_URL=import.meta.env.VITE_APM_STORE_BASE_URL;
|
||||||
export const APM_STORE_ARCHITECTURE='amd64-apm';
|
|
||||||
|
|
||||||
// 下面的变量用于存储当前应用的信息,其实用在多个组件中
|
// 下面的变量用于存储当前应用的信息,其实用在多个组件中
|
||||||
export const currentApp = ref<any>(null);
|
export const currentApp = ref<any>(null);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// })
|
// })
|
||||||
|
|
||||||
import { currentApp, currentAppIsInstalled } from "../global/storeConfig";
|
import { currentApp, currentAppIsInstalled } from "../global/storeConfig";
|
||||||
import { APM_STORE_BASE_URL, APM_STORE_ARCHITECTURE } from "../global/storeConfig";
|
import { APM_STORE_BASE_URL } from "../global/storeConfig";
|
||||||
import { downloads } from "../global/downloadStatus";
|
import { downloads } from "../global/downloadStatus";
|
||||||
|
|
||||||
import { InstallLog, DownloadItem, DownloadResult } from '../global/typedefinition';
|
import { InstallLog, DownloadItem, DownloadResult } from '../global/typedefinition';
|
||||||
@@ -20,7 +20,7 @@ export const handleInstall = () => {
|
|||||||
name: currentApp.value.Name,
|
name: currentApp.value.Name,
|
||||||
pkgname: currentApp.value.Pkgname,
|
pkgname: currentApp.value.Pkgname,
|
||||||
version: currentApp.value.Version,
|
version: currentApp.value.Version,
|
||||||
icon: `${APM_STORE_BASE_URL}/${APM_STORE_ARCHITECTURE}/${currentApp.value._category}/${currentApp.value.Pkgname}/icon.png`,
|
icon: `${APM_STORE_BASE_URL}/${APM_STORE_ARCHITECTURE()}/${currentApp.value._category}/${currentApp.value.Pkgname}/icon.png`,
|
||||||
status: 'queued',
|
status: 'queued',
|
||||||
progress: 0,
|
progress: 0,
|
||||||
downloadedSize: 0,
|
downloadedSize: 0,
|
||||||
@@ -62,7 +62,7 @@ export const handleUpgrade = (pkg: any) => {
|
|||||||
name: pkg.Name,
|
name: pkg.Name,
|
||||||
pkgname: pkg.Pkgname,
|
pkgname: pkg.Pkgname,
|
||||||
version: pkg.Version,
|
version: pkg.Version,
|
||||||
icon: `${APM_STORE_BASE_URL}/${APM_STORE_ARCHITECTURE}/${pkg._category}/${pkg.Pkgname}/icon.png`,
|
icon: `${APM_STORE_BASE_URL}/${window.apm_store.arch}/${pkg._category}/${pkg.Pkgname}/icon.png`,
|
||||||
status: 'queued',
|
status: 'queued',
|
||||||
progress: 0,
|
progress: 0,
|
||||||
downloadedSize: 0,
|
downloadedSize: 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user