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

View File

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

View File

@@ -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('复制成功')