chore: replace all cn comments of fe to en version by volc api (#320)

This commit is contained in:
tecvan
2025-07-31 10:32:15 +08:00
committed by GitHub
parent 716ec0cba8
commit 71f6245a01
2960 changed files with 15545 additions and 15545 deletions

View File

@@ -62,7 +62,7 @@ export const createGrabPlugin = (params: CreateGrabPluginParams) => {
const eventCenter = mitt<EventCenter>();
// 默认注入preference
// Default injection preference
storeSet.usePreferenceStore
.getState()
.updateEnableGrab(preference.enableGrab);

View File

@@ -36,7 +36,7 @@ export const QuoteMessageInnerTopSlot: CustomTextMessageInnerTopSlot = ({
const { useQuoteStore } = plugin.pluginBizContext.storeSet;
// 优先用本地映射的
// Preference is given to locally mapped
const hasLocal = useQuoteStore(
useShallow(state => !!state.quoteContentMap[localMessageId]),
);

View File

@@ -36,7 +36,7 @@ export const LocalQuoteInnerTopSlot: CustomTextMessageInnerTopSlot = ({
const { useQuoteStore } = plugin.pluginBizContext.storeSet;
// 优先用本地映射的
// Preference is given to locally mapped
const localNodeList = useQuoteStore(
useShallow(state => state.quoteContentMap[localMessageId]),
);

View File

@@ -27,7 +27,7 @@ import { QuoteTopUI } from './quote-top-ui';
export const RemoteQuoteInnerTopSlot: CustomTextMessageInnerTopSlot = ({
message,
}) => {
// 本地没有用服务端下发的
// It was not sent locally with server level.
const refer = getReferFromMessage(message);
if (!refer) {
@@ -42,7 +42,7 @@ export const RemoteQuoteInnerTopSlot: CustomTextMessageInnerTopSlot = ({
);
}
// 尝试解析ast
// Try to parse ast.
const nodeList = parseMarkdownToGrabNode(refer.text);
return (

View File

@@ -37,21 +37,21 @@ import {
import { FILTER_MESSAGE_SOURCE } from '../../constants/filter-message';
export const GrabMenu: MessageListFloatSlot = ({ contentRef }) => {
// 获取插件实例
// Get plugin instance
const plugin = useWriteablePlugin<GrabPluginBizContext>(
PluginName.MessageGrab,
);
// 获取插件的业务上下文信息
// Get business context information for the plug-in
const { pluginBizContext } = plugin;
const { eventCenter, storeSet } = pluginBizContext;
const { usePreferenceStore, useSelectionStore } = storeSet;
// 事件中心监听函数
// Event Center Listener Function
const { on, off } = eventCenter;
/**
* Float Menu Ref
* Floating Menu Ref
*/
const floatMenuRef = useRef<MenuListRef>(null);
@@ -65,23 +65,23 @@ export const GrabMenu: MessageListFloatSlot = ({ contentRef }) => {
);
/**
* 是否启用 Grab 插件
* Whether to enable the Grab plugin
*/
const enableGrab = usePreferenceStore(state => state.enableGrab);
/**
* 处理位置信息的回调
* Callbacks to handle location information
*/
const handlePositionChange = (_position: GrabPosition | null) => {
// 更新浮动菜单在 Store 中的数据
// Update Floating Menu Data in Store
updateFloatMenuPosition(_position);
// 清空栈后调用刷新的逻辑 (因为 floatMenu 在 hidden 状态下 通过 ref 拿到的 rect 信息是空,所以需要延迟一会儿获取)
// Call the refresh logic after clearing the stack (because the floatMenu is in the hidden state, the rect information obtained through ref is empty, so it needs to be delayed for a while)
defer(() => floatMenuRef.current?.refreshOpacity());
};
/**
* 处理选区的变化
* Handling changes in constituencies
*/
const handleSelectChange = (selectionData: SelectionData | null) => {
const {
@@ -93,9 +93,9 @@ export const GrabMenu: MessageListFloatSlot = ({ contentRef }) => {
} = plugin.pluginBizContext.storeSet.useSelectionStore.getState();
/**
* 过滤特殊类型的消息
* 目前只有通过消息来源进行判断 messageSource
* 1. 通知类型 (禁止选择)
* Filtering for special types of messages
* Currently only judged by the source messageSource
* 1. Notification type (no selection)
*/
if (
selectionData &&
@@ -104,29 +104,29 @@ export const GrabMenu: MessageListFloatSlot = ({ contentRef }) => {
return;
}
// 更新选区数据
// Update constituency data
updateSelectionData(selectionData);
// 更新展示浮动菜单的状态
// Update the status of displaying the floating menu
updateIsFloatMenuVisible(!!selectionData);
// 拿取 MessageId
// Get MessageId
const messageId = selectionData?.ancestorAttributeValue;
// 判断是否是特殊消息
// Determine whether it is a special message
const isSpecialMessage = messageId === NO_MESSAGE_ID_MARK;
// 如果拿不到消息 ID就证明选区不在消息哪
// If you can't get the message ID, it proves that the constituency is not in the message.
if (!messageId) {
return;
}
// 特殊处理,需要判断是否是回复中的消息
// Special processing, you need to determine whether it is a message in the reply.
const { is_finish } =
plugin.chatAreaPluginContext.readonlyAPI.message.findMessage(messageId) ??
{};
// 如果消息回复没完成 并且 不是一个特殊的消息 那么就不展示,否则展示
// If the message reply is not completed, and it is not a special message, then it will not be displayed, otherwise it will be displayed
if (!is_finish && !isSpecialMessage) {
updateIsFloatMenuVisible(false);
return;
@@ -158,7 +158,7 @@ export const GrabMenu: MessageListFloatSlot = ({ contentRef }) => {
};
}, []);
// 如果没有开启 Grab 插件,那么就隐藏了当然
// If the Grab plugin is not enabled, it will be hidden, of course.
if (!enableGrab) {
return null;
}

View File

@@ -56,12 +56,12 @@ export const useFloatMenuListener = ({
} | null>(null);
/**
* 是否在 Scrolling
* In Scrolling
*/
const [isScrolling, setIsScrolling] = useState(false);
/**
* Scrolling 计时器
* Scrolling timer
*/
const scrollingTimer = useRef<NodeJS.Timeout | null>(null);

View File

@@ -28,14 +28,14 @@ interface Params {
botId: string;
source: MessageSource | undefined;
}) => void;
// 目前只需要区分出 store 的场景
// At present, only the scene of the store needs to be distinguished.
scene?: Scene;
}
export const useCreateGrabPlugin = (params?: Params) => {
const { onQuote, scene = 'other' } = params ?? {};
const [grabEnableUpload, setGrabEnableUpload] = useState(true);
// eslint-disable-next-line @typescript-eslint/naming-convention -- 符合预期的命名
// eslint-disable-next-line @typescript-eslint/naming-convention -- matches the expected naming
const { grabPlugin: GrabPlugin, grabPluginId } = useMemo(
() =>
createGrabPlugin({

View File

@@ -27,7 +27,7 @@ export class GrabAppLifeCycleService extends WriteableAppLifeCycleService<GrabPl
const { unsubscribe, eventCenter, publicEventCenter, scene } =
this.pluginInstance.pluginBizContext;
// Store 历史逻辑有一些问题,导致调用了 多次 destroy 但未初始化的情况,就不走下面的强制清理流程,而是走组件生命周期销毁
// There are some problems with the Store history logic, which leads to the situation that destroy is called multiple times but not initialized. Instead of going through the following forced cleaning process, the component life cycle is destroyed.
if (scene === 'store') {
return;
}

View File

@@ -33,7 +33,7 @@ export const enum EventNames {
OnLinkElementMouseLeave = 'onCardLinkElementMouseLeave',
}
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- 符合预期
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- as expected
export type EventCenter = {
[EventNames.OnMessageUpdate]: unknown;
[EventNames.OnViewScroll]: unknown;

View File

@@ -32,24 +32,24 @@ const isReactElementWithChildren = (
'children' in node.props;
/**
* 从 ReactNode 中提取纯文本(不包括各种特殊转换逻辑)
* Extracting plain text from ReactNode (excluding various special conversion logic)
*/
export const extractTextFromReactNode = (children: ReactNode): string => {
let text = '';
Children.forEach(children, child => {
if (typeof child === 'string' || typeof child === 'number') {
// 如果 child 是字符串或数字,直接加到 text
// If child is a string or number, add it directly to the text
text += child.toString();
} else if (
isValidElement(child) &&
isReactElementWithChildren(child) &&
child.props.children
) {
// 如果 child React 元素且有 children 属性,递归提取
// If child is a React element with a children attribute, recursive extraction
text += extractTextFromReactNode(child.props.children);
}
// 如果 child null boolean,不需要做任何操作
// If child is null or boolean, no action is required
});
return text;