index.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import axios from './config'
  2. // export const SERVER_URL = 'http://localhost:5000'
  3. export const SERVER_URL = (import.meta.env.MODE === 'development') ? '/api' : 'https://server.pptist.cn'
  4. export const ASSET_URL = 'https://asset.pptist.cn'
  5. export const API_URL = 'https://pbl.cocorobo.cn/api/pbl/'
  6. interface AIPPTOutlinePayload {
  7. content: string
  8. language: string
  9. model: string
  10. }
  11. interface AIPPTPayload {
  12. content: string
  13. language: string
  14. style: string
  15. model: string
  16. }
  17. interface AIWritingPayload {
  18. content: string
  19. command: string
  20. }
  21. export default {
  22. getMockData(filename: string): Promise<any> {
  23. return axios.get(`./mocks/${filename}.json`)
  24. },
  25. getFileData(filename: string): Promise<any> {
  26. // return axios.get(`${ASSET_URL}/data/${filename}.json`)
  27. return axios.get(`./mocks/${filename}.json`)
  28. },
  29. AIPPT_Outline({
  30. content,
  31. language,
  32. model,
  33. }: AIPPTOutlinePayload): Promise<any> {
  34. return fetch(`${SERVER_URL}/tools/aippt_outline`, {
  35. method: 'POST',
  36. headers: {
  37. 'Content-Type': 'application/json',
  38. },
  39. body: JSON.stringify({
  40. content,
  41. language,
  42. model,
  43. stream: true,
  44. }),
  45. })
  46. },
  47. AIPPT({
  48. content,
  49. language,
  50. style,
  51. model,
  52. }: AIPPTPayload): Promise<any> {
  53. return fetch(`${SERVER_URL}/tools/aippt`, {
  54. method: 'POST',
  55. headers: {
  56. 'Content-Type': 'application/json',
  57. },
  58. body: JSON.stringify({
  59. content,
  60. language,
  61. model,
  62. style,
  63. stream: true,
  64. }),
  65. })
  66. },
  67. AI_Writing({
  68. content,
  69. command,
  70. }: AIWritingPayload): Promise<any> {
  71. return fetch(`${SERVER_URL}/tools/ai_writing`, {
  72. method: 'POST',
  73. headers: {
  74. 'Content-Type': 'application/json',
  75. },
  76. body: JSON.stringify({
  77. content,
  78. command,
  79. stream: true,
  80. }),
  81. })
  82. },
  83. }