You've already forked bilibili-subtitle
优化字幕复制
This commit is contained in:
@@ -66,6 +66,7 @@ const MoreBtn = (props: Props) => {
|
||||
const [moreVisible, setMoreVisible] = useState(false)
|
||||
const eventBus = useContext(EventBusContext)
|
||||
const segments = useAppSelector(state => state.env.segments)
|
||||
const url = useAppSelector(state => state.env.url)
|
||||
const title = useAppSelector(state => state.env.title)
|
||||
const curSummaryType = useAppSelector(state => state.env.tempData.curSummaryType)
|
||||
|
||||
@@ -76,19 +77,19 @@ const MoreBtn = (props: Props) => {
|
||||
|
||||
let s, fileName
|
||||
if (!downloadType || downloadType === 'text') {
|
||||
s = ''
|
||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
||||
for (const item of data.body) {
|
||||
s += item.content + '\n'
|
||||
}
|
||||
fileName = 'download.txt'
|
||||
} else if (downloadType === 'textWithTime') {
|
||||
s = ''
|
||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
||||
for (const item of data.body) {
|
||||
s += formatTime(item.from) + ' ' + item.content + '\n'
|
||||
}
|
||||
fileName = 'download.txt'
|
||||
} else if (downloadType === 'article') {
|
||||
s = ''
|
||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
||||
for (const item of data.body) {
|
||||
s += item.content + ', '
|
||||
}
|
||||
@@ -138,9 +139,10 @@ const MoreBtn = (props: Props) => {
|
||||
s = JSON.stringify(data)
|
||||
fileName = 'download.json'
|
||||
} else if (downloadType === 'summarize') {
|
||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
||||
const [success, content] = getSummarize(title, segments, curSummaryType)
|
||||
if (!success) return
|
||||
s = content
|
||||
s += content
|
||||
fileName = '总结.txt'
|
||||
} else {
|
||||
return
|
||||
@@ -153,7 +155,7 @@ const MoreBtn = (props: Props) => {
|
||||
}).catch(console.error)
|
||||
}
|
||||
setMoreVisible(false)
|
||||
}, [curSummaryType, data, downloadType, segments, title])
|
||||
}, [curSummaryType, data, downloadType, segments, title, url])
|
||||
|
||||
const downloadAudioCallback = useCallback(() => {
|
||||
window.parent.postMessage({
|
||||
|
@@ -102,6 +102,7 @@ const refreshVideoInfo = async () => {
|
||||
//send setVideoInfo
|
||||
iframe.contentWindow.postMessage({
|
||||
type: 'setVideoInfo',
|
||||
url: location.origin + location.pathname,
|
||||
title,
|
||||
aid,
|
||||
pages,
|
||||
|
@@ -12,6 +12,7 @@ import {
|
||||
setSegments,
|
||||
setTitle,
|
||||
setTotalHeight,
|
||||
setUrl,
|
||||
} from '../redux/envReducer'
|
||||
import {EventBusContext} from '../Router'
|
||||
import {
|
||||
@@ -55,6 +56,7 @@ const useSubtitleService = () => {
|
||||
|
||||
if (data.type === 'setVideoInfo') {
|
||||
dispatch(setInfos(data.infos))
|
||||
dispatch(setUrl(data.url))
|
||||
dispatch(setTitle(data.title))
|
||||
console.debug('video title: ', data.title)
|
||||
}
|
||||
@@ -86,7 +88,6 @@ const useSubtitleService = () => {
|
||||
if (data.data.totalHeight) {
|
||||
dispatch(setTotalHeight(Math.min(Math.max(data.data.totalHeight, TOTAL_HEIGHT_MIN), TOTAL_HEIGHT_MAX)))
|
||||
}
|
||||
console.debug('setSettings', data.data)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -30,6 +30,7 @@ interface EnvState {
|
||||
data?: Transcript
|
||||
uploadedTranscript?: Transcript
|
||||
segments?: Segment[]
|
||||
url?: string
|
||||
title?: string
|
||||
|
||||
taskIds?: string[]
|
||||
@@ -260,6 +261,9 @@ export const slice = createSlice({
|
||||
setCurrentTime: (state, action: PayloadAction<number | undefined>) => {
|
||||
state.currentTime = action.payload
|
||||
},
|
||||
setUrl: (state, action: PayloadAction<string | undefined>) => {
|
||||
state.url = action.payload
|
||||
},
|
||||
setTitle: (state, action: PayloadAction<string | undefined>) => {
|
||||
state.title = action.payload
|
||||
},
|
||||
@@ -288,6 +292,7 @@ export const slice = createSlice({
|
||||
})
|
||||
|
||||
export const {
|
||||
setUrl,
|
||||
setAskFold,
|
||||
setAskQuestion,
|
||||
setAskStatus,
|
||||
|
Reference in New Issue
Block a user