|
|
@@ -0,0 +1,38 @@
|
|
|
+import { defineStore } from 'pinia';
|
|
|
+import { getAllModelFileJsonApi } from '/@/api/sys/modelFile';
|
|
|
+
|
|
|
+interface ModelFileItem {
|
|
|
+ fileName: string;
|
|
|
+ filePath: string;
|
|
|
+}
|
|
|
+
|
|
|
+export const useModelFileStore = defineStore({
|
|
|
+ id: 'app-model-file',
|
|
|
+ state: () => ({
|
|
|
+ modelFileData: null as Record<string, ModelFileItem[]> | null,
|
|
|
+ }),
|
|
|
+ getters: {
|
|
|
+ getModelFileDataByKey(): (key: string) => ModelFileItem[] {
|
|
|
+ return (key: string) => {
|
|
|
+ if (!this.modelFileData || !this.modelFileData[key]) return [];
|
|
|
+ return this.modelFileData[key];
|
|
|
+ };
|
|
|
+ },
|
|
|
+ getAllModelFileData(): Record<string, ModelFileItem[]> | null {
|
|
|
+ return this.modelFileData;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ actions: {
|
|
|
+ async fetchModelFileData() {
|
|
|
+ const raw = await getAllModelFileJsonApi();
|
|
|
+ const processed: Record<string, ModelFileItem[]> = {};
|
|
|
+ for (const [key, items] of Object.entries(raw)) {
|
|
|
+ processed[key] = items.map((item) => ({
|
|
|
+ fileName: item.fileName.replace(/\.[^.]+$/, ''),
|
|
|
+ filePath: item.filePath.replace(/^\/data\/file/, ''),
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ this.modelFileData = processed;
|
|
|
+ },
|
|
|
+ },
|
|
|
+});
|