| 1234567891011121314151617181920212223242526272829303132 |
- import { ref, type Ref } from "vue";
- import { defineStore } from "pinia";
- import * as kgService from "@/services/knowledgeGraph.service";
- import * as searchService from "@/services/search.service";
- import type { Property } from "@/types/knowledgeGraph.types";
- import type { SearchResult } from "@/types/search.types";
- export const useKnowledgeGraphStore = defineStore('knowledge-graph', () => {
- const property: Ref<Property> = ref({} as Property);
- const searchResult: Ref<SearchResult | null> = ref(null);
- function fetchProperty(id: number) {
- kgService.fetchProperty(id).then((resp) => {
- property.value = resp.data.data;
- })
- }
- function search(name: string) {
- searchService.search(`TP=("${name}")`).then((resp) => {
- searchResult.value = resp.data.data;
- });
- }
- return {
- property,
- searchResult,
- fetchProperty,
- search,
- }
- });
|