027c1305fd
- Ajout vue-pdf-embed@2.1.4 - DTO share.ts (FileEntry, Breadcrumb, ShareBrowseResult, ShareStatus, ShareSettings, ShareSettingsWrite, ShareTestResult) - Service share.ts (browse, getStatus, getDownloadUrl) - Service share-settings.ts (getSettings, saveSettings, testConnection)
23 lines
808 B
TypeScript
23 lines
808 B
TypeScript
import type { ShareBrowseResult, ShareStatus } from './dto/share'
|
|
|
|
export function useShareService() {
|
|
const api = useApi()
|
|
const config = useRuntimeConfig()
|
|
|
|
async function browse(path: string): Promise<ShareBrowseResult> {
|
|
const query = path ? `?path=${encodeURIComponent(path)}` : ''
|
|
return api.get<ShareBrowseResult>(`/share/browse${query}`)
|
|
}
|
|
|
|
async function getStatus(): Promise<ShareStatus> {
|
|
return api.get<ShareStatus>('/share/status')
|
|
}
|
|
|
|
function getDownloadUrl(path: string, disposition: 'inline' | 'attachment' = 'inline'): string {
|
|
const base = config.public.apiBase || '/api'
|
|
return `${base}/share/download?path=${encodeURIComponent(path)}&disposition=${disposition}`
|
|
}
|
|
|
|
return { browse, getStatus, getDownloadUrl }
|
|
}
|