From 2bdbce2e4085d035b603570f48b41504d11419b1 Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 27 Jun 2025 14:37:25 +0700 Subject: [PATCH] refactor: clean up unused apis --- core/src/browser/core.ts | 8 ------- core/src/types/api/index.ts | 1 - web-app/src/lib/service.ts | 39 +--------------------------------- web-app/src/services/models.ts | 3 +-- 4 files changed, 2 insertions(+), 49 deletions(-) diff --git a/core/src/browser/core.ts b/core/src/browser/core.ts index 93bea50c9..3c35212a3 100644 --- a/core/src/browser/core.ts +++ b/core/src/browser/core.ts @@ -78,13 +78,6 @@ const log: (message: string, fileName?: string) => void = (message, fileName) => const isSubdirectory: (from: string, to: string) => Promise = (from: string, to: string) => globalThis.core.api?.isSubdirectory(from, to) -/** - * Get system information - * @returns {Promise} - A promise that resolves with the system information. - */ -const systemInformation: () => Promise = () => - globalThis.core.api?.systemInformation() - /** * Show toast message from browser processes. * @param title @@ -117,7 +110,6 @@ export { log, isSubdirectory, getUserHomePath, - systemInformation, showToast, dirName, } diff --git a/core/src/types/api/index.ts b/core/src/types/api/index.ts index b9584725d..853195178 100644 --- a/core/src/types/api/index.ts +++ b/core/src/types/api/index.ts @@ -49,7 +49,6 @@ export enum AppRoute { isSubdirectory = 'isSubdirectory', baseName = 'baseName', log = 'log', - systemInformation = 'systemInformation', showToast = 'showToast', } diff --git a/web-app/src/lib/service.ts b/web-app/src/lib/service.ts index 99e958ff2..351780445 100644 --- a/web-app/src/lib/service.ts +++ b/web-app/src/lib/service.ts @@ -1,12 +1,5 @@ -import { - CoreRoutes, - APIRoutes, - HardwareManagementExtension, - ExtensionTypeEnum, -} from '@janhq/core' +import { CoreRoutes, APIRoutes } from '@janhq/core' import { invoke, InvokeArgs } from '@tauri-apps/api/core' -import { ExtensionManager } from './extension' -import { useVulkan } from '@/hooks/useVulkan' export const AppRoutes = [ 'installExtensions', @@ -43,35 +36,6 @@ export function openExternalUrl(url: string) { window?.open(url, '_blank') } -export const systemInformation = async () => { - const hardwareExtension = - ExtensionManager.getInstance().get( - ExtensionTypeEnum.Hardware - ) - - if (!hardwareExtension) return undefined - - const hardwareInfo = await hardwareExtension?.getHardware() - - const gpuSettingInfo = { - gpus: hardwareInfo.gpus.filter((gpu) => gpu.total_vram > 0), - vulkan: useVulkan.getState().vulkanEnabled, - cpu: hardwareInfo.cpu, - } - - const updateOsInfo = { - platform: PLATFORM, - arch: hardwareInfo.cpu.arch, - freeMem: hardwareInfo.ram.available, - totalMem: hardwareInfo.ram.total, - } - - return { - gpuSetting: gpuSettingInfo, - osInfo: updateOsInfo, - } -} - export const APIs = { ...Object.values(Routes).reduce((acc, proxy) => { return { @@ -86,5 +50,4 @@ export const APIs = { } }, {}), openExternalUrl, - systemInformation, } diff --git a/web-app/src/services/models.ts b/web-app/src/services/models.ts index c97a67ed1..264b7f8c3 100644 --- a/web-app/src/services/models.ts +++ b/web-app/src/services/models.ts @@ -5,7 +5,6 @@ import { SettingComponentProps, } from '@janhq/core' import { Model as CoreModel } from '@janhq/core' -import { fetch as fetchTauri } from '@tauri-apps/plugin-http' // Types for model catalog export interface ModelQuant { model_id: string @@ -45,7 +44,7 @@ export const fetchModels = async () => { */ export const fetchModelCatalog = async (): Promise => { try { - const response = await fetchTauri(MODEL_CATALOG_URL) + const response = await fetch(MODEL_CATALOG_URL) if (!response.ok) { throw new Error(