Skip to content

Commit

Permalink
modify
Browse files Browse the repository at this point in the history
  • Loading branch information
veasion committed Aug 14, 2024
1 parent 8ce82bf commit 704191f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ <h1>🤖 AI智能生成PPT演示文稿</h1>
var pptxObj = null
var selectIdx = 0
var mTimer = null
var gening = false

var markdownRenderer = new marked.Renderer()
marked.setOptions({
Expand All @@ -244,7 +245,6 @@ <h1>🤖 AI智能生成PPT演示文稿</h1>
painter.setMode('edit')

function generateOutline() {
outline = ''
let subject = document.getElementById('subject').value
if (!subject) {
alert('请输入主题')
Expand All @@ -254,6 +254,11 @@ <h1>🤖 AI智能生成PPT演示文稿</h1>
alert('主题太短')
return
}
if (gening) {
return
}
outline = ''
gening = true
const url = 'https://docmee.cn/api/public/ppt/generateOutline?apiKey=' + apiKey
var source = new SSE(url, {
method: 'POST',
Expand All @@ -267,6 +272,7 @@ <h1>🤖 AI智能生成PPT演示文稿</h1>
source.onmessage = function (data) {
let json = JSON.parse(data.data)
if (json.status == -1) {
gening = false
alert('生成大纲异常:' + json.error)
return
}
Expand All @@ -275,6 +281,7 @@ <h1>🤖 AI智能生成PPT演示文稿</h1>
window.scrollTo({ behavior: 'smooth', top: document.body.scrollHeight })
}
source.onend = function (data) {
gening = false
if (data.data.startsWith('{') && data.data.endsWith('}')) {
const json = JSON.parse(data.data)
if (json.code != 0) {
Expand All @@ -286,6 +293,7 @@ <h1>🤖 AI智能生成PPT演示文稿</h1>
window.scrollTo(0, 0)
}
source.onerror = function (err) {
gening = false
console.error('生成大纲异常', err)
alert('生成大纲异常')
}
Expand Down

0 comments on commit 704191f

Please sign in to comment.