37 lines
879 B
TypeScript
37 lines
879 B
TypeScript
import { ExtensionTypeEnum } from '@janhq/core'
|
|
|
|
import { extensionManager } from '@/extension/ExtensionManager'
|
|
|
|
export const isCoreExtensionInstalled = () => {
|
|
if (!extensionManager.get(ExtensionTypeEnum.Conversational)) {
|
|
return false
|
|
}
|
|
if (!extensionManager.get(ExtensionTypeEnum.Model)) {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
export const setupBaseExtensions = async () => {
|
|
if (typeof window === 'undefined') {
|
|
return
|
|
}
|
|
|
|
if (IS_TAURI) {
|
|
await window.core?.api.installExtensions()
|
|
window.location.reload()
|
|
}
|
|
return
|
|
const baseExtensions = await window.core?.api.baseExtensions()
|
|
|
|
if (
|
|
!extensionManager.get(ExtensionTypeEnum.Conversational) ||
|
|
!extensionManager.get(ExtensionTypeEnum.Model)
|
|
) {
|
|
const installed = await extensionManager.install(baseExtensions)
|
|
if (installed) {
|
|
window.location.reload()
|
|
}
|
|
}
|
|
}
|