You've already forked bilibili-subtitle
优化导出文件名
This commit is contained in:
@@ -75,26 +75,27 @@ const MoreBtn = (props: Props) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let s, fileName
|
let fileName = title
|
||||||
|
let s, suffix
|
||||||
if (!downloadType || downloadType === 'text') {
|
if (!downloadType || downloadType === 'text') {
|
||||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
||||||
for (const item of data.body) {
|
for (const item of data.body) {
|
||||||
s += item.content + '\n'
|
s += item.content + '\n'
|
||||||
}
|
}
|
||||||
fileName = 'download.txt'
|
suffix = 'txt'
|
||||||
} else if (downloadType === 'textWithTime') {
|
} else if (downloadType === 'textWithTime') {
|
||||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
||||||
for (const item of data.body) {
|
for (const item of data.body) {
|
||||||
s += formatTime(item.from) + ' ' + item.content + '\n'
|
s += formatTime(item.from) + ' ' + item.content + '\n'
|
||||||
}
|
}
|
||||||
fileName = 'download.txt'
|
suffix = 'txt'
|
||||||
} else if (downloadType === 'article') {
|
} else if (downloadType === 'article') {
|
||||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
||||||
for (const item of data.body) {
|
for (const item of data.body) {
|
||||||
s += item.content + ', '
|
s += item.content + ', '
|
||||||
}
|
}
|
||||||
s = s.substring(0, s.length - 1) // remove last ','
|
s = s.substring(0, s.length - 1) // remove last ','
|
||||||
fileName = 'download.txt'
|
suffix = 'txt'
|
||||||
} else if (downloadType === 'srt') {
|
} else if (downloadType === 'srt') {
|
||||||
/**
|
/**
|
||||||
* 1
|
* 1
|
||||||
@@ -113,7 +114,7 @@ const MoreBtn = (props: Props) => {
|
|||||||
s += ss
|
s += ss
|
||||||
}
|
}
|
||||||
s = s.substring(0, s.length - 1)// remove last '\n'
|
s = s.substring(0, s.length - 1)// remove last '\n'
|
||||||
fileName = 'download.srt'
|
suffix = 'srt'
|
||||||
} else if (downloadType === 'vtt') {
|
} else if (downloadType === 'vtt') {
|
||||||
/**
|
/**
|
||||||
* WEBVTT title
|
* WEBVTT title
|
||||||
@@ -134,21 +135,22 @@ const MoreBtn = (props: Props) => {
|
|||||||
s += ss
|
s += ss
|
||||||
}
|
}
|
||||||
s = s.substring(0, s.length - 1)// remove last '\n'
|
s = s.substring(0, s.length - 1)// remove last '\n'
|
||||||
fileName = 'download.vtt'
|
suffix = 'vtt'
|
||||||
} else if (downloadType === 'json') {
|
} else if (downloadType === 'json') {
|
||||||
s = JSON.stringify(data)
|
s = JSON.stringify(data)
|
||||||
fileName = 'download.json'
|
suffix = 'json'
|
||||||
} else if (downloadType === 'summarize') {
|
} else if (downloadType === 'summarize') {
|
||||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
||||||
const [success, content] = getSummarize(title, segments, curSummaryType)
|
const [success, content] = getSummarize(title, segments, curSummaryType)
|
||||||
if (!success) return
|
if (!success) return
|
||||||
s += content
|
s += content
|
||||||
fileName = '总结.txt'
|
fileName += ' - 总结'
|
||||||
|
suffix = 'txt'
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (download) {
|
if (download) {
|
||||||
downloadText(s, fileName)
|
downloadText(s, fileName+'.'+suffix)
|
||||||
} else {
|
} else {
|
||||||
navigator.clipboard.writeText(s).then(() => {
|
navigator.clipboard.writeText(s).then(() => {
|
||||||
toast.success('复制成功')
|
toast.success('复制成功')
|
||||||
|
Reference in New Issue
Block a user