🚨 Format code
This commit is contained in:
@@ -1,40 +1,40 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref } from 'vue'
|
||||
import { Extension, ExtensionID } from '@/../bindings/voidraft/internal/models/models'
|
||||
import { ExtensionService } from '@/../bindings/voidraft/internal/services'
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import { Extension, ExtensionID } from '@/../bindings/voidraft/internal/models/models';
|
||||
import { ExtensionService } from '@/../bindings/voidraft/internal/services';
|
||||
|
||||
export const useExtensionStore = defineStore('extension', () => {
|
||||
// 扩展配置数据
|
||||
const extensions = ref<Extension[]>([])
|
||||
const extensions = ref<Extension[]>([]);
|
||||
|
||||
// 获取启用的扩展
|
||||
const enabledExtensions = computed(() =>
|
||||
extensions.value.filter(ext => ext.enabled)
|
||||
)
|
||||
);
|
||||
|
||||
// 获取启用的扩展ID列表
|
||||
const enabledExtensionIds = computed(() =>
|
||||
enabledExtensions.value.map(ext => ext.id)
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* 从后端加载扩展配置
|
||||
*/
|
||||
const loadExtensions = async (): Promise<void> => {
|
||||
try {
|
||||
extensions.value = await ExtensionService.GetAllExtensions()
|
||||
extensions.value = await ExtensionService.GetAllExtensions();
|
||||
} catch (err) {
|
||||
console.error('[ExtensionStore] Failed to load extensions:', err)
|
||||
console.error('[ExtensionStore] Failed to load extensions:', err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取扩展配置
|
||||
*/
|
||||
const getExtensionConfig = (id: ExtensionID): any => {
|
||||
const extension = extensions.value.find(ext => ext.id === id)
|
||||
return extension?.config ?? {}
|
||||
}
|
||||
const extension = extensions.value.find(ext => ext.id === id);
|
||||
return extension?.config ?? {};
|
||||
};
|
||||
|
||||
return {
|
||||
// 状态
|
||||
@@ -45,5 +45,5 @@ export const useExtensionStore = defineStore('extension', () => {
|
||||
// 方法
|
||||
loadExtensions,
|
||||
getExtensionConfig,
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user