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) =>
|
const isSubdirectory: (from: string, to: string) => Promise<boolean> = (from: string, to: string) =>
|
||||||
globalThis.core.api?.isSubdirectory(from, to)
|
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.
|
* Show toast message from browser processes.
|
||||||
* @param title
|
* @param title
|
||||||
@ -117,7 +110,6 @@ export {
|
|||||||
log,
|
log,
|
||||||
isSubdirectory,
|
isSubdirectory,
|
||||||
getUserHomePath,
|
getUserHomePath,
|
||||||
systemInformation,
|
|
||||||
showToast,
|
showToast,
|
||||||
dirName,
|
dirName,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,6 @@ export enum AppRoute {
|
|||||||
isSubdirectory = 'isSubdirectory',
|
isSubdirectory = 'isSubdirectory',
|
||||||
baseName = 'baseName',
|
baseName = 'baseName',
|
||||||
log = 'log',
|
log = 'log',
|
||||||
systemInformation = 'systemInformation',
|
|
||||||
showToast = 'showToast',
|
showToast = 'showToast',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,5 @@
|
|||||||
import {
|
import { CoreRoutes, APIRoutes } from '@janhq/core'
|
||||||
CoreRoutes,
|
|
||||||
APIRoutes,
|
|
||||||
HardwareManagementExtension,
|
|
||||||
ExtensionTypeEnum,
|
|
||||||
} from '@janhq/core'
|
|
||||||
import { invoke, InvokeArgs } from '@tauri-apps/api/core'
|
import { invoke, InvokeArgs } from '@tauri-apps/api/core'
|
||||||
import { ExtensionManager } from './extension'
|
|
||||||
import { useVulkan } from '@/hooks/useVulkan'
|
|
||||||
|
|
||||||
export const AppRoutes = [
|
export const AppRoutes = [
|
||||||
'installExtensions',
|
'installExtensions',
|
||||||
@ -43,35 +36,6 @@ export function openExternalUrl(url: string) {
|
|||||||
window?.open(url, '_blank')
|
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 = {
|
export const APIs = {
|
||||||
...Object.values(Routes).reduce((acc, proxy) => {
|
...Object.values(Routes).reduce((acc, proxy) => {
|
||||||
return {
|
return {
|
||||||
@ -86,5 +50,4 @@ export const APIs = {
|
|||||||
}
|
}
|
||||||
}, {}),
|
}, {}),
|
||||||
openExternalUrl,
|
openExternalUrl,
|
||||||
systemInformation,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import {
|
|||||||
SettingComponentProps,
|
SettingComponentProps,
|
||||||
} from '@janhq/core'
|
} from '@janhq/core'
|
||||||
import { Model as CoreModel } from '@janhq/core'
|
import { Model as CoreModel } from '@janhq/core'
|
||||||
import { fetch as fetchTauri } from '@tauri-apps/plugin-http'
|
|
||||||
// Types for model catalog
|
// Types for model catalog
|
||||||
export interface ModelQuant {
|
export interface ModelQuant {
|
||||||
model_id: string
|
model_id: string
|
||||||
@ -45,7 +44,7 @@ export const fetchModels = async () => {
|
|||||||
*/
|
*/
|
||||||
export const fetchModelCatalog = async (): Promise<ModelCatalog> => {
|
export const fetchModelCatalog = async (): Promise<ModelCatalog> => {
|
||||||
try {
|
try {
|
||||||
const response = await fetchTauri(MODEL_CATALOG_URL)
|
const response = await fetch(MODEL_CATALOG_URL)
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user