refactor: clean up unused apis
This commit is contained in:
parent
c6ac9f1d2a
commit
2bdbce2e40
@ -78,13 +78,6 @@ const log: (message: string, fileName?: string) => void = (message, fileName) =>
|
||||
const isSubdirectory: (from: string, to: string) => Promise<boolean> = (from: string, to: string) =>
|
||||
globalThis.core.api?.isSubdirectory(from, to)
|
||||
|
||||
/**
|
||||
* Get system information
|
||||
* @returns {Promise<any>} - A promise that resolves with the system information.
|
||||
*/
|
||||
const systemInformation: () => Promise<SystemInformation> = () =>
|
||||
globalThis.core.api?.systemInformation()
|
||||
|
||||
/**
|
||||
* Show toast message from browser processes.
|
||||
* @param title
|
||||
@ -117,7 +110,6 @@ export {
|
||||
log,
|
||||
isSubdirectory,
|
||||
getUserHomePath,
|
||||
systemInformation,
|
||||
showToast,
|
||||
dirName,
|
||||
}
|
||||
|
||||
@ -49,7 +49,6 @@ export enum AppRoute {
|
||||
isSubdirectory = 'isSubdirectory',
|
||||
baseName = 'baseName',
|
||||
log = 'log',
|
||||
systemInformation = 'systemInformation',
|
||||
showToast = 'showToast',
|
||||
}
|
||||
|
||||
|
||||
@ -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<HardwareManagementExtension>(
|
||||
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,
|
||||
}
|
||||
|
||||
@ -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<ModelCatalog> => {
|
||||
try {
|
||||
const response = await fetchTauri(MODEL_CATALOG_URL)
|
||||
const response = await fetch(MODEL_CATALOG_URL)
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user