init source
This commit is contained in:
28
composables/useApi.ts
Normal file
28
composables/useApi.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useFetch, useRuntimeConfig, useCookie } from '#imports'
|
||||
|
||||
export const useApi = <T>(
|
||||
path: string,
|
||||
options: {
|
||||
method?: 'get' | 'post' | 'put' | 'delete'
|
||||
body?: any
|
||||
query?: Record<string, any>
|
||||
headers?: HeadersInit
|
||||
server?: boolean // ← 이 줄 추가!
|
||||
} = {}
|
||||
) => {
|
||||
const config = useRuntimeConfig()
|
||||
const token = useCookie('token')
|
||||
|
||||
const method = options.method ? options.method.toUpperCase() : 'GET'
|
||||
|
||||
return useFetch<T>(() => `${config.public.apiBase}${path}`, {
|
||||
method: method as any, // 타입 강제 우회
|
||||
body: options.body,
|
||||
query: options.query,
|
||||
headers: {
|
||||
Authorization: token.value ? `Bearer ${token.value}` : '',
|
||||
...options.headers
|
||||
},
|
||||
server: options.server // ← 이 줄 추가!
|
||||
})
|
||||
}
|
25
composables/useCounter.ts
Normal file
25
composables/useCounter.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export const useCounter = () => {
|
||||
const count = ref(0);
|
||||
|
||||
const increment = () => {
|
||||
count.value++;
|
||||
};
|
||||
|
||||
const decrement = () => {
|
||||
count.value--;
|
||||
};
|
||||
|
||||
const reset = () => {
|
||||
count.value = 0;
|
||||
};
|
||||
|
||||
const double = computed(() => count.value * 2);
|
||||
|
||||
return {
|
||||
count: readonly(count),
|
||||
increment,
|
||||
decrement,
|
||||
reset,
|
||||
double,
|
||||
};
|
||||
};
|
8
composables/useOverlay.ts
Normal file
8
composables/useOverlay.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export default async function useOverlay() {
|
||||
if (import.meta.server) {
|
||||
// SSR에서는 cytoscape-overlays를 사용하지 않음
|
||||
return null
|
||||
}
|
||||
// 전체 export 객체를 반환
|
||||
return await import('cytoscape-overlays')
|
||||
}
|
9
composables/useSidebar.ts
Normal file
9
composables/useSidebar.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { ref } from "vue";
|
||||
|
||||
export const useSidebar = () => {
|
||||
const isSidebarOpen = ref(true);
|
||||
const toggleSidebar = () => {
|
||||
isSidebarOpen.value = !isSidebarOpen.value;
|
||||
};
|
||||
return { isSidebarOpen, toggleSidebar };
|
||||
};
|
Reference in New Issue
Block a user