fix消息通信

This commit is contained in:
IndieKKY
2025-02-23 20:19:41 +08:00
parent d4e5e407a4
commit 5bcedf0c9d
24 changed files with 200 additions and 716 deletions

View File

@@ -25,6 +25,7 @@ import toast from 'react-hot-toast'
import SegmentCard from './SegmentCard'
import {
ASK_ENABLED_DEFAULT,
DEFAULT_USE_PORT,
HEADER_HEIGHT,
PAGE_SETTINGS,
SEARCH_BAR_HEIGHT,
@@ -39,7 +40,7 @@ import Ask from './Ask'
import { v4 } from 'uuid'
import RateExtension from '../components/RateExtension'
import ApiKeyReminder from './ApiKeyReminder'
import useMessaging from '@/messaging/layer2/useMessaging'
import { useMessaging } from '@kky002/kky-message'
const Body = () => {
const dispatch = useAppDispatch()
@@ -66,7 +67,7 @@ const Body = () => {
// const fontSize = useAppSelector(state => state.env.envData.fontSize)
const searchText = useAppSelector(state => state.env.searchText)
const asks = useAppSelector(state => state.env.asks)
const {disconnected} = useMessaging()
const {disconnected} = useMessaging(DEFAULT_USE_PORT)
// const recommendIdx = useMemo(() => random(0, 3), [])
const showSearchInput = useMemo(() => {
return (segments != null && segments.length > 0) && (envData.searchEnabled ? envData.searchEnabled : (envData.askEnabled ?? ASK_ENABLED_DEFAULT))

View File

@@ -1,8 +1,6 @@
import React, {MouseEvent, useCallback, useContext, useRef, useState} from 'react'
import {MouseEvent, useCallback, useContext, useRef, useState} from 'react'
import {useClickAway} from 'ahooks'
import {
AiFillWechat,
BsFillChatDotsFill,
FiMoreVertical,
ImDownload3,
IoMdSettings,
@@ -13,13 +11,13 @@ import {Placement} from '@popperjs/core/lib/enums'
import {useAppDispatch, useAppSelector} from '../hooks/redux'
import {setEnvData, setTempData} from '../redux/envReducer'
import {EventBusContext} from '../Router'
import {EVENT_EXPAND} from '../consts/const'
import {DEFAULT_USE_PORT, EVENT_EXPAND} from '../consts/const'
import {formatSrtTime, formatTime, formatVttTime} from '../utils/util'
import {downloadText, openUrl} from '@kky002/kky-util'
import toast from 'react-hot-toast'
import {getSummarize} from '../utils/bizUtil'
import { useMessage } from '@/hooks/message'
import dayjs from 'dayjs';
import { useMessage } from '@/hooks/useMessageService'
interface Props {
placement: Placement
@@ -74,7 +72,7 @@ const MoreBtn = (props: Props) => {
const author = useAppSelector(state => state.env.author)
const curSummaryType = useAppSelector(state => state.env.tempData.curSummaryType)
const {sendInject} = useMessage()
const {sendInject} = useMessage(!!envData.sidePanel)
const downloadCallback = useCallback((download: boolean) => {
if (data == null) {
@@ -167,7 +165,7 @@ const MoreBtn = (props: Props) => {
}, [curSummaryType, data, downloadType, segments, title, url])
const downloadAudioCallback = useCallback(() => {
sendInject('DOWNLOAD_AUDIO', {})
sendInject(null, 'DOWNLOAD_AUDIO', {})
}, [])
const selectCallback = useCallback((e: any) => {

View File

@@ -1,9 +1,9 @@
import React, {MutableRefObject, useCallback, useEffect, useMemo, useRef} from 'react'
import {MutableRefObject, useCallback, useEffect, useMemo, useRef} from 'react'
import {useAppDispatch, useAppSelector} from '../hooks/redux'
import {setFloatKeyPointsSegIdx, setSegmentFold, setTempData} from '../redux/envReducer'
import classNames from 'classnames'
import {FaClipboardList, FaComments} from 'react-icons/fa'
import {PAGE_MAIN, PAGE_SETTINGS, SUMMARIZE_THRESHOLD, SUMMARIZE_TYPES} from '../consts/const'
import {SUMMARIZE_THRESHOLD, SUMMARIZE_TYPES} from '../consts/const'
import useTranslate from '../hooks/useTranslate'
import {BsDashSquare, BsPlusSquare, CgFileDocument, FaQuestion, GrOverview, RiFileCopy2Line} from 'react-icons/all'
import toast from 'react-hot-toast'