's'
This commit is contained in:
18
services/ResourceService.ts
Normal file
18
services/ResourceService.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export class ResourceService {
|
||||
async addResource(resource: { path: string }) {
|
||||
// Logic to add the resource, e.g., sending a request to your API
|
||||
const response = await fetch('/api/resource', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(resource),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to add resource');
|
||||
}
|
||||
|
||||
return await response.json(); // Return the response data if needed
|
||||
}
|
||||
}
|
||||
43
services/siteConfigService.ts
Normal file
43
services/siteConfigService.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { SiteConfig } from '@/types/site'
|
||||
|
||||
export class SiteConfigService {
|
||||
async getSiteConfig(): Promise<SiteConfig> {
|
||||
try {
|
||||
const response = await fetch('/api/site')
|
||||
if (!response.ok) throw new Error('Failed to fetch site config')
|
||||
const data = await response.json()
|
||||
return data
|
||||
} catch (error) {
|
||||
console.error('Error fetching site config:', error)
|
||||
return {
|
||||
basic: {
|
||||
title: '',
|
||||
description: '',
|
||||
keywords: ''
|
||||
},
|
||||
appearance: {
|
||||
logo: '',
|
||||
favicon: '',
|
||||
theme: 'system'
|
||||
},
|
||||
navigation: {
|
||||
linkTarget: '_blank'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async updateSiteConfig(config: SiteConfig): Promise<boolean> {
|
||||
try {
|
||||
const response = await fetch('/api/site', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(config)
|
||||
})
|
||||
return response.ok
|
||||
} catch (error) {
|
||||
console.error('Error updating site config:', error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user