File size: 2,712 Bytes
89ce340
 
 
 
95807d6
89ce340
 
 
33178be
89ce340
 
 
95807d6
89ce340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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}`)
  }
}