mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
refactor: consolidate environment config and API handling
- Update database paths and port configuration - Remove backend config.ts and sessions route - Add mobile file preview and files API - Clean up shared constants and provider hooks
This commit is contained in:
1 parent
0db354048d
commit
8a56bc208d
32 files changed
+301
-512
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { API_BASE_URL } from '@/constants/api'
|
||||
import type { FileInfo } from '@/types/files'
|
||||
|
||||
const API_BASE = API_BASE_URL
|
||||
|
||||
async function fetchFile(path: string): Promise<FileInfo> {
|
||||
const response = await fetch(`${API_BASE}/api/files/${path}`)
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to load file: ${response.statusText}`)
|
||||
}
|
||||
|
||||
return response.json()
|
||||
}
|
||||
|
||||
export function useFile(path: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['file', path],
|
||||
queryFn: () => path ? fetchFile(path) : Promise.reject(new Error('No file path provided')),
|
||||
enabled: !!path,
|
||||
})
|
||||
}
|
||||
@@ -39,6 +39,7 @@ export interface Provider {
|
||||
env: string[];
|
||||
npm?: string;
|
||||
models: Record<string, Model>;
|
||||
options?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface ProviderWithModels {
|
||||
|
||||
Reference in new issue
Block a user