chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -56,13 +56,13 @@ describe('Date', () => {
|
||||
expect(getCurrentTZ().utcOffset()).toBe(60 * 8);
|
||||
});
|
||||
it('#formatDate', () => {
|
||||
// 使用固定的时间戳,但验证格式而不是具体的时区值
|
||||
// Uses a fixed timestamp, but verifies the format rather than a specific timezone value
|
||||
const timestamp = 1718782764;
|
||||
const date = formatDate(timestamp);
|
||||
// 验证格式是否正确:YYYY/MM/DD HH:mm:ss
|
||||
// Verify that the format is correct: YYYY/MM/DD HH: mm: ss
|
||||
expect(date).toMatch(/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/);
|
||||
|
||||
// 验证时间戳转换的一致性:格式化后再解析应该得到相同的dayjs对象的日期部分
|
||||
// Verify consistency of timestamp conversions: Formatting and parsing should result in the same date portion of the dayjs object
|
||||
const formattedDayjs = dayjs(date, 'YYYY/MM/DD HH:mm:ss');
|
||||
const originalDayjs = dayjs.unix(timestamp);
|
||||
expect(formattedDayjs.unix()).toBe(originalDayjs.unix());
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
表格单元格宽度适配
|
||||
当 width 小于 WidthThresholds.Small 时应该返回 ColumnSize.Default。
|
||||
当 width 大于等于 WidthThresholds.Small 但小于 WidthThresholds.Medium 时应该返回 ColumnSize.Small。
|
||||
当 width 大于等于 WidthThresholds.Medium 但小于 WidthThresholds.Large 时应该返回 ColumnSize.Medium。
|
||||
当 width 大于等于 WidthThresholds.Large 时应该返回 ColumnSize.Large。
|
||||
当 minWidth 为 'auto' 时应该返回 'auto'。
|
||||
当 minWidth 是一个指定数字时,应该返回 minWidth 和 columnWidth 中较大的一个。*/
|
||||
Table cell width adaptation
|
||||
ColumnSize. Default should be returned when width is less than WidthThresholds. Small.
|
||||
ColumnSize. Small should be returned when width is greater than or equal to WidthThresholds. Small but less than WidthThresholds. Medium.
|
||||
ColumnSize. Medium should be returned when width is greater than or equal to WidthThresholds. Medium but less than WidthThresholds. Large.
|
||||
ColumnSize. Large should be returned when width is greater than or equal to WidthThresholds. Large.
|
||||
'Auto 'should be returned when minWidth is'auto'.
|
||||
When minWidth is a specified number, the larger of minWidth and columnWidth should be returned.*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
|
||||
@@ -25,12 +25,12 @@ export const ArrayUtil = {
|
||||
mapAndFilter,
|
||||
};
|
||||
|
||||
// region array2Map 重载声明
|
||||
// 和 OptionUtil.array2Map 虽然相似,但在用法和类型约束上还是很不一样的
|
||||
// Region array2Map Overload Statement
|
||||
// Although similar to OptionUtil.array2Map, it is still very different in terms of usage and type constraints
|
||||
/**
|
||||
* 将列表转化为 map
|
||||
* Convert a list to a map
|
||||
* @param items
|
||||
* @param key 指定 item[key] 作为 map 的键
|
||||
* @Param key Specifies item [key] as the key of the map
|
||||
* @example
|
||||
* const items = [{name: 'a', id: 1}];
|
||||
* array2Map(items, 'id');
|
||||
@@ -41,10 +41,10 @@ function array2Map<T extends Obj, K extends keyof T>(
|
||||
key: K,
|
||||
): Record<T[K], T>;
|
||||
/**
|
||||
* 将列表转化为 map
|
||||
* Convert a list to a map
|
||||
* @param items
|
||||
* @param key 指定 item[key] 作为 map 的键
|
||||
* @param value 指定 item[value] 作为 map 的值
|
||||
* @Param key Specifies item [key] as the key of the map
|
||||
* @Param value Specifies item [value] as the value of the map
|
||||
* @example
|
||||
* const items = [{name: 'a', id: 1}];
|
||||
* array2Map(items, 'id', 'name');
|
||||
@@ -56,10 +56,10 @@ function array2Map<T extends Obj, K extends keyof T, V extends keyof T>(
|
||||
value: V,
|
||||
): Record<T[K], T[V]>;
|
||||
/**
|
||||
* 将列表转化为 map
|
||||
* Convert a list to a map
|
||||
* @param items
|
||||
* @param key 指定 item[key] 作为 map 的键
|
||||
* @param value 获取值
|
||||
* @Param key Specifies item [key] as the key of the map
|
||||
* @param value get value
|
||||
* @example
|
||||
* const items = [{name: 'a', id: 1}];
|
||||
* array2Map(items, 'id', (item) => `${item.id}-${item.name}`);
|
||||
@@ -72,7 +72,7 @@ function array2Map<T extends Obj, K extends keyof T, V>(
|
||||
): Record<T[K], V>;
|
||||
// endregion
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/** 将列表转化为 map */
|
||||
/** Convert a list to a map */
|
||||
function array2Map<T extends Obj, K extends keyof T>(
|
||||
items: T[],
|
||||
key: K,
|
||||
@@ -111,10 +111,10 @@ function mapAndFilter<I = Obj, T = Obj>(
|
||||
const realValue = map ? map(currentValue) : currentValue;
|
||||
const filtered = filter ? filter(currentValue) : true;
|
||||
if (!filtered) {
|
||||
// 如果filtered是false,表示此项需要跳过
|
||||
// If filtered is false, this item needs to be skipped
|
||||
return previousValue;
|
||||
}
|
||||
// 如果filtered是true,表示需要加上此项
|
||||
// If filtered is true, it means that this item needs to be added
|
||||
return [...previousValue, realValue] as Array<I>;
|
||||
}, [] as Array<I>);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ export const formatDate = (v: number, template = 'YYYY/MM/DD HH:mm:ss') =>
|
||||
|
||||
export const CHINESE_TIMEZONE = 'Asia/Shanghai';
|
||||
|
||||
// 根据地区判断 海外返回UTC时间,国内返回北京时间
|
||||
// According to the regional judgment, return to UTC time overseas, and return to Beijing time domestically.
|
||||
export const getCurrentTZ = (param?: ConfigType): Dayjs => {
|
||||
if (IS_OVERSEA) {
|
||||
return dayjs(param).utc(true);
|
||||
@@ -56,18 +56,18 @@ export const getCurrentTZ = (param?: ConfigType): Dayjs => {
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取dayjs add后的时间戳
|
||||
* Get timestamp after dayjs add
|
||||
*/
|
||||
export const getTimestampByAdd = (value: number, unit?: ManipulateType) =>
|
||||
dayjs().add(value, unit).unix();
|
||||
|
||||
/**
|
||||
* 获取当前的时间戳
|
||||
* Get the current timestamp
|
||||
*/
|
||||
export const getCurrentTimestamp = () => dayjs().unix();
|
||||
|
||||
/**
|
||||
* 获取当前时间到次日UTC0点的时间间隔,精确到分钟
|
||||
* Gets the time interval between the current time and UTC0 the next day, accurate to the minute
|
||||
* e.g. 12h 30m
|
||||
*/
|
||||
export const getRemainTime = () => {
|
||||
@@ -81,43 +81,43 @@ export const getRemainTime = () => {
|
||||
};
|
||||
|
||||
/**
|
||||
* fork 自 packages/community/pages/src/bot/utils/index.ts
|
||||
* 将11位的时间戳按以下格式显示
|
||||
* 1. 不足一分钟, 显示”Just now“
|
||||
* 2. 不足1小时, 显示”{n}min ago“,例如 3min ago
|
||||
* 3. 不足1天,显示”{n}h ago",例如 3h ago
|
||||
* 4. 不足1个月,显示"{n}d ago", 例如 3d ago
|
||||
* 5. 超过1个月,显示“{MM}/{DD}/{yyyy}”,例如12/1/2024,中文是2024 年 12 月 1 日
|
||||
* Fork from packages/community/pages/src/bot/utils/index.ts
|
||||
* Display the 11-digit timestamp in the following format
|
||||
* 1. Less than a minute, showing "Just now"
|
||||
* 2. Less than 1 hour, showing "{n} min ago", such as 3min ago
|
||||
* 3. Less than 1 day, display "{n} h ago", such as 3h ago
|
||||
* 4. Less than 1 month, display "{n} d ago", such as 3d ago
|
||||
* 5. More than 1 month, display "{MM}/{DD}/{yyyy}", for example 12/1/2024, Chinese is December 1, 2024
|
||||
*
|
||||
*/
|
||||
export const formatTimestamp = (timestampMs: number) => {
|
||||
/** 秒级时间戳 */
|
||||
/** Second timestamp */
|
||||
const timestampSecond = Math.floor(timestampMs / 1000);
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const diff = now - timestampSecond;
|
||||
|
||||
// 将时间差转换成分钟、小时和天数
|
||||
// Convert time differences to minutes, hours, and days
|
||||
const minutes = Math.floor(diff / 60);
|
||||
const hours = Math.floor(diff / 3600);
|
||||
const days = Math.floor(diff / 86400);
|
||||
|
||||
// 不足一分钟,显示“Just now”
|
||||
// Less than a minute, showing "Just now"
|
||||
if (minutes < 1) {
|
||||
return I18n.t('community_time_just_now');
|
||||
}
|
||||
// 不足一小时,显示“{n}min ago”
|
||||
// Less than an hour, showing "{n} min ago"
|
||||
else if (hours < 1) {
|
||||
return I18n.t('community_time_min', { n: minutes });
|
||||
}
|
||||
// 不足一天,显示“{n}h ago”
|
||||
// Less than a day, showing "{n} h ago"
|
||||
else if (days < 1) {
|
||||
return I18n.t('community_time_hour', { n: hours });
|
||||
}
|
||||
// 不足一个月,显示“{n}d ago”
|
||||
// Less than a month, showing "{n} d ago"
|
||||
else if (days < 30) {
|
||||
return I18n.t('community_time_day', { n: days });
|
||||
}
|
||||
// 超过一个月,显示“{MM}/{DD}/{yyyy}”
|
||||
// More than a month, showing "{MM}/{DD}/{yyyy}"
|
||||
else {
|
||||
const dayObj = dayjs(timestampSecond * 1000);
|
||||
return I18n.t('community_time_date', {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* 获取最近一个可滚动元素
|
||||
* Get the latest scrollable element
|
||||
*/
|
||||
export function closestScrollableElement(element: HTMLElement) {
|
||||
const htmlElement = document.documentElement;
|
||||
@@ -47,7 +47,7 @@ export function closestScrollableElement(element: HTMLElement) {
|
||||
return htmlElement;
|
||||
}
|
||||
|
||||
// 解决浏览器拦截window.open行为,接口catch则跳错误兜底页
|
||||
// Solve browser interception window.open behavior, interface catch jump error default page
|
||||
export const openNewWindow = async (
|
||||
callbackUrl: () => Promise<string> | string,
|
||||
defaultUrl?: string,
|
||||
|
||||
@@ -30,9 +30,9 @@ export class BufferedEventEmitter<T extends EventEmitter.ValidEventTypes> {
|
||||
buffer: EventWithData<T>[] = [];
|
||||
|
||||
/**
|
||||
* 触发事件
|
||||
* @param event 事件名称
|
||||
* @param args 参数
|
||||
* trigger event
|
||||
* @param event name
|
||||
* @param args parameter
|
||||
*/
|
||||
emit<P extends EventEmitter.EventNames<T>>(
|
||||
event: P,
|
||||
@@ -49,9 +49,9 @@ export class BufferedEventEmitter<T extends EventEmitter.ValidEventTypes> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅事件
|
||||
* @param event 事件名称
|
||||
* @param fn 事件回调
|
||||
* subscribe to events
|
||||
* @param event name
|
||||
* @param fn event callback
|
||||
*/
|
||||
on<P extends EventEmitter.EventNames<T>>(
|
||||
event: P,
|
||||
@@ -61,9 +61,9 @@ export class BufferedEventEmitter<T extends EventEmitter.ValidEventTypes> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订阅事件
|
||||
* @param event 事件名称
|
||||
* @param fn 事件回调
|
||||
* unsubscribe from the event
|
||||
* @param event name
|
||||
* @param fn event callback
|
||||
*/
|
||||
off<P extends EventEmitter.EventNames<T>>(
|
||||
event: P,
|
||||
@@ -73,7 +73,7 @@ export class BufferedEventEmitter<T extends EventEmitter.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;
|
||||
@@ -83,14 +83,14 @@ export class BufferedEventEmitter<T extends EventEmitter.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 = [];
|
||||
@@ -105,7 +105,7 @@ const initEventEmitter = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 模块折叠 有关事件
|
||||
// Module folding, related events
|
||||
export enum OpenBlockEvent {
|
||||
DATA_MEMORY_BLOCK_OPEN = 'dataMemoryBlockOpen',
|
||||
TABLE_MEMORY_BLOCK_OPEN = 'tableMemoryBlockOpen',
|
||||
@@ -122,7 +122,7 @@ export enum OpenBlockEvent {
|
||||
BACKGROUND_IMAGE_BLOCK = 'BackgroundImageOpen',
|
||||
}
|
||||
|
||||
// 模块弹窗 有关事件
|
||||
// Module pop-ups, related events
|
||||
export enum OpenModalEvent {
|
||||
PLUGIN_API_MODAL_OPEN = 'pluginApiModalOpen',
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
import { isObject } from 'lodash-es';
|
||||
|
||||
/**
|
||||
* @param inputError 传啥都行,一般是 catch (e) 那个 e
|
||||
* @param reason 解释
|
||||
* @param inputError can pass anything, usually catch (e) that e.
|
||||
* @param reason explanation
|
||||
*/
|
||||
export const getReportError = (
|
||||
inputError: unknown,
|
||||
|
||||
@@ -66,7 +66,7 @@ export {
|
||||
draftEventEmitter,
|
||||
} from './event-handler';
|
||||
export { setMobileBody, setPCBody } from './viewport';
|
||||
/** 获取设备信息 */
|
||||
/** Get device information */
|
||||
export {
|
||||
getIsIPhoneOrIPad,
|
||||
getIsIPad,
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
import { reporter } from '@coze-arch/logger';
|
||||
import { CustomError } from '@coze-arch/bot-error';
|
||||
|
||||
// 这段代码是从 apps/bot/src/store/socket/utils.ts 复制出来的,后续也可以考虑统一
|
||||
// This code is copied from apps/bot/src/store/socket/utils.ts, and you can also consider unification in the future.
|
||||
const hasSuggestion = (ext?: unknown) =>
|
||||
isObject(ext) && 'has_suggest' in ext && ext.has_suggest === '1';
|
||||
|
||||
@@ -113,7 +113,7 @@ export class MessageReportEvent {
|
||||
|
||||
private _receiveTotalMessagesEvent = {
|
||||
start: () => {
|
||||
// 打断了
|
||||
// interrupted
|
||||
this._receiveTotalMessagesReportEvent =
|
||||
this._createReceiveTotalMessagesEvent();
|
||||
},
|
||||
@@ -219,7 +219,7 @@ export class MessageReportEvent {
|
||||
return;
|
||||
}
|
||||
if (!message.content) {
|
||||
// 回复消息为空的错误事件上报
|
||||
// Error event reporting with empty reply message
|
||||
reporter.errorEvent({
|
||||
eventName: ReportEventNames.emptyReceiveMessage,
|
||||
error: new CustomError(
|
||||
|
||||
@@ -38,7 +38,7 @@ const THOUSAND = 1e3;
|
||||
const MILLION = 1e6;
|
||||
const BILLION = 1e9;
|
||||
const TRILLION = 1e12;
|
||||
//将数字转换成K、M等单位
|
||||
//Convert numbers into K, M, and other units
|
||||
export const formatNumber = (num: number) => {
|
||||
const absNum = Math.abs(num);
|
||||
if (absNum >= TRILLION) {
|
||||
@@ -56,7 +56,7 @@ export const formatNumber = (num: number) => {
|
||||
return num;
|
||||
};
|
||||
|
||||
// 将数字转换成百分数, 向上取整
|
||||
// Convert a number to a percentage, round it up
|
||||
export const formatPercent = (num?: number): string => {
|
||||
if (num === undefined || num === null) {
|
||||
return 'NaN%';
|
||||
@@ -65,17 +65,17 @@ export const formatPercent = (num?: number): string => {
|
||||
|
||||
let formatted = percentage.toFixed(1);
|
||||
|
||||
// 如果小数点后一位是0,则移除小数点和0
|
||||
// If the decimal place is 0, remove the decimal point and 0.
|
||||
if (formatted.endsWith('.0')) {
|
||||
formatted = formatted.slice(0, -2);
|
||||
}
|
||||
|
||||
// 添加百分号并返回结果
|
||||
// Add a percent sign and return the result
|
||||
return `${formatted}%`;
|
||||
};
|
||||
|
||||
// 格式化时间, 毫秒, 保留一位小数点
|
||||
// 比如6.7s, 3.2min, 100ms, 1.3h
|
||||
// Format time, milliseconds, one decimal place reserved
|
||||
// For example, 6.7s, 3.2min, 100ms, 1.3h
|
||||
export const formatTime = (ms: number) => {
|
||||
const absMs = Math.abs(ms);
|
||||
|
||||
@@ -103,7 +103,7 @@ export const getEllipsisCount = (num: number, max: number): string =>
|
||||
num > max ? `${max}+` : `${num}`;
|
||||
|
||||
/**
|
||||
* @deprecated 不知道这个函数是干啥的。。。
|
||||
* @Deprecated doesn't know what this function does...
|
||||
*/
|
||||
export const exhaustiveCheck = (_v: never) => {
|
||||
// empty
|
||||
|
||||
@@ -20,8 +20,8 @@ const browser = Browser.getParser(window.navigator.userAgent);
|
||||
|
||||
let getIsMobileCache: boolean | undefined;
|
||||
/**
|
||||
* 是否是移动设备
|
||||
* 注:ipad 不是移动设备
|
||||
* Is it a mobile device?
|
||||
* Note: iPad is not a mobile device
|
||||
*/
|
||||
const isMobile = () => browser.getPlatformType(true).includes('mobile');
|
||||
|
||||
@@ -34,7 +34,7 @@ export const getIsMobile = () => {
|
||||
|
||||
let getIsIPhoneOrIPadCache: boolean | undefined;
|
||||
/**
|
||||
* gpt-4 提供的代码
|
||||
* Code provided by gpt-4
|
||||
*/
|
||||
export const getIsIPhoneOrIPad = () => {
|
||||
if (typeof getIsIPhoneOrIPadCache === 'undefined') {
|
||||
@@ -52,7 +52,7 @@ export const getIsIPhoneOrIPad = () => {
|
||||
|
||||
let getIsIPadCache: boolean | undefined;
|
||||
/**
|
||||
* gpt-4 提供的代码
|
||||
* Code provided by gpt-4
|
||||
*/
|
||||
export const getIsIPad = () => {
|
||||
if (typeof getIsIPadCache === 'undefined') {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import EventEmitter from 'eventemitter3';
|
||||
|
||||
interface BusinessData<T> {
|
||||
code: number; // 0: 成功, 其他: 错误码,业务tidying
|
||||
code: number; // 0: success, others: error codes, business tidying
|
||||
data?: T;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
@@ -55,11 +55,11 @@ export const responsiveTableColumn = (
|
||||
return 'auto';
|
||||
}
|
||||
|
||||
// 查找第一个符合条件的项
|
||||
// Find the first eligible item
|
||||
const range =
|
||||
colWidthRanges.find(colWidth => width >= colWidth.threshold) ||
|
||||
defaultRange;
|
||||
|
||||
// 返回 minWidth 或找到的 columnWidth,取决于哪个更大
|
||||
// Return minWidth or found columnWidth, depending on which is larger
|
||||
return Math.max(minWidth, range.columnWidth);
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ import { REPORT_EVENTS } from '@coze-arch/report-events';
|
||||
import { logger, reporter } from '@coze-arch/logger';
|
||||
|
||||
/**
|
||||
* @deprecated 这其实是 unsafe 的,请换用 typeSafeJSONParse
|
||||
* @Deprecated This is actually unsafe, please use typeSafeJSONParse instead
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const safeJSONParse: (v: any, emptyValue?: any) => any = (
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
import { type SkillKeyEnum } from '@coze-agent-ide/tool-config';
|
||||
|
||||
/**
|
||||
* `能力模块主键` 转 `接口定义的属性名` 函数
|
||||
* ⚠️ 命名需参看 @/services/auto-generate/developer_api/namespaces/developer_api > TabDisplayItems
|
||||
* 'Capability module primary key 'to'interface-defined attribute name' function
|
||||
* ⚠️ For naming, see @/services/auto-generate/developer_api/namespaces/developer_api > TabDisplayItems
|
||||
*/
|
||||
export const skillKeyToApiStatusKeyTransformer = ($key: SkillKeyEnum) =>
|
||||
`${$key}_tab_status`;
|
||||
|
||||
@@ -39,8 +39,8 @@ const removeAllListeners = (instance: UploaderInstance) => {
|
||||
export interface FileItem {
|
||||
file: File;
|
||||
/**
|
||||
* 非图片的文件 type 为 object
|
||||
* 这里显得很奇怪, 是为了对齐 @byted/uploader 的设计
|
||||
* Non-image file type is object
|
||||
* This seems strange, to align the design of @byted/uploader
|
||||
*/
|
||||
fileType: 'image' | 'object';
|
||||
}
|
||||
@@ -61,12 +61,12 @@ export interface UploadFileV2Param {
|
||||
}
|
||||
|
||||
/**
|
||||
* 改良版本的上传方法
|
||||
* 1. 能够支持打断, 清除副作用
|
||||
* 2. 更完善的回调函数
|
||||
* 3. 支持一次上传多文件
|
||||
* Improved version upload method
|
||||
* 1. Able to support interruption and clear side effects
|
||||
* 2. Better callback function
|
||||
* 3. Support uploading multiple files at one time
|
||||
*/
|
||||
// eslint-disable-next-line max-lines-per-function -- 内部的方法分了模块但是都依赖同一个 context 作打断无法拆出去
|
||||
// eslint-disable-next-line max-lines-per-function -- the internal methods are divided into modules, but they all rely on the same context for interruption and cannot be removed
|
||||
export function uploadFileV2({
|
||||
fileItemList,
|
||||
userId,
|
||||
@@ -125,13 +125,13 @@ export function uploadFileV2({
|
||||
{
|
||||
schema,
|
||||
useFileExtension: true,
|
||||
// 解决报错问题:
|
||||
// Solve the error problem:
|
||||
userId,
|
||||
appId: APP_ID,
|
||||
// cp-disable-next-line
|
||||
imageHost: `https://${upload_host}`, //imageX上传必填
|
||||
imageHost: `https://${upload_host}`, //imageX upload required
|
||||
imageConfig: {
|
||||
serviceId: service_id || '', // 在视频云中申请的服务id
|
||||
serviceId: service_id || '', // The service id applied for in the video cloud.
|
||||
},
|
||||
objectConfig: {
|
||||
serviceId: service_id || '',
|
||||
@@ -155,7 +155,7 @@ export function uploadFileV2({
|
||||
AccessKeyId: auth?.access_key_id || '',
|
||||
SecretAccessKey: auth?.secret_access_key || '',
|
||||
},
|
||||
type: fileType, // 上传文件类型,三个可选值:video(视频或者音频,默认值),image(图片),object(普通文件)
|
||||
type: fileType, // Upload file type, three optional values: video (video or audio, default), image (picture), object (normal file)
|
||||
});
|
||||
return { file, fileType, fileKey };
|
||||
});
|
||||
@@ -170,7 +170,7 @@ export function uploadFileV2({
|
||||
|
||||
list.push(inform as any);
|
||||
if (list.length === fileAndKeyList.length) {
|
||||
// 按顺序赋值
|
||||
// Assignment in order
|
||||
// @ts-expect-error -- linter-disable-autofix
|
||||
list = fileAndKeyList.map(({ fileKey }) =>
|
||||
list.find(v => v.key === fileKey),
|
||||
|
||||
@@ -106,13 +106,13 @@ export function upLoadFile({
|
||||
getUploader,
|
||||
getUploadAuthToken,
|
||||
}: {
|
||||
/** 业务, 不同业务对应不同的 ImageX 服务 */
|
||||
/** Business, different businesses correspond to different ImageX services */
|
||||
biz?: 'bot' | 'workflow' | string;
|
||||
file: File;
|
||||
fileType?: 'image' | 'object';
|
||||
getProgress?: (progress: number) => void;
|
||||
getUploader?: (uploader: BytedUploader) => void;
|
||||
// 业务方自己获取upload token
|
||||
// The business party obtains the upload token by itself
|
||||
getUploadAuthToken?: () => Promise<developer_api.GetUploadAuthTokenResponse>;
|
||||
}) {
|
||||
const config = bizConfig[biz];
|
||||
@@ -163,9 +163,9 @@ export function upLoadFile({
|
||||
userId: userStoreService.getUserInfo()?.user_id_str || '',
|
||||
appId: APP_ID,
|
||||
// cp-disable-next-line
|
||||
imageHost: `https://${uploadHost}`, //imageX上传必填
|
||||
imageHost: `https://${uploadHost}`, //imageX upload required
|
||||
imageConfig: {
|
||||
serviceId: serviceId || '', // 在视频云中申请的服务id
|
||||
serviceId: serviceId || '', // The service id applied for in the video cloud.
|
||||
},
|
||||
objectConfig: {
|
||||
serviceId: serviceId || '',
|
||||
@@ -196,7 +196,7 @@ export function upLoadFile({
|
||||
const fileKey = bytedUploader.addFile({
|
||||
file,
|
||||
stsToken,
|
||||
type: fileType, // 上传文件类型,三个可选值:video(视频或者音频,默认值),image(图片),object(普通文件)
|
||||
type: fileType, // Upload file type, three optional values: video (video or audio, default), image (picture), object (normal file)
|
||||
});
|
||||
bytedUploader.start(fileKey);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user