CatPtain's picture
Upload index.ts
95807d6 verified
raw
history blame
2.71 kB
import axios from './config'
// export const SERVER_URL = 'http://localhost:5000'
export const SERVER_URL = (import.meta.env.MODE === 'development') ? '/api' : '/api'
export const ASSET_URL = '/data' // 修改为本地路径
export default {
getMockData(filename: string): Promise<any> {
return axios.get(`./mocks/${filename}.json`)
},
getFileData(filename: string): Promise<any> {
return axios.get(`${ASSET_URL}/${filename}.json`)
},
AIPPT_Outline(
content: string,
language: string,
model: string,
): Promise<any> {
return fetch(`${SERVER_URL}/tools/aippt_outline`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
content,
language,
model,
stream: true,
}),
})
},
AIPPT(
content: string,
language: string,
model: string,
): Promise<any> {
return fetch(`${SERVER_URL}/tools/aippt`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
content,
language,
model,
stream: true,
}),
})
},
// 用户认证
login(username: string, password: string): Promise<any> {
return axios.post(`${SERVER_URL}/auth/login`, { username, password })
},
verifyToken(): Promise<any> {
return axios.get(`${SERVER_URL}/auth/verify`)
},
getUserInfo(): Promise<any> {
return axios.get(`${SERVER_URL}/auth/user`)
},
// PPT管理
getPPTList(): Promise<any> {
return axios.get(`${SERVER_URL}/ppt/list`)
},
getPPT(pptId: string): Promise<any> {
return axios.get(`${SERVER_URL}/ppt/${pptId}`)
},
savePPT(pptData: any): Promise<any> {
return axios.post(`${SERVER_URL}/ppt/save`, pptData)
},
createPPT(title: string): Promise<any> {
return axios.post(`${SERVER_URL}/ppt/create`, { title })
},
deletePPT(pptId: string): Promise<any> {
return axios.delete(`${SERVER_URL}/ppt/${pptId}`)
},
copyPPT(pptId: string, title: string): Promise<any> {
return axios.post(`${SERVER_URL}/ppt/${pptId}/copy`, { title })
},
// 公共分享
generateShareLink(userId: string, pptId: string, slideIndex?: number): Promise<any> {
return axios.post(`${SERVER_URL}/public/generate-share-link`, {
userId,
pptId,
slideIndex
})
},
getPublicPPT(userId: string, pptId: string): Promise<any> {
return axios.get(`${SERVER_URL}/public/ppt/${userId}/${pptId}`)
},
getPublicSlide(userId: string, pptId: string, slideIndex: number): Promise<any> {
return axios.get(`${SERVER_URL}/public/view/${userId}/${pptId}/${slideIndex}`)
}
}