Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0a6bda667e | ||
![]() |
5a0a123af9 | ||
![]() |
b481b8a55a | ||
![]() |
3cede8650d | ||
![]() |
69e0497081 | ||
![]() |
8776186486 | ||
![]() |
d31c2d7b03 | ||
![]() |
1c5534fc82 | ||
![]() |
44895a98a6 | ||
![]() |
53d3522fd6 | ||
![]() |
56bb936aaa | ||
![]() |
d52a4e8378 | ||
![]() |
f69bc7f040 |
@@ -1,3 +1 @@
|
|||||||
VITE_ENV=web-dev
|
VITE_ENV=web-dev
|
||||||
|
|
||||||
VITE_EXTENSION_ID=nejipfbcnfhckfpmlgibfommbnahchko
|
|
@@ -1,4 +1,3 @@
|
|||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
VITE_ENV=chrome
|
VITE_ENV=chrome
|
||||||
VITE_EXTENSION_ID=bciglihaegkdhoogebcdblfhppoilclp
|
|
@@ -65,7 +65,3 @@ node版本:18.15.0
|
|||||||
## 许可证
|
## 许可证
|
||||||
|
|
||||||
该项目采用 **MIT 许可证**,详情请参阅许可证文件。
|
该项目采用 **MIT 许可证**,详情请参阅许可证文件。
|
||||||
|
|
||||||
## 截图
|
|
||||||
|
|
||||||

