mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00

* doc * feat: file upload config * perf: chat box file params * feat: markdown show file * feat: chat file store and clear * perf: read file contentType * feat: llm vision config * feat: file url output * perf: plugin error text * perf: image load * feat: ai chat document * perf: file block ui * feat: read file node * feat: file read response field * feat: simple mode support read files * feat: tool call * feat: read file histories * perf: select file * perf: select file config * i18n * i18n * fix: ts; feat: tool response preview result
23 lines
497 B
TypeScript
23 lines
497 B
TypeScript
import { useMemo } from 'react';
|
|
|
|
export const useWidthVariable = <T = any>({
|
|
width,
|
|
widthList = [900, 1200, 1500, 1800, 2100],
|
|
list
|
|
}: {
|
|
width: number;
|
|
widthList?: number[];
|
|
list: T[];
|
|
}) => {
|
|
const value = useMemo(() => {
|
|
// 根据 width 计算,找到第一个大于 width 的值
|
|
const index = widthList.findLastIndex((item) => width > item);
|
|
if (index === -1) {
|
|
return list[0];
|
|
}
|
|
return list[index];
|
|
}, [list, width, widthList]);
|
|
|
|
return value;
|
|
};
|