chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -21,7 +21,7 @@ import {
|
||||
defaultConversationUniqId,
|
||||
} from '../../src/const/community';
|
||||
|
||||
// 模拟 lodash-es 的 uniqueId 函数
|
||||
// Mimicking the uniqueId function of lodash-es
|
||||
vi.mock('lodash-es', () => ({
|
||||
uniqueId: vi.fn().mockReturnValue('mocked-unique-id'),
|
||||
}));
|
||||
@@ -32,9 +32,9 @@ describe('const/community', () => {
|
||||
});
|
||||
|
||||
test('defaultConversationUniqId should be a unique ID generated by lodash-es', () => {
|
||||
// 验证 uniqueId 函数被调用
|
||||
// Verify that the uniqueId function is called
|
||||
expect(uniqueId).toHaveBeenCalled();
|
||||
// 验证 defaultConversationUniqId 的值是由模拟的 uniqueId 函数返回的
|
||||
// Verify that defaultConversationUniqId value is returned by the simulated uniqueId function
|
||||
expect(defaultConversationUniqId).toBe('mocked-unique-id');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,8 +34,8 @@ describe('const/custom', () => {
|
||||
expect(COZE_TOKEN_INSUFFICIENT_ERROR_CODE).toContain('702095072');
|
||||
});
|
||||
|
||||
// 移除失败的测试用例
|
||||
// 原因:在 JavaScript 中,即使使用 const 声明数组,其内容仍然是可变的
|
||||
// 只有数组引用是不可变的,而不是数组内容
|
||||
// Remove failed test cases
|
||||
// Reason: In JavaScript, even if an array is declared with const, its content is still mutable
|
||||
// Only the array reference is immutable, not the array content
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,10 +19,10 @@ import { globalVars } from '../src/global-var';
|
||||
describe('global-var', () => {
|
||||
test('should be able to set and get a property', () => {
|
||||
const testValue = 'Hello, World';
|
||||
// 设置一个属性
|
||||
// Set a property
|
||||
globalVars.TEST_PROP = testValue;
|
||||
|
||||
// 确保我们能获取到相同的属性
|
||||
// Make sure we can get the same properties
|
||||
expect(globalVars.TEST_PROP).toBe(testValue);
|
||||
});
|
||||
|
||||
@@ -34,11 +34,11 @@ describe('global-var', () => {
|
||||
const firstValue = 'First Value';
|
||||
const secondValue = 'Second Value';
|
||||
|
||||
// 先设置一个属性
|
||||
// Set a property first
|
||||
globalVars.OVERWRITE_PROP = firstValue;
|
||||
expect(globalVars.OVERWRITE_PROP).toBe(firstValue);
|
||||
|
||||
// 再覆盖这个属性
|
||||
// Override this property again
|
||||
globalVars.OVERWRITE_PROP = secondValue;
|
||||
expect(globalVars.OVERWRITE_PROP).toBe(secondValue);
|
||||
});
|
||||
|
||||
@@ -16,20 +16,20 @@
|
||||
|
||||
// extract from apps/bot/src/constant/app.ts
|
||||
export enum BaseEnum {
|
||||
Home = 'home', //首页
|
||||
Explore = 'explore', //探索
|
||||
Store = 'store', // 商店
|
||||
Model = 'model', //模型竞技场
|
||||
Space = 'space', //空间内
|
||||
Workflow = 'work_flow', //兼容 workflow 编辑页
|
||||
Invite = 'invite', // 邀请链接
|
||||
Home = 'home', //Home
|
||||
Explore = 'explore', //explore
|
||||
Store = 'store', // store
|
||||
Model = 'model', //Model Arena
|
||||
Space = 'space', //In space
|
||||
Workflow = 'work_flow', //Compatible workflow edit page
|
||||
Invite = 'invite', // invite link
|
||||
Token = 'token', // token
|
||||
Open = 'open', // 开放平台
|
||||
Open = 'open', // open API
|
||||
PluginMockSet = 'plugin_mock_set',
|
||||
Search = 'search', // 搜索
|
||||
Premium = 'premium', // 订阅服务
|
||||
User = 'user', // 个人主页
|
||||
Enterprise = 'enterprise', // 企业管理
|
||||
Search = 'search', // Search
|
||||
Premium = 'premium', // subscription service
|
||||
User = 'user', // personal homepage
|
||||
Enterprise = 'enterprise', // Business Management
|
||||
}
|
||||
|
||||
export enum SpaceAppEnum {
|
||||
|
||||
@@ -21,8 +21,8 @@ const enum CozeTokenInsufficientErrorCode {
|
||||
BOT = '702082020',
|
||||
}
|
||||
/**
|
||||
* Coze Token不足错误码
|
||||
* 当出现该错误码的时候,需要额外进行停止拉流操作
|
||||
* Insufficient Coze Token Error Code
|
||||
* When the error code appears, an additional stop and pull operation is required
|
||||
*/
|
||||
export const COZE_TOKEN_INSUFFICIENT_ERROR_CODE = [
|
||||
CozeTokenInsufficientErrorCode.BOT,
|
||||
|
||||
@@ -45,9 +45,9 @@ export class GlobalEventBus<T extends ValidEventTypes> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发事件
|
||||
* @param event 事件名称
|
||||
* @param args 参数
|
||||
* trigger event
|
||||
* @param event name
|
||||
* @param args parameter
|
||||
*/
|
||||
emit<P extends EventEmitter.EventNames<T>>(
|
||||
event: P,
|
||||
@@ -64,9 +64,9 @@ export class GlobalEventBus<T extends ValidEventTypes> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅事件
|
||||
* @param event 事件名称
|
||||
* @param fn 事件回调
|
||||
* subscribe to events
|
||||
* @param event name
|
||||
* @param fn event callback
|
||||
*/
|
||||
on<P extends EventEmitter.EventNames<T>>(
|
||||
event: P,
|
||||
@@ -76,9 +76,9 @@ export class GlobalEventBus<T extends ValidEventTypes> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订阅事件
|
||||
* @param event 事件名称
|
||||
* @param fn 事件回调
|
||||
* unsubscribe from the event
|
||||
* @param event name
|
||||
* @param fn event callback
|
||||
*/
|
||||
off<P extends EventEmitter.EventNames<T>>(
|
||||
event: P,
|
||||
@@ -88,7 +88,7 @@ export class GlobalEventBus<T extends ValidEventTypes> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启缓存事件订阅器,开启时会将关闭时收到的事件对应的回调按顺序逐一触发
|
||||
* Turn on the cached event subscriber, and when turned on, the callbacks corresponding to the events received when closed will be fired one by one in sequence
|
||||
*/
|
||||
start() {
|
||||
this.started = true;
|
||||
@@ -98,14 +98,14 @@ export class GlobalEventBus<T extends ValidEventTypes> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭缓存事件订阅器,在关闭时收到的事件会被缓存并延迟到下次开启时触发
|
||||
* Close the cached event subscriber. Events received during shutdown will be cached and delayed until the next time it is turned on
|
||||
*/
|
||||
stop() {
|
||||
this.started = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除缓存事件订阅器缓存的事件,使得在重新开启(start)时不会触发在关闭(stop)时收到的事件对应的回调
|
||||
* Clears the cached events of the event subscriber so that the callback corresponding to the event received at stop is not triggered when starting again
|
||||
*/
|
||||
clear() {
|
||||
this.buffer = [];
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
// 需要全局共享的值,可以提前到这里注册类型
|
||||
// Values that need to be shared globally can be registered here in advance
|
||||
interface GlobalVars {
|
||||
/**
|
||||
* Last Execute ID that extracts from apps/bot/src/store/bot-detail/utils/execute-draft-bot-request-id.ts
|
||||
*
|
||||
* 用于 debug 记录对话接口的 log id,不需要响应式,所以直接存 const 里了
|
||||
* The log id of the debug record dialogue interface does not need to be reactive, so it is directly stored in const.
|
||||
*/
|
||||
LAST_EXECUTE_ID: string;
|
||||
[key: string | symbol]: unknown;
|
||||
@@ -45,6 +45,6 @@ const createGlobalVarsStorage = () => {
|
||||
};
|
||||
|
||||
/**
|
||||
* 通用全局变量
|
||||
* universal global variable
|
||||
*/
|
||||
export const globalVars = createGlobalVarsStorage();
|
||||
|
||||
@@ -20,7 +20,7 @@ export { globalVars } from './global-var';
|
||||
export { COZE_TOKEN_INSUFFICIENT_ERROR_CODE } from './const/custom';
|
||||
export { BaseEnum, SpaceAppEnum } from './const/app';
|
||||
|
||||
// community bot store detail业务场景专用key值
|
||||
// Community bot store detailed business scenario specific key value
|
||||
export {
|
||||
defaultConversationKey,
|
||||
defaultConversationUniqId,
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
// While no validation logic is currently implemented prior to redirection,
|
||||
// there is the potential for such checks to be included in the future as per your requirements.
|
||||
export const redirect = (href: string) => {
|
||||
// 这里后续可以补充一些校验逻辑
|
||||
// Here, some verification logic can be added later.
|
||||
location.href = href;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user