|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh" data-theme="light">
|
<html lang="zh" data-theme="light">
|
||||||
<head>
|
<head>
|
||||||
<title>bilibili-subtitle - 哔哩哔哩字幕</title>
|
<title>哔哔君 - 哔哩哔哩字幕列表</title>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
<link rel="icon" href="/favicon-128x128.png" sizes="128x128">
|
<link rel="icon" href="/favicon-128x128.png" sizes="128x128">
|
||||||
|
@@ -12,7 +12,7 @@ const [major, minor, patch, label = '0'] = version
|
|||||||
.split(/[.-]/)
|
.split(/[.-]/)
|
||||||
|
|
||||||
export default defineManifest(async (env) => ({
|
export default defineManifest(async (env) => ({
|
||||||
"name": "哔哩哔哩字幕列表",
|
"name": "哔哔君 - 哔哩哔哩字幕列表",
|
||||||
"description": "显示B站视频的字幕列表,可点击跳转与下载字幕,并支持翻译和总结字幕!",
|
"description": "显示B站视频的字幕列表,可点击跳转与下载字幕,并支持翻译和总结字幕!",
|
||||||
"version": `${major}.${minor}.${patch}`,
|
"version": `${major}.${minor}.${patch}`,
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" data-theme="light">
|
<html lang="en" data-theme="light">
|
||||||
<head>
|
<head>
|
||||||
<title>哔哩哔哩字幕列表选项</title>
|
<title>哔哔君 - 哔哩哔哩字幕列表选项</title>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
<link rel="icon" href="/favicon-16x16.png" sizes="16x16">
|
<link rel="icon" href="/favicon-16x16.png" sizes="16x16">
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "bilibili-subtitle",
|
"name": "bilibili-subtitle",
|
||||||
"version": "1.11.1",
|
"version": "1.11.6",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "哔哩哔哩字幕列表",
|
"description": "哔哩哔哩字幕列表",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
"ahooks": "^3.7.1",
|
"ahooks": "^3.7.1",
|
||||||
"classnames": "^2.3.2",
|
"classnames": "^2.3.2",
|
||||||
"daisyui": "^2.42.1",
|
"daisyui": "^2.42.1",
|
||||||
|
"dayjs": "^1.11.13",
|
||||||
"js-search": "^2.0.0",
|
"js-search": "^2.0.0",
|
||||||
"less": "^4.1.3",
|
"less": "^4.1.3",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
|
13
pnpm-lock.yaml
generated
@@ -41,6 +41,9 @@ importers:
|
|||||||
daisyui:
|
daisyui:
|
||||||
specifier: ^2.42.1
|
specifier: ^2.42.1
|
||||||
version: 2.42.1(autoprefixer@10.4.13(postcss@8.4.19))(postcss@8.4.19)
|
version: 2.42.1(autoprefixer@10.4.13(postcss@8.4.19))(postcss@8.4.19)
|
||||||
|
dayjs:
|
||||||
|
specifier: ^1.11.13
|
||||||
|
version: 1.11.13
|
||||||
js-search:
|
js-search:
|
||||||
specifier: ^2.0.0
|
specifier: ^2.0.0
|
||||||
version: 2.0.0
|
version: 2.0.0
|
||||||
@@ -856,8 +859,8 @@ packages:
|
|||||||
autoprefixer: ^10.0.2
|
autoprefixer: ^10.0.2
|
||||||
postcss: ^8.1.6
|
postcss: ^8.1.6
|
||||||
|
|
||||||
dayjs@1.11.5:
|
dayjs@1.11.13:
|
||||||
resolution: {integrity: sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA==}
|
resolution: {integrity: sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==}
|
||||||
|
|
||||||
debug@2.6.9:
|
debug@2.6.9:
|
||||||
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
||||||
@@ -3114,7 +3117,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@types/js-cookie': 2.2.7
|
'@types/js-cookie': 2.2.7
|
||||||
ahooks-v3-count: 1.0.0
|
ahooks-v3-count: 1.0.0
|
||||||
dayjs: 1.11.5
|
dayjs: 1.11.13
|
||||||
intersection-observer: 0.12.2
|
intersection-observer: 0.12.2
|
||||||
js-cookie: 2.2.1
|
js-cookie: 2.2.1
|
||||||
lodash: 4.17.21
|
lodash: 4.17.21
|
||||||
@@ -3126,7 +3129,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@types/js-cookie': 2.2.7
|
'@types/js-cookie': 2.2.7
|
||||||
ahooks-v3-count: 1.0.0
|
ahooks-v3-count: 1.0.0
|
||||||
dayjs: 1.11.5
|
dayjs: 1.11.13
|
||||||
intersection-observer: 0.12.2
|
intersection-observer: 0.12.2
|
||||||
js-cookie: 2.2.1
|
js-cookie: 2.2.1
|
||||||
lodash: 4.17.21
|
lodash: 4.17.21
|
||||||
@@ -3385,7 +3388,7 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- ts-node
|
- ts-node
|
||||||
|
|
||||||
dayjs@1.11.5: {}
|
dayjs@1.11.13: {}
|
||||||
|
|
||||||
debug@2.6.9:
|
debug@2.6.9:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
11
popup.html
@@ -1,11 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="zh" style="width: 500px;">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<img src="shot.jpg" style="width: 100%; object-fit: contain;"/>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
BIN
public/bibijun.png
Normal file
After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 278 B After Width: | Height: | Size: 651 B |
Before Width: | Height: | Size: 363 B After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 400 B After Width: | Height: | Size: 2.4 KiB |
BIN
public/favicon-64x64.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 447 B After Width: | Height: | Size: 4.2 KiB |
BIN
public/shot.jpg
Before Width: | Height: | Size: 50 KiB |
@@ -1,3 +0,0 @@
|
|||||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg t="1672795365953" class="icon" viewBox="0 0 1303 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2585"
|
|
||||||
width="254.4921875" height="200"><path d="M110.964364 1023.720727c-60.509091 0-109.847273-48.872727-109.847273-108.916363V109.009455C1.117091 48.965818 50.455273 0 110.964364 0h1081.902545c60.509091 0 109.847273 48.872727 109.847273 108.916364v805.794909c0 60.043636-49.338182 108.916364-109.847273 108.916363H110.964364z m0-927.650909c-6.609455 0-12.101818 5.771636-12.101819 12.939637v805.794909c0 7.168 5.492364 13.032727 12.101819 13.032727h1081.902545c6.609455 0 12.101818-5.864727 12.101818-13.032727V109.009455c0-7.168-5.492364-13.032727-12.101818-13.032728H110.964364z" fill="#00AEEC" p-id="2586"></path><path d="M1003.054545 520.098909a51.572364 51.572364 0 0 1-50.26909 52.689455h-80.058182a51.572364 51.572364 0 0 1-50.269091-52.689455c0-29.137455 22.434909-52.782545 50.269091-52.782545h80.058182c27.834182 0 50.269091 23.645091 50.26909 52.782545zM1096.610909 270.149818c0 28.858182-22.341818 52.410182-49.989818 52.410182H232.541091a51.293091 51.293091 0 0 1-50.082909-52.410182c0-29.044364 22.434909-52.503273 50.082909-52.503273h814.08c27.648 0 50.082909 23.458909 50.082909 52.503273zM768.744727 520.098909c0 28.858182-22.341818 52.410182-50.082909 52.410182H232.541091a51.293091 51.293091 0 0 1-50.082909-52.410182c0-29.044364 22.434909-52.503273 50.082909-52.503273H718.661818c27.648 0 50.082909 23.458909 50.082909 52.503273zM1096.610909 735.976727c0 29.044364-22.341818 52.503273-49.989818 52.503273H560.500364a51.293091 51.293091 0 0 1-50.082909-52.503273c0-28.951273 22.341818-52.410182 50.082909-52.410182h486.120727c27.648 0 50.082909 23.458909 50.082909 52.410182z" fill="#00AEEC" p-id="2587"></path></svg>
|
|
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 280 KiB |
Before Width: | Height: | Size: 867 KiB |
Before Width: | Height: | Size: 333 KiB |
Before Width: | Height: | Size: 413 KiB |
Before Width: | Height: | Size: 280 KiB |
@@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh" data-theme="light">
|
<html lang="zh" data-theme="light">
|
||||||
<head>
|
<head>
|
||||||
<title>哔哩哔哩字幕列表</title>
|
<title>哔哔君 - 哔哩哔哩字幕列表</title>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
<link rel="icon" href="/favicon-128x128.png" sizes="128x128">
|
<link rel="icon" href="/favicon-128x128.png" sizes="128x128">
|
||||||
|
43
src/components/DebateChat.tsx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { useAppSelector } from '@/hooks/redux';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
const DebateChat: React.FC<DebateProps> = ({ messages }) => {
|
||||||
|
const fontSize = useAppSelector(state => state.env.envData.fontSize)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col h-full">
|
||||||
|
<div className="flex-1 overflow-y-auto p-4">
|
||||||
|
{messages.map((message, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
className={`flex mb-4 ${
|
||||||
|
message.side === 'pro' ? 'justify-start' : 'justify-end'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={`max-w-[85%] rounded-2xl p-3 shadow-md relative ${
|
||||||
|
message.side === 'pro'
|
||||||
|
? 'bg-blue-100 text-blue-800 ml-2'
|
||||||
|
: 'bg-green-100 text-green-800 mr-2'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<p className={`${fontSize === 'large' ? 'text-sm' : 'text-xs'} font-bold mb-1`}>
|
||||||
|
{message.side === 'pro' ? '正方' : '反方'}
|
||||||
|
</p>
|
||||||
|
<p className={fontSize === 'large' ? 'text-sm' : 'text-xs'}>{message.content}</p>
|
||||||
|
<div
|
||||||
|
className={`absolute w-4 h-4 ${
|
||||||
|
message.side === 'pro'
|
||||||
|
? 'bg-blue-100 -left-2 top-2 rounded-bl-full'
|
||||||
|
: 'bg-green-100 -right-2 top-2 rounded-br-full'
|
||||||
|
}`}
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DebateChat;
|
@@ -83,7 +83,8 @@ const Header = (props: {
|
|||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<div className='shrink-0 flex items-center'>
|
<div className='shrink-0 flex items-center'>
|
||||||
<span className='shrink-0 text-[15px] font-medium pl-[16px] pr-[14px]'>字幕列表</span>
|
<img src="bibijun.png" alt="Logo" className="w-auto h-6 ml-2 mr-1" />
|
||||||
|
{/* <span className='shrink-0 text-[15px] font-medium pl-1 pr-[14px]'>字幕列表</span> */}
|
||||||
<MoreBtn placement={'right-start'}/>
|
<MoreBtn placement={'right-start'}/>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex gap-0.5 items-center mr-[16px]'>
|
<div className='flex gap-0.5 items-center mr-[16px]'>
|
||||||
|
@@ -19,6 +19,8 @@ import {downloadText, openUrl} from '@kky002/kky-util'
|
|||||||
import toast from 'react-hot-toast'
|
import toast from 'react-hot-toast'
|
||||||
import {getSummarize} from '../utils/bizUtil'
|
import {getSummarize} from '../utils/bizUtil'
|
||||||
import { useMessage } from '@/hooks/message'
|
import { useMessage } from '@/hooks/message'
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
placement: Placement
|
placement: Placement
|
||||||
}
|
}
|
||||||
@@ -68,6 +70,8 @@ const MoreBtn = (props: Props) => {
|
|||||||
const segments = useAppSelector(state => state.env.segments)
|
const segments = useAppSelector(state => state.env.segments)
|
||||||
const url = useAppSelector(state => state.env.url)
|
const url = useAppSelector(state => state.env.url)
|
||||||
const title = useAppSelector(state => state.env.title)
|
const title = useAppSelector(state => state.env.title)
|
||||||
|
const ctime = useAppSelector(state => state.env.ctime) //时间戳,单位s
|
||||||
|
const author = useAppSelector(state => state.env.author)
|
||||||
const curSummaryType = useAppSelector(state => state.env.tempData.curSummaryType)
|
const curSummaryType = useAppSelector(state => state.env.tempData.curSummaryType)
|
||||||
|
|
||||||
const {sendInject} = useMessage()
|
const {sendInject} = useMessage()
|
||||||
@@ -79,20 +83,21 @@ const MoreBtn = (props: Props) => {
|
|||||||
|
|
||||||
let fileName = title
|
let fileName = title
|
||||||
let s, suffix
|
let s, suffix
|
||||||
|
let time = ctime ? dayjs(ctime * 1000).format('YYYY-MM-DD HH:mm:ss') : '' // 2024-05-01 12:00:00
|
||||||
if (!downloadType || downloadType === 'text') {
|
if (!downloadType || downloadType === 'text') {
|
||||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
s = `${title??'无标题'}\n${url??'无链接'}\n${author??'无作者'} ${time}\n\n`
|
||||||
for (const item of data.body) {
|
for (const item of data.body) {
|
||||||
s += item.content + '\n'
|
s += item.content + '\n'
|
||||||
}
|
}
|
||||||
suffix = 'txt'
|
suffix = 'txt'
|
||||||
} else if (downloadType === 'textWithTime') {
|
} else if (downloadType === 'textWithTime') {
|
||||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
s = `${title??'无标题'}\n${url??'无链接'}\n${author??'无作者'} ${time}\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'
|
||||||
}
|
}
|
||||||
suffix = 'txt'
|
suffix = 'txt'
|
||||||
} else if (downloadType === 'article') {
|
} else if (downloadType === 'article') {
|
||||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
s = `${title??'无标题'}\n${url??'无链接'}\n${author??'无作者'} ${time}\n\n`
|
||||||
for (const item of data.body) {
|
for (const item of data.body) {
|
||||||
s += item.content + ', '
|
s += item.content + ', '
|
||||||
}
|
}
|
||||||
@@ -142,7 +147,7 @@ const MoreBtn = (props: Props) => {
|
|||||||
s = JSON.stringify(data)
|
s = JSON.stringify(data)
|
||||||
suffix = 'json'
|
suffix = 'json'
|
||||||
} else if (downloadType === 'summarize') {
|
} else if (downloadType === 'summarize') {
|
||||||
s = `${title??'无标题'}\n${url??'无链接'}\n\n`
|
s = `${title??'无标题'}\n${url??'无链接'}\n${author??'无作者'} ${time}\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
|
||||||
@@ -245,7 +250,7 @@ const MoreBtn = (props: Props) => {
|
|||||||
下载音频(m4s)
|
下载音频(m4s)
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li className='hover:bg-accent'>
|
{/* <li className='hover:bg-accent'>
|
||||||
<a className='flex items-center' onClick={(e) => {
|
<a className='flex items-center' onClick={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
@@ -264,7 +269,7 @@ const MoreBtn = (props: Props) => {
|
|||||||
<AiFillWechat className='w-[20px] h-[20px] text-primary/75 bg-white rounded-sm p-0.5'/>
|
<AiFillWechat className='w-[20px] h-[20px] text-primary/75 bg-white rounded-sm p-0.5'/>
|
||||||
微信公众号(IndieKKY)
|
微信公众号(IndieKKY)
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li> */}
|
||||||
{/* <li className='hover:bg-accent'> */}
|
{/* <li className='hover:bg-accent'> */}
|
||||||
{/* <a className='flex items-center' onClick={(e) => { */}
|
{/* <a className='flex items-center' onClick={(e) => { */}
|
||||||
{/* e.preventDefault() */}
|
{/* e.preventDefault() */}
|
||||||
@@ -297,6 +302,17 @@ const MoreBtn = (props: Props) => {
|
|||||||
选项
|
选项
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{/* 官网 */}
|
||||||
|
<li className='hover:bg-accent'>
|
||||||
|
<a className='flex items-center' onClick={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
openUrl('https://www.bibijun.cc')
|
||||||
|
}}>
|
||||||
|
<img alt='哔哔君' src='/favicon-128x128.png' className='w-[20px] h-[20px] bg-white rounded-sm p-0.5'/>
|
||||||
|
🏠 哔哔君官网
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</Popover>}
|
</Popover>}
|
||||||
</>
|
</>
|
||||||
|
@@ -2,7 +2,7 @@ import React, {MutableRefObject, useCallback, useEffect, useMemo, useRef} from '
|
|||||||
import {useAppDispatch, useAppSelector} from '../hooks/redux'
|
import {useAppDispatch, useAppSelector} from '../hooks/redux'
|
||||||
import {setFloatKeyPointsSegIdx, setSegmentFold, setTempData} from '../redux/envReducer'
|
import {setFloatKeyPointsSegIdx, setSegmentFold, setTempData} from '../redux/envReducer'
|
||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
import {FaClipboardList} from 'react-icons/fa'
|
import {FaClipboardList, FaComments} from 'react-icons/fa'
|
||||||
import {PAGE_MAIN, PAGE_SETTINGS, SUMMARIZE_THRESHOLD, SUMMARIZE_TYPES} from '../consts/const'
|
import {PAGE_MAIN, PAGE_SETTINGS, SUMMARIZE_THRESHOLD, SUMMARIZE_TYPES} from '../consts/const'
|
||||||
import useTranslate from '../hooks/useTranslate'
|
import useTranslate from '../hooks/useTranslate'
|
||||||
import {BsDashSquare, BsPlusSquare, CgFileDocument, FaQuestion, GrOverview, RiFileCopy2Line} from 'react-icons/all'
|
import {BsDashSquare, BsPlusSquare, CgFileDocument, FaQuestion, GrOverview, RiFileCopy2Line} from 'react-icons/all'
|
||||||
@@ -12,6 +12,7 @@ import {useInViewport} from 'ahooks'
|
|||||||
import SegmentItem from './SegmentItem'
|
import SegmentItem from './SegmentItem'
|
||||||
import {stopPopFunc} from '../utils/util'
|
import {stopPopFunc} from '../utils/util'
|
||||||
import useSubtitle from '../hooks/useSubtitle'
|
import useSubtitle from '../hooks/useSubtitle'
|
||||||
|
import DebateChat from './DebateChat'
|
||||||
|
|
||||||
const SummarizeItemOverview = (props: {
|
const SummarizeItemOverview = (props: {
|
||||||
segment: Segment
|
segment: Segment
|
||||||
@@ -113,6 +114,8 @@ const Summarize = (props: {
|
|||||||
<div className={classNames('font-normal', fontSize === 'large' ? 'text-sm' : 'text-xs')}>{question.a}</div>
|
<div className={classNames('font-normal', fontSize === 'large' ? 'text-sm' : 'text-xs')}>{question.a}</div>
|
||||||
</div>)}
|
</div>)}
|
||||||
</div>}
|
</div>}
|
||||||
|
{summary?.type === 'debate' && (summary.content != null) &&
|
||||||
|
<DebateChat messages={summary.content} />}
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-col justify-center items-center'>
|
<div className='flex flex-col justify-center items-center'>
|
||||||
{segment.text.length < SUMMARIZE_THRESHOLD && <div className='desc-lighter text-xs'>文字过短,无法总结.</div>}
|
{segment.text.length < SUMMARIZE_THRESHOLD && <div className='desc-lighter text-xs'>文字过短,无法总结.</div>}
|
||||||
@@ -200,6 +203,12 @@ const SegmentCard = (props: {
|
|||||||
}))
|
}))
|
||||||
}, [dispatch])
|
}, [dispatch])
|
||||||
|
|
||||||
|
const onSelDebate = useCallback(() => {
|
||||||
|
dispatch(setTempData({
|
||||||
|
curSummaryType: 'debate'
|
||||||
|
}))
|
||||||
|
}, [dispatch])
|
||||||
|
|
||||||
return <div
|
return <div
|
||||||
className={classNames('border border-base-300 bg-base-200/25 rounded flex flex-col m-1.5 p-1.5 gap-1 shadow', showCurrent && 'shadow-primary')}>
|
className={classNames('border border-base-300 bg-base-200/25 rounded flex flex-col m-1.5 p-1.5 gap-1 shadow', showCurrent && 'shadow-primary')}>
|
||||||
<div className='relative flex justify-center min-h-[20px]'>
|
<div className='relative flex justify-center min-h-[20px]'>
|
||||||
@@ -215,6 +224,7 @@ const SegmentCard = (props: {
|
|||||||
<a className={classNames('tab tab-lifted tab-xs', curSummaryType === 'overview' && 'tab-active')} onClick={onSelOverview}><GrOverview/>概览</a>
|
<a className={classNames('tab tab-lifted tab-xs', curSummaryType === 'overview' && 'tab-active')} onClick={onSelOverview}><GrOverview/>概览</a>
|
||||||
<a className={classNames('tab tab-lifted tab-xs', curSummaryType === 'keypoint' && 'tab-active')} onClick={onSelKeypoint}><FaClipboardList/>要点</a>
|
<a className={classNames('tab tab-lifted tab-xs', curSummaryType === 'keypoint' && 'tab-active')} onClick={onSelKeypoint}><FaClipboardList/>要点</a>
|
||||||
<a className={classNames('tab tab-lifted tab-xs', curSummaryType === 'question' && 'tab-active')} onClick={onSelQuestion}><FaQuestion/>问题</a>
|
<a className={classNames('tab tab-lifted tab-xs', curSummaryType === 'question' && 'tab-active')} onClick={onSelQuestion}><FaQuestion/>问题</a>
|
||||||
|
<a className={classNames('tab tab-lifted tab-xs', curSummaryType === 'debate' && 'tab-active')} onClick={onSelDebate}><FaComments/>辩论</a>
|
||||||
<a className="tab tab-lifted tab-xs tab-disabled cursor-default"></a>
|
<a className="tab tab-lifted tab-xs tab-disabled cursor-default"></a>
|
||||||
</div>}
|
</div>}
|
||||||
<div
|
<div
|
||||||
|
@@ -11,6 +11,7 @@ export const PROMPT_TYPE_TRANSLATE = 'translate'
|
|||||||
export const PROMPT_TYPE_SUMMARIZE_OVERVIEW = 'summarize_overview'
|
export const PROMPT_TYPE_SUMMARIZE_OVERVIEW = 'summarize_overview'
|
||||||
export const PROMPT_TYPE_SUMMARIZE_KEYPOINT = 'summarize_keypoint'
|
export const PROMPT_TYPE_SUMMARIZE_KEYPOINT = 'summarize_keypoint'
|
||||||
export const PROMPT_TYPE_SUMMARIZE_QUESTION = 'summarize_question'
|
export const PROMPT_TYPE_SUMMARIZE_QUESTION = 'summarize_question'
|
||||||
|
export const PROMPT_TYPE_SUMMARIZE_DEBATE = 'summarize_debate'
|
||||||
export const PROMPT_TYPE_SUMMARIZE_BRIEF = 'summarize_brief'
|
export const PROMPT_TYPE_SUMMARIZE_BRIEF = 'summarize_brief'
|
||||||
export const PROMPT_TYPE_ASK = 'ask'
|
export const PROMPT_TYPE_ASK = 'ask'
|
||||||
export const PROMPT_TYPES = [{
|
export const PROMPT_TYPES = [{
|
||||||
@@ -28,6 +29,9 @@ export const PROMPT_TYPES = [{
|
|||||||
}, {
|
}, {
|
||||||
name: '问题',
|
name: '问题',
|
||||||
type: PROMPT_TYPE_SUMMARIZE_QUESTION,
|
type: PROMPT_TYPE_SUMMARIZE_QUESTION,
|
||||||
|
}, {
|
||||||
|
name: '辩论',
|
||||||
|
type: PROMPT_TYPE_SUMMARIZE_DEBATE,
|
||||||
}, {
|
}, {
|
||||||
name: '提问',
|
name: '提问',
|
||||||
type: PROMPT_TYPE_ASK,
|
type: PROMPT_TYPE_ASK,
|
||||||
@@ -58,6 +62,12 @@ export const SUMMARIZE_TYPES = {
|
|||||||
downloadName: '💡常见问题💡',
|
downloadName: '💡常见问题💡',
|
||||||
promptType: PROMPT_TYPE_SUMMARIZE_QUESTION,
|
promptType: PROMPT_TYPE_SUMMARIZE_QUESTION,
|
||||||
},
|
},
|
||||||
|
debate: {
|
||||||
|
name: '辩论',
|
||||||
|
desc: '辩论',
|
||||||
|
downloadName: '💡辩论💡',
|
||||||
|
promptType: PROMPT_TYPE_SUMMARIZE_DEBATE,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PROMPT_DEFAULTS = {
|
export const PROMPT_DEFAULTS = {
|
||||||
@@ -175,6 +185,42 @@ Provide an example to illustrate the expected output:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
`,
|
||||||
|
[PROMPT_TYPE_SUMMARIZE_DEBATE]: `You are a helpful assistant skilled at generating debates based on video subtitles.
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
The video's title: '''{{title}}'''.
|
||||||
|
The video's subtitles:
|
||||||
|
|
||||||
|
'''
|
||||||
|
{{segment}}
|
||||||
|
'''
|
||||||
|
|
||||||
|
## Command
|
||||||
|
|
||||||
|
Please play the roles of both the affirmative and negative sides to discuss the author's viewpoint.
|
||||||
|
The conversation should consist of 10 rounds(5 sentences from the affirmative side, 5 sentences from the negative side.).
|
||||||
|
The tone should be straightforward.
|
||||||
|
|
||||||
|
Answer in language '{{language}}'.
|
||||||
|
|
||||||
|
## Output format
|
||||||
|
|
||||||
|
Provide an example to illustrate the expected output:
|
||||||
|
|
||||||
|
\`\`\`json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"side": "pro",
|
||||||
|
"content": "xxx"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"side": "con",
|
||||||
|
"content": "xxx"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
\`\`\`
|
||||||
`,
|
`,
|
||||||
[PROMPT_TYPE_ASK]: `You are a helpful assistant who answers question related to video subtitles.
|
[PROMPT_TYPE_ASK]: `You are a helpful assistant who answers question related to video subtitles.
|
||||||
Answer in language '{{language}}'.
|
Answer in language '{{language}}'.
|
||||||
@@ -245,6 +291,9 @@ for (const model of MODELS) {
|
|||||||
export const LANGUAGES = [{
|
export const LANGUAGES = [{
|
||||||
code: 'en',
|
code: 'en',
|
||||||
name: 'English',
|
name: 'English',
|
||||||
|
}, {
|
||||||
|
code: 'ja',
|
||||||
|
name: '日本語',
|
||||||
}, {
|
}, {
|
||||||
code: 'ena',
|
code: 'ena',
|
||||||
name: 'American English',
|
name: 'American English',
|
||||||
@@ -278,6 +327,39 @@ export const LANGUAGES = [{
|
|||||||
}, {
|
}, {
|
||||||
code: 'Italian',
|
code: 'Italian',
|
||||||
name: 'Italiano',
|
name: 'Italiano',
|
||||||
|
}, {
|
||||||
|
code: 'ko',
|
||||||
|
name: '한국어',
|
||||||
|
}, {
|
||||||
|
code: 'hi',
|
||||||
|
name: 'हिन्दी',
|
||||||
|
}, {
|
||||||
|
code: 'tr',
|
||||||
|
name: 'Türkçe',
|
||||||
|
}, {
|
||||||
|
code: 'nl',
|
||||||
|
name: 'Nederlands',
|
||||||
|
}, {
|
||||||
|
code: 'pl',
|
||||||
|
name: 'Polski',
|
||||||
|
}, {
|
||||||
|
code: 'sv',
|
||||||
|
name: 'Svenska',
|
||||||
|
}, {
|
||||||
|
code: 'vi',
|
||||||
|
name: 'Tiếng Việt',
|
||||||
|
}, {
|
||||||
|
code: 'th',
|
||||||
|
name: 'ไทย',
|
||||||
|
}, {
|
||||||
|
code: 'id',
|
||||||
|
name: 'Bahasa Indonesia',
|
||||||
|
}, {
|
||||||
|
code: 'el',
|
||||||
|
name: 'Ελληνικά',
|
||||||
|
}, {
|
||||||
|
code: 'he',
|
||||||
|
name: 'עברית',
|
||||||
}]
|
}]
|
||||||
export const LANGUAGES_MAP: {[key: string]: typeof LANGUAGES[number]} = {}
|
export const LANGUAGES_MAP: {[key: string]: typeof LANGUAGES[number]} = {}
|
||||||
for (const language of LANGUAGES) {
|
for (const language of LANGUAGES) {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { setCurFetched, setCurInfo, setData, setInfos, setTitle, setUrl } from '@/redux/envReducer'
|
import { setAuthor, setCtime, setCurFetched, setCurInfo, setData, setInfos, setTitle, setUrl } from '@/redux/envReducer'
|
||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { useAppDispatch } from './redux'
|
import { useAppDispatch } from './redux'
|
||||||
import useMessagingService from '@/messaging/layer2/useMessagingService'
|
import useMessagingService from '@/messaging/layer2/useMessagingService'
|
||||||
@@ -20,6 +20,8 @@ const useMessageService = () => {
|
|||||||
dispatch(setInfos(params.infos))
|
dispatch(setInfos(params.infos))
|
||||||
dispatch(setUrl(params.url))
|
dispatch(setUrl(params.url))
|
||||||
dispatch(setTitle(params.title))
|
dispatch(setTitle(params.title))
|
||||||
|
dispatch(setCtime(params.ctime))
|
||||||
|
dispatch(setAuthor(params.author))
|
||||||
console.debug('video title: ', params.title)
|
console.debug('video title: ', params.title)
|
||||||
},
|
},
|
||||||
}), [dispatch])
|
}), [dispatch])
|
||||||
|
@@ -120,6 +120,8 @@ const debug = (...args: any[]) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let aid: number | null = null
|
let aid: number | null = null
|
||||||
|
let ctime: number | null = null
|
||||||
|
let author: string | undefined
|
||||||
let title = ''
|
let title = ''
|
||||||
let pages: any[] = []
|
let pages: any[] = []
|
||||||
let pagesMap: Record<string, any> = {}
|
let pagesMap: Record<string, any> = {}
|
||||||
@@ -162,6 +164,8 @@ const debug = (...args: any[]) => {
|
|||||||
aid = parseInt(aidOrBvid.slice(2))
|
aid = parseInt(aidOrBvid.slice(2))
|
||||||
pages = await fetch(`https://api.bilibili.com/x/player/pagelist?aid=${aid}`, { credentials: 'include' }).then(res => res.json()).then(res => res.data)
|
pages = await fetch(`https://api.bilibili.com/x/player/pagelist?aid=${aid}`, { credentials: 'include' }).then(res => res.json()).then(res => res.data)
|
||||||
cid = pages[0].cid
|
cid = pages[0].cid
|
||||||
|
ctime = pages[0].ctime
|
||||||
|
author = pages[0].owner?.name
|
||||||
title = pages[0].part
|
title = pages[0].part
|
||||||
await fetch(`https://api.bilibili.com/x/player/v2?aid=${aid}&cid=${cid}`, { credentials: 'include' }).then(res => res.json()).then(res => {
|
await fetch(`https://api.bilibili.com/x/player/v2?aid=${aid}&cid=${cid}`, { credentials: 'include' }).then(res => res.json()).then(res => {
|
||||||
subtitles = res.data.subtitle.subtitles
|
subtitles = res.data.subtitle.subtitles
|
||||||
@@ -171,6 +175,8 @@ const debug = (...args: any[]) => {
|
|||||||
title = res.data.title
|
title = res.data.title
|
||||||
aid = res.data.aid
|
aid = res.data.aid
|
||||||
cid = res.data.cid
|
cid = res.data.cid
|
||||||
|
ctime = res.data.ctime
|
||||||
|
author = res.data.owner?.name
|
||||||
pages = res.data.pages
|
pages = res.data.pages
|
||||||
})
|
})
|
||||||
await fetch(`https://api.bilibili.com/x/player/v2?aid=${aid}&cid=${cid}`, { credentials: 'include' }).then(res => res.json()).then(res => {
|
await fetch(`https://api.bilibili.com/x/player/v2?aid=${aid}&cid=${cid}`, { credentials: 'include' }).then(res => res.json()).then(res => {
|
||||||
@@ -191,6 +197,8 @@ const debug = (...args: any[]) => {
|
|||||||
url: location.origin + location.pathname,
|
url: location.origin + location.pathname,
|
||||||
title,
|
title,
|
||||||
aid,
|
aid,
|
||||||
|
ctime,
|
||||||
|
author,
|
||||||
pages,
|
pages,
|
||||||
infos: subtitles,
|
infos: subtitles,
|
||||||
})
|
})
|
||||||
|
14
src/message-typings.d.ts
vendored
@@ -1,21 +1,19 @@
|
|||||||
//extension
|
//extension
|
||||||
interface ExtensionCloseSidePanelMessage extends ExtensionMessage<{}> {
|
interface ExtensionCloseSidePanelMessage extends ExtensionMessage {
|
||||||
method: 'CLOSE_SIDE_PANEL';
|
method: 'CLOSE_SIDE_PANEL';
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ExtensionAddTaskMessage extends ExtensionMessage<{ taskDef: TaskDef }> {
|
interface ExtensionAddTaskMessage extends ExtensionMessage<{ taskDef: TaskDef }, Task> {
|
||||||
method: 'ADD_TASK';
|
method: 'ADD_TASK';
|
||||||
return: Task
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ExtensionGetTaskMessage extends ExtensionMessage<{ taskId: string }> {
|
interface ExtensionGetTaskMessage extends ExtensionMessage<{ taskId: string }, {
|
||||||
method: 'GET_TASK';
|
|
||||||
return: {
|
|
||||||
code: 'ok'
|
code: 'ok'
|
||||||
task: Task
|
task: Task
|
||||||
} | {
|
} | {
|
||||||
code: 'not_found'
|
code: 'not_found'
|
||||||
}
|
}> {
|
||||||
|
method: 'GET_TASK';
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ExtensionShowFlagMessage extends ExtensionMessage<{ show: boolean }> {
|
interface ExtensionShowFlagMessage extends ExtensionMessage<{ show: boolean }> {
|
||||||
@@ -82,7 +80,7 @@ interface ExtensionCloseSidePanelMessage extends ExtensionMessage<{}> {
|
|||||||
method: 'SET_INFOS';
|
method: 'SET_INFOS';
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AppSetVideoInfoMessage extends AppMessage<{ url: string, title: string, aid: number | null, pages: any, infos: any }> {
|
interface AppSetVideoInfoMessage extends AppMessage<{ url: string, title: string, aid: number | null, ctime: number | null, author?: string, pages: any, infos: any }> {
|
||||||
method: 'SET_VIDEO_INFO';
|
method: 'SET_VIDEO_INFO';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -62,7 +62,7 @@ class InjectMessaging<AllExtensionMessagesType extends ExtensionMessage, AllInje
|
|||||||
[K in AllInjectMessagesType['method']]: (params: Extract<AllInjectMessagesType, { method: K }>['params'], context: MethodContext) => Promise<any>
|
[K in AllInjectMessagesType['method']]: (params: Extract<AllInjectMessagesType, { method: K }>['params'], context: MethodContext) => Promise<any>
|
||||||
}) {
|
}) {
|
||||||
this.methods = methods
|
this.methods = methods
|
||||||
this.port = chrome.runtime.connect(import.meta.env.VITE_EXTENSION_ID, {
|
this.port = chrome.runtime.connect({
|
||||||
name: 'bilibili-inject',
|
name: 'bilibili-inject',
|
||||||
})
|
})
|
||||||
this.l1protocol = new Layer1Protocol<L2ReqMsg, L2ResMsg>(this.messageHandler, this.port)
|
this.l1protocol = new Layer1Protocol<L2ReqMsg, L2ResMsg>(this.messageHandler, this.port)
|
||||||
|
@@ -63,7 +63,7 @@ const useMessagingService = <AllAPPMessagesType extends AppMessage>(methods?: {
|
|||||||
}, [methods])
|
}, [methods])
|
||||||
|
|
||||||
const port = useMemo(() => {
|
const port = useMemo(() => {
|
||||||
return chrome.runtime.connect(import.meta.env.VITE_EXTENSION_ID, {
|
return chrome.runtime.connect({
|
||||||
name: 'bilibili-app',
|
name: 'bilibili-app',
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
6
src/messaging/messaging-typings.d.ts
vendored
@@ -4,13 +4,13 @@ interface Message<T = any, R = any> {
|
|||||||
return: R
|
return: R
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ExtensionMessage<T = any> extends Message<T> {
|
interface ExtensionMessage<T = any, R = any> extends Message<T, R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InjectMessage<T = any> extends Message<T> {
|
interface InjectMessage<T = any, R = any> extends Message<T, R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AppMessage<T = any> extends Message<T> {
|
interface AppMessage<T = any, R = any> extends Message<T, R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -27,17 +27,23 @@ import toast from 'react-hot-toast'
|
|||||||
import {useBoolean, useEventTarget} from 'ahooks'
|
import {useBoolean, useEventTarget} from 'ahooks'
|
||||||
import {useEventChecked} from '@kky002/kky-hooks'
|
import {useEventChecked} from '@kky002/kky-hooks'
|
||||||
import { useMessage } from '@/hooks/message'
|
import { useMessage } from '@/hooks/message'
|
||||||
|
import { FaChevronDown, FaChevronUp } from 'react-icons/fa'
|
||||||
|
|
||||||
const Section = (props: {
|
const OptionCard = ({ title, children, defaultExpanded = true }: { title: React.ReactNode; children: React.ReactNode; defaultExpanded?: boolean }) => {
|
||||||
title: ShowElement
|
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
|
||||||
htmlFor?: string
|
|
||||||
} & PropsWithChildren) => {
|
return (
|
||||||
const {title, htmlFor, children} = props
|
<div className="card bg-base-200 shadow-xl mb-4">
|
||||||
return <div className='flex flex-col gap-1'>
|
<div className="card-body p-4">
|
||||||
<label className='font-medium desc-lighter text-sm' htmlFor={htmlFor}>{title}</label>
|
<h2 className="card-title flex justify-between cursor-pointer" onClick={() => setIsExpanded(!isExpanded)}>
|
||||||
<div className='flex flex-col gap-1 rounded py-2 px-2 bg-base-200/75'>{children}</div>
|
{title}
|
||||||
|
{isExpanded ? <FaChevronUp /> : <FaChevronDown />}
|
||||||
|
</h2>
|
||||||
|
{isExpanded && <div className="mt-4">{children}</div>}
|
||||||
</div>
|
</div>
|
||||||
}
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const FormItem = (props: {
|
const FormItem = (props: {
|
||||||
title: ShowElement
|
title: ShowElement
|
||||||
@@ -45,14 +51,16 @@ const FormItem = (props: {
|
|||||||
htmlFor?: string
|
htmlFor?: string
|
||||||
} & PropsWithChildren) => {
|
} & PropsWithChildren) => {
|
||||||
const {title, tip, htmlFor, children} = props
|
const {title, tip, htmlFor, children} = props
|
||||||
return <div className='flex items-center gap-2'>
|
return (
|
||||||
<div className={classNames('basis-3/12 justify-end flex-center', tip && 'tooltip tooltip-right z-[100] underline underline-offset-2 decoration-dashed')} data-tip={tip}>
|
<div className='flex items-center gap-4 mb-2'>
|
||||||
<label className='font-medium desc' htmlFor={htmlFor}>{title}</label>
|
<div className={classNames('w-1/3 text-right', tip && 'tooltip tooltip-right z-50')} data-tip={tip}>
|
||||||
|
<label className={classNames('font-medium', tip && 'border-b border-dotted border-current pb-[2px]')} htmlFor={htmlFor}>{title}</label>
|
||||||
</div>
|
</div>
|
||||||
<div className='basis-9/12 flex items-center'>
|
<div className='w-2/3'>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const OptionsPage = () => {
|
const OptionsPage = () => {
|
||||||
@@ -199,9 +207,9 @@ const OptionsPage = () => {
|
|||||||
setAiTypeValue('gemini')
|
setAiTypeValue('gemini')
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return <div className='flex justify-center'>
|
return (
|
||||||
<div className="w-2/3 max-w-[600px] flex flex-col gap-3 p-2">
|
<div className='container mx-auto max-w-3xl p-4'>
|
||||||
<Section title='通用配置'>
|
<OptionCard title="通用配置">
|
||||||
<FormItem title='侧边栏' htmlFor='sidePanel' tip='字幕列表是否显示在侧边栏'>
|
<FormItem title='侧边栏' htmlFor='sidePanel' tip='字幕列表是否显示在侧边栏'>
|
||||||
<input id='sidePanel' type='checkbox' className='toggle toggle-primary' checked={sidePanelValue}
|
<input id='sidePanel' type='checkbox' className='toggle toggle-primary' checked={sidePanelValue}
|
||||||
onChange={setSidePanelValue}/>
|
onChange={setSidePanelValue}/>
|
||||||
@@ -216,37 +224,37 @@ const OptionsPage = () => {
|
|||||||
</FormItem>}
|
</FormItem>}
|
||||||
<FormItem title='主题'>
|
<FormItem title='主题'>
|
||||||
<div className="btn-group">
|
<div className="btn-group">
|
||||||
<button onClick={onSelTheme1} className={classNames('btn btn-xs no-animation', (!themeValue || themeValue === 'system')?'btn-active':'')}>系统</button>
|
<button onClick={onSelTheme1} className={classNames('btn btn-sm no-animation', (!themeValue || themeValue === 'system')?'btn-active':'')}>系统</button>
|
||||||
<button onClick={onSelTheme2} className={classNames('btn btn-xs no-animation', themeValue === 'light'?'btn-active':'')}>浅色</button>
|
<button onClick={onSelTheme2} className={classNames('btn btn-sm no-animation', themeValue === 'light'?'btn-active':'')}>浅色</button>
|
||||||
<button onClick={onSelTheme3} className={classNames('btn btn-xs no-animation', themeValue === 'dark'?'btn-active':'')}>深色</button>
|
<button onClick={onSelTheme3} className={classNames('btn btn-sm no-animation', themeValue === 'dark'?'btn-active':'')}>深色</button>
|
||||||
</div>
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem title='字体大小'>
|
<FormItem title='字体大小'>
|
||||||
<div className="btn-group">
|
<div className="btn-group">
|
||||||
<button onClick={onSelFontSize1} className={classNames('btn btn-xs no-animation', (!fontSizeValue || fontSizeValue === 'normal')?'btn-active':'')}>普通</button>
|
<button onClick={onSelFontSize1} className={classNames('btn btn-sm no-animation', (!fontSizeValue || fontSizeValue === 'normal')?'btn-active':'')}>普通</button>
|
||||||
<button onClick={onSelFontSize2} className={classNames('btn btn-xs no-animation', fontSizeValue === 'large'?'btn-active':'')}>加大</button>
|
<button onClick={onSelFontSize2} className={classNames('btn btn-sm no-animation', fontSizeValue === 'large'?'btn-active':'')}>加大</button>
|
||||||
</div>
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem title='AI类型' tip='OPENAI质量更高'>
|
<FormItem title='AI类型' tip='OPENAI质量更高'>
|
||||||
<div className="btn-group">
|
<div className="btn-group">
|
||||||
<button onClick={onSelOpenai} className={classNames('btn btn-xs no-animation', (!aiTypeValue || aiTypeValue === 'openai')?'btn-active':'')}>OpenAI</button>
|
<button onClick={onSelOpenai} className={classNames('btn btn-sm', (!aiTypeValue || aiTypeValue === 'openai')?'btn-active':'')}>OpenAI</button>
|
||||||
<button onClick={onSelGemini} className={classNames('btn btn-xs no-animation', aiTypeValue === 'gemini'?'btn-active':'')}>Gemini</button>
|
<button onClick={onSelGemini} className={classNames('btn btn-sm', aiTypeValue === 'gemini'?'btn-active':'')}>Gemini</button>
|
||||||
</div>
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Section>
|
</OptionCard>
|
||||||
|
|
||||||
{(!aiTypeValue || aiTypeValue === 'openai') && <Section title='openai配置'>
|
<OptionCard title="AI 配置">
|
||||||
<FormItem title='ApiKey' htmlFor='apiKey'>
|
{(!aiTypeValue || aiTypeValue === 'openai') && <FormItem title='ApiKey' htmlFor='apiKey'>
|
||||||
<input id='apiKey' type='text' className='input input-sm input-bordered w-full' placeholder='sk-xxx'
|
<input id='apiKey' type='text' className='input input-sm input-bordered w-full' placeholder='sk-xxx'
|
||||||
value={apiKeyValue} onChange={onChangeApiKeyValue}/>
|
value={apiKeyValue} onChange={onChangeApiKeyValue}/>
|
||||||
</FormItem>
|
</FormItem>}
|
||||||
<FormItem title='服务器' htmlFor='serverUrl'>
|
{(!aiTypeValue || aiTypeValue === 'openai') && <FormItem title='服务器' htmlFor='serverUrl'>
|
||||||
<input id='serverUrl' type='text' className='input input-sm input-bordered w-full'
|
<input id='serverUrl' type='text' className='input input-sm input-bordered w-full'
|
||||||
placeholder={DEFAULT_SERVER_URL_OPENAI} value={serverUrlValue}
|
placeholder={DEFAULT_SERVER_URL_OPENAI} value={serverUrlValue}
|
||||||
onChange={e => setServerUrlValue(e.target.value)}/>
|
onChange={e => setServerUrlValue(e.target.value)}/>
|
||||||
</FormItem>
|
</FormItem>}
|
||||||
<div>
|
{(!aiTypeValue || aiTypeValue === 'openai') && <div>
|
||||||
<div className='desc text-xs text-center'>
|
<div className='desc text-sm text-center'>
|
||||||
<div className='flex justify-center font-semibold'>【官方地址】</div>
|
<div className='flex justify-center font-semibold'>【官方地址】</div>
|
||||||
<div>官方网址:<a className='link link-primary' href='https://platform.openai.com/' target='_blank'
|
<div>官方网址:<a className='link link-primary' href='https://platform.openai.com/' target='_blank'
|
||||||
rel="noreferrer">点击访问</a></div>
|
rel="noreferrer">点击访问</a></div>
|
||||||
@@ -262,16 +270,16 @@ const OptionsPage = () => {
|
|||||||
{/* rel='noreferrer'>点击设置</a></div> */}
|
{/* rel='noreferrer'>点击设置</a></div> */}
|
||||||
{/* <div className='text-amber-600 flex justify-center items-center'><FaGripfire/>目前价格不到官方价格的6折<FaGripfire/></div> */}
|
{/* <div className='text-amber-600 flex justify-center items-center'><FaGripfire/>目前价格不到官方价格的6折<FaGripfire/></div> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>}
|
||||||
<FormItem title='模型选择' htmlFor='modelSel' tip='注意,不同模型有不同价格与token限制'>
|
{(!aiTypeValue || aiTypeValue === 'openai') && <FormItem title='模型选择' htmlFor='modelSel' tip='注意,不同模型有不同价格与token限制'>
|
||||||
<select id='modelSel' className="select select-sm select-bordered" value={modelValue}
|
<select id='modelSel' className="select select-sm select-bordered" value={modelValue}
|
||||||
onChange={onChangeModelValue}>
|
onChange={onChangeModelValue}>
|
||||||
{MODELS.map(model => <option key={model.code} value={model.code}>{model.name}</option>)}
|
{MODELS.map(model => <option key={model.code} value={model.code}>{model.name}</option>)}
|
||||||
</select>
|
</select>
|
||||||
</FormItem>
|
</FormItem>}
|
||||||
<div className='desc text-xs'>
|
{(!aiTypeValue || aiTypeValue === 'openai') && <div className='desc text-sm'>
|
||||||
{MODEL_TIP}
|
{MODEL_TIP}
|
||||||
</div>
|
</div>}
|
||||||
{modelValue === 'custom' && <FormItem title='模型名' htmlFor='customModel'>
|
{modelValue === 'custom' && <FormItem title='模型名' htmlFor='customModel'>
|
||||||
<input id='customModel' type='text' className='input input-sm input-bordered w-full' placeholder='llama2'
|
<input id='customModel' type='text' className='input input-sm input-bordered w-full' placeholder='llama2'
|
||||||
value={customModelValue} onChange={onChangeCustomModelValue}/>
|
value={customModelValue} onChange={onChangeCustomModelValue}/>
|
||||||
@@ -282,26 +290,23 @@ const OptionsPage = () => {
|
|||||||
value={customModelTokensValue}
|
value={customModelTokensValue}
|
||||||
onChange={e => setCustomModelTokensValue(e.target.value ? parseInt(e.target.value) : undefined)}/>
|
onChange={e => setCustomModelTokensValue(e.target.value ? parseInt(e.target.value) : undefined)}/>
|
||||||
</FormItem>}
|
</FormItem>}
|
||||||
</Section>}
|
{aiTypeValue === 'gemini' && <FormItem title='ApiKey' htmlFor='geminiApiKey'>
|
||||||
|
|
||||||
{aiTypeValue === 'gemini' && <Section title='gemini配置'>
|
|
||||||
<FormItem title='ApiKey' htmlFor='geminiApiKey'>
|
|
||||||
<input id='geminiApiKey' type='text' className='input input-sm input-bordered w-full' placeholder='xxx'
|
<input id='geminiApiKey' type='text' className='input input-sm input-bordered w-full' placeholder='xxx'
|
||||||
value={geminiApiKeyValue} onChange={onChangeGeminiApiKeyValue}/>
|
value={geminiApiKeyValue} onChange={onChangeGeminiApiKeyValue}/>
|
||||||
</FormItem>
|
</FormItem>}
|
||||||
<div>
|
{aiTypeValue === 'gemini' && <div>
|
||||||
<div className='desc text-xs'>
|
<div className='desc text-sm'>
|
||||||
<div>官方网址:<a className='link link-primary' href='https://makersuite.google.com/app/apikey'
|
<div>官方网址:<a className='link link-primary' href='https://makersuite.google.com/app/apikey'
|
||||||
target='_blank'
|
target='_blank'
|
||||||
rel="noreferrer">Google AI Studio</a> (目前免费)
|
rel="noreferrer">Google AI Studio</a> (目前免费)
|
||||||
</div>
|
</div>
|
||||||
<div className='text-xs text-error flex items-center'><IoWarning className='text-sm text-warning'/>谷歌模型安全要求比较高,有些视频可能无法生成总结!
|
<div className='text-sm text-error flex items-center'><IoWarning className='text-sm text-warning'/>谷歌模型安全要求比较高,有些视频可能无法生成总结!
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>}
|
||||||
</Section>}
|
</OptionCard>
|
||||||
|
|
||||||
<Section title={<div className='flex items-center'>
|
<OptionCard title={<div className='flex items-center'>
|
||||||
翻译配置
|
翻译配置
|
||||||
{!apiKeySetted && <div className='tooltip tooltip-right ml-1' data-tip='未设置ApiKey无法使用'>
|
{!apiKeySetted && <div className='tooltip tooltip-right ml-1' data-tip='未设置ApiKey无法使用'>
|
||||||
<IoWarning className='text-sm text-warning'/>
|
<IoWarning className='text-sm text-warning'/>
|
||||||
@@ -320,24 +325,24 @@ const OptionsPage = () => {
|
|||||||
<FormItem title='翻译条数' tip='每次翻译条数'>
|
<FormItem title='翻译条数' tip='每次翻译条数'>
|
||||||
<div className='flex-1 flex flex-col'>
|
<div className='flex-1 flex flex-col'>
|
||||||
<input type="range" min={TRANSLATE_FETCH_MIN} max={TRANSLATE_FETCH_MAX} step={TRANSLATE_FETCH_STEP} value={fetchAmountValue} className="range range-primary" onChange={onFetchAmountChange} />
|
<input type="range" min={TRANSLATE_FETCH_MIN} max={TRANSLATE_FETCH_MAX} step={TRANSLATE_FETCH_STEP} value={fetchAmountValue} className="range range-primary" onChange={onFetchAmountChange} />
|
||||||
<div className="w-full flex justify-between text-xs px-2">
|
<div className="w-full flex justify-between text-sm px-2">
|
||||||
{transFetchAmountList.map(amount => <span key={amount}>{amount}</span>)}
|
{transFetchAmountList.map(amount => <span key={amount}>{amount}</span>)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem title='翻译显示'>
|
<FormItem title='翻译显示'>
|
||||||
<div className="btn-group">
|
<div className="btn-group">
|
||||||
<button onClick={onSel1} className={classNames('btn btn-xs no-animation', (!transDisplayValue || transDisplayValue === 'originPrimary')?'btn-active':'')}>原文为主</button>
|
<button onClick={onSel1} className={classNames('btn btn-sm no-animation', (!transDisplayValue || transDisplayValue === 'originPrimary')?'btn-active':'')}>原文为主</button>
|
||||||
<button onClick={onSel2} className={classNames('btn btn-xs no-animation', transDisplayValue === 'targetPrimary'?'btn-active':'')}>翻译为主</button>
|
<button onClick={onSel2} className={classNames('btn btn-sm no-animation', transDisplayValue === 'targetPrimary'?'btn-active':'')}>翻译为主</button>
|
||||||
<button onClick={onSel3} className={classNames('btn btn-xs no-animation', transDisplayValue === 'target'?'btn-active':'')}>仅翻译</button>
|
<button onClick={onSel3} className={classNames('btn btn-sm no-animation', transDisplayValue === 'target'?'btn-active':'')}>仅翻译</button>
|
||||||
</div>
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem title='隐藏翻译' tip='取消自动翻译时,隐藏已翻译内容' htmlFor='hideOnDisableAutoTranslate'>
|
<FormItem title='隐藏翻译' tip='取消自动翻译时,隐藏已翻译内容' htmlFor='hideOnDisableAutoTranslate'>
|
||||||
<input id='hideOnDisableAutoTranslate' type='checkbox' className='toggle toggle-primary' checked={hideOnDisableAutoTranslateValue}
|
<input id='hideOnDisableAutoTranslate' type='checkbox' className='toggle toggle-primary' checked={hideOnDisableAutoTranslateValue}
|
||||||
onChange={onChangeHideOnDisableAutoTranslate}/>
|
onChange={onChangeHideOnDisableAutoTranslate}/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Section>
|
</OptionCard>
|
||||||
<Section title={<div className='flex items-center'>
|
<OptionCard title={<div className='flex items-center'>
|
||||||
总结配置
|
总结配置
|
||||||
{!apiKeySetted && <div className='tooltip tooltip-right ml-1' data-tip='未设置ApiKey无法使用'>
|
{!apiKeySetted && <div className='tooltip tooltip-right ml-1' data-tip='未设置ApiKey无法使用'>
|
||||||
<IoWarning className='text-sm text-warning'/>
|
<IoWarning className='text-sm text-warning'/>
|
||||||
@@ -360,17 +365,17 @@ const OptionsPage = () => {
|
|||||||
<div className='flex-1 flex flex-col'>
|
<div className='flex-1 flex flex-col'>
|
||||||
<input id='words' type='number' className='input input-sm input-bordered w-full' placeholder={`默认为上限x${WORDS_RATE}`} value={wordsValue??''} onChange={e => setWordsValue(e.target.value?parseInt(e.target.value):undefined)}/>
|
<input id='words' type='number' className='input input-sm input-bordered w-full' placeholder={`默认为上限x${WORDS_RATE}`} value={wordsValue??''} onChange={e => setWordsValue(e.target.value?parseInt(e.target.value):undefined)}/>
|
||||||
{/* <input type="range" min={WORDS_MIN} max={WORDS_MAX} step={WORDS_STEP} value={wordsValue} className="range range-primary" onChange={onWordsChange} /> */}
|
{/* <input type="range" min={WORDS_MIN} max={WORDS_MAX} step={WORDS_STEP} value={wordsValue} className="range range-primary" onChange={onWordsChange} /> */}
|
||||||
{/* <div className="w-full flex justify-between text-xs px-2"> */}
|
{/* <div className="w-full flex justify-between text-sm px-2"> */}
|
||||||
{/* {wordsList.map(words => <span key={words}>{words}</span>)} */}
|
{/* {wordsList.map(words => <span key={words}>{words}</span>)} */}
|
||||||
{/* </div> */}
|
{/* </div> */}
|
||||||
</div>
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<div className='desc text-xs'>
|
<div className='desc text-sm'>
|
||||||
当前选择的模型的分段字数上限是<span className='font-semibold font-mono'>{aiTypeValue === 'gemini'?GEMINI_TOKENS:(MODEL_MAP[modelValue??MODEL_DEFAULT]?.tokens??'未知')}</span>
|
当前选择的模型的分段字数上限是<span className='font-semibold font-mono'>{aiTypeValue === 'gemini'?GEMINI_TOKENS:(MODEL_MAP[modelValue??MODEL_DEFAULT]?.tokens??'未知')}</span>
|
||||||
(太接近上限总结会报错)
|
(太接近上限总结会报错)
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</OptionCard>
|
||||||
<Section title={<div className='flex items-center'>
|
<OptionCard title={<div className='flex items-center'>
|
||||||
搜索配置
|
搜索配置
|
||||||
</div>}>
|
</div>}>
|
||||||
<FormItem title='启用搜索' htmlFor='searchEnabled' tip='是否启用字幕搜索功能'>
|
<FormItem title='启用搜索' htmlFor='searchEnabled' tip='是否启用字幕搜索功能'>
|
||||||
@@ -381,23 +386,23 @@ const OptionsPage = () => {
|
|||||||
<input id='cnSearchEnabled' type='checkbox' className='toggle toggle-primary' checked={cnSearchEnabledValue}
|
<input id='cnSearchEnabled' type='checkbox' className='toggle toggle-primary' checked={cnSearchEnabledValue}
|
||||||
onChange={setCnSearchEnabledValue}/>
|
onChange={setCnSearchEnabledValue}/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Section>
|
</OptionCard>
|
||||||
<Section title={<div className='flex items-center'>
|
<OptionCard title={<div className='flex items-center'>
|
||||||
提问配置
|
提问配置
|
||||||
</div>}>
|
</div>}>
|
||||||
<FormItem title='启用提问' htmlFor='askEnabled' tip='是否启用字幕提问功能'>
|
<FormItem title='启用提问' htmlFor='askEnabled' tip='是否启用字幕提问功能'>
|
||||||
<input id='askEnabled' type='checkbox' className='toggle toggle-primary' checked={askEnabledValue}
|
<input id='askEnabled' type='checkbox' className='toggle toggle-primary' checked={askEnabledValue}
|
||||||
onChange={setAskEnabledValue}/>
|
onChange={setAskEnabledValue}/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Section>
|
</OptionCard>
|
||||||
|
|
||||||
<Section title='提示词配置'>
|
<OptionCard title='提示词配置'>
|
||||||
<div className='flex justify-center'>
|
<div className='flex justify-center'>
|
||||||
<a className='text-xs link link-primary' onClick={togglePromptsFold}>点击{promptsFold ? '展开' : '折叠'}</a>
|
<a className='text-sm link link-primary' onClick={togglePromptsFold}>点击{promptsFold ? '展开' : '折叠'}</a>
|
||||||
</div>
|
</div>
|
||||||
{!promptsFold && PROMPT_TYPES.map((item, idx) => <FormItem key={item.type} title={<div>
|
{!promptsFold && PROMPT_TYPES.map((item, idx) => <FormItem key={item.type} title={<div>
|
||||||
<div>{item.name}</div>
|
<div>{item.name}</div>
|
||||||
<div className='link text-xs' onClick={() => {
|
<div className='link text-sm' onClick={() => {
|
||||||
setPromptsValue({
|
setPromptsValue({
|
||||||
...promptsValue,
|
...promptsValue,
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
@@ -414,20 +419,14 @@ const OptionsPage = () => {
|
|||||||
})
|
})
|
||||||
}}/>
|
}}/>
|
||||||
</FormItem>)}
|
</FormItem>)}
|
||||||
</Section>
|
</OptionCard>
|
||||||
|
|
||||||
<div className='flex justify-center gap-5'>
|
<div className='flex flex-col justify-center items-center gap-5 mt-6'>
|
||||||
<button className='btn btn-primary btn-sm' onClick={onSave}>保存</button>
|
<button className='btn btn-primary btn-wide' onClick={onSave}>保存</button>
|
||||||
<button className='btn btn-sm' onClick={onCancel}>取消</button>
|
<button className='btn btn-wide' onClick={onCancel}>取消</button>
|
||||||
{/* <button className='btn btn-sm' onClick={() => {
|
|
||||||
dispatch(setTempData({
|
|
||||||
reviewed: undefined,
|
|
||||||
// reviewActions: 0
|
|
||||||
}))
|
|
||||||
}}>重置</button> */}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OptionsPage
|
export default OptionsPage
|
@@ -32,7 +32,8 @@ interface EnvState {
|
|||||||
segments?: Segment[]
|
segments?: Segment[]
|
||||||
url?: string
|
url?: string
|
||||||
title?: string
|
title?: string
|
||||||
|
ctime?: number | null
|
||||||
|
author?: string
|
||||||
taskIds?: string[]
|
taskIds?: string[]
|
||||||
transResults: { [key: number]: TransResult }
|
transResults: { [key: number]: TransResult }
|
||||||
lastTransTime?: number
|
lastTransTime?: number
|
||||||
@@ -271,6 +272,12 @@ export const slice = createSlice({
|
|||||||
setTitle: (state, action: PayloadAction<string | undefined>) => {
|
setTitle: (state, action: PayloadAction<string | undefined>) => {
|
||||||
state.title = action.payload
|
state.title = action.payload
|
||||||
},
|
},
|
||||||
|
setCtime: (state, action: PayloadAction<number | null | undefined>) => {
|
||||||
|
state.ctime = action.payload
|
||||||
|
},
|
||||||
|
setAuthor: (state, action: PayloadAction<string | undefined>) => {
|
||||||
|
state.author = action.payload
|
||||||
|
},
|
||||||
setInfos: (state, action: PayloadAction<any[]>) => {
|
setInfos: (state, action: PayloadAction<any[]>) => {
|
||||||
state.infos = action.payload
|
state.infos = action.payload
|
||||||
},
|
},
|
||||||
@@ -342,6 +349,8 @@ export const {
|
|||||||
addAskInfo,
|
addAskInfo,
|
||||||
delAskInfo,
|
delAskInfo,
|
||||||
mergeAskInfo,
|
mergeAskInfo,
|
||||||
|
setCtime,
|
||||||
|
setAuthor,
|
||||||
} = slice.actions
|
} = slice.actions
|
||||||
|
|
||||||
export default slice.reducer
|
export default slice.reducer
|
||||||
|
11
src/typings.d.ts
vendored
@@ -151,4 +151,13 @@ interface BriefSummary extends Summary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SummaryStatus = 'init' | 'pending' | 'done'
|
type SummaryStatus = 'init' | 'pending' | 'done'
|
||||||
type SummaryType = 'overview' | 'keypoint' | 'brief' | 'question'
|
type SummaryType = 'overview' | 'keypoint' | 'brief' | 'question' | 'debate'
|
||||||
|
|
||||||
|
interface DebateMessage {
|
||||||
|
side: 'pro' | 'con';
|
||||||
|
content: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DebateProps {
|
||||||
|
messages: DebateMessage[];
|
||||||
|
}
|
||||||
|
@@ -81,6 +81,9 @@ export const isSummaryEmpty = (summary: Summary) => {
|
|||||||
} else if (summary.type === 'question') {
|
} else if (summary.type === 'question') {
|
||||||
const content: any[] = summary.content??[]
|
const content: any[] = summary.content??[]
|
||||||
return content.length === 0
|
return content.length === 0
|
||||||
|
} else if (summary.type === 'debate') {
|
||||||
|
const content: Array<{ side: string, content: string }> = summary.content ?? []
|
||||||
|
return content.length === 0
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -107,6 +110,11 @@ export const getSummaryStr = (summary: Summary) => {
|
|||||||
s += content.map(item => {
|
s += content.map(item => {
|
||||||
return item.q + '\n' + item.a + '\n'
|
return item.q + '\n' + item.a + '\n'
|
||||||
}).join('\n')
|
}).join('\n')
|
||||||
|
} else if (summary.type === 'debate') {
|
||||||
|
const content: Array<{ side: string, content: string }> = summary.content ?? []
|
||||||
|
s += content.map(item => {
|
||||||
|
return (item.side === 'pro'?'正方:':'反方:') + item.content + '\n'
|
||||||
|
}).join('\n')
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
1
src/vite-env.d.ts
vendored
@@ -1,7 +1,6 @@
|
|||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
readonly VITE_EXTENSION_ID: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
|