2 Commits

Author SHA1 Message Date
IndieKKY
9320928b34 chore: release 1.10.1 2024-06-18 11:10:27 +08:00
IndieKKY
1fbdeaa8f6 优化导出文件名 2024-06-18 10:57:20 +08:00
3 changed files with 13 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "哔哩哔哩字幕列表",
"description": "显示B站视频的字幕列表,可点击跳转与下载字幕,并支持翻译和总结字幕!",
"version": "1.10.0",
"version": "1.10.1",
"manifest_version": 3,
"permissions": [
"storage"

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "bilibili-subtitle",
"version": "1.10.0",
"version": "1.10.1",
"type": "module",
"description": "哔哩哔哩字幕列表",
"main": "index.js",

View File

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