fix: model import name and id is wrong on Windows

This commit is contained in:
Louis 2024-11-11 10:30:22 +07:00
parent 244d3d10dc
commit 19879ef279

View File

@ -5,11 +5,11 @@ import {
ImportingModel, ImportingModel,
LocalImportModelEvent, LocalImportModelEvent,
Model, Model,
ModelEvent,
ModelExtension, ModelExtension,
OptionType, OptionType,
events, events,
fs, fs,
baseName
} from '@janhq/core' } from '@janhq/core'
import { atom, useSetAtom } from 'jotai' import { atom, useSetAtom } from 'jotai'
@ -61,8 +61,8 @@ const useImportModel = () => {
const importModels = useCallback( const importModels = useCallback(
(models: ImportingModel[], optionType: OptionType) => { (models: ImportingModel[], optionType: OptionType) => {
models.map((model) => { models.map(async (model) => {
const modelId = model.modelId ?? model.path.split('/').pop() const modelId = model.modelId ?? await baseName(model.path)
if (modelId) { if (modelId) {
addDownloadingModel(modelId) addDownloadingModel(modelId)
extensionManager extensionManager