mirror of
https://github.com/labring/FastGPT.git
synced 2026-04-21 01:01:33 +08:00
f626c961fb
* icon & gradient * line & header ui * basic presentation mode * ui & icon * node * fix * source color schema * delete code * fix build * fix * fix * fix icon * function position
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import { NodeGradients, NodeBorderColors } from '@fastgpt/global/core/workflow/node/constant';
|
|
import { AppToolSourceEnum } from '@fastgpt/global/core/app/tool/constants';
|
|
import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
|
|
|
|
const getColorSchemaBySource = (source: AppToolSourceEnum) => {
|
|
if (source === AppToolSourceEnum.http || source === AppToolSourceEnum.mcp) {
|
|
return 'salmon';
|
|
}
|
|
if (
|
|
source === AppToolSourceEnum.commercial ||
|
|
source === AppToolSourceEnum.community ||
|
|
source === AppToolSourceEnum.systemTool
|
|
) {
|
|
return 'gray';
|
|
}
|
|
return undefined;
|
|
};
|
|
|
|
export const getGradientByColorSchema = ({
|
|
colorSchema,
|
|
source
|
|
}: {
|
|
colorSchema?: keyof typeof NodeGradients;
|
|
source: AppToolSourceEnum;
|
|
}): string | undefined => {
|
|
const sourceColor = getColorSchemaBySource(source);
|
|
if (sourceColor) {
|
|
return NodeGradients[sourceColor];
|
|
}
|
|
if (!colorSchema) return undefined;
|
|
return NodeGradients[colorSchema];
|
|
};
|
|
|
|
export const getBorderColorByColorSchema = ({
|
|
colorSchema,
|
|
source
|
|
}: {
|
|
colorSchema?: keyof typeof NodeBorderColors;
|
|
source: AppToolSourceEnum;
|
|
}): string | undefined => {
|
|
const sourceColor = getColorSchemaBySource(source);
|
|
if (sourceColor) {
|
|
return NodeBorderColors[sourceColor];
|
|
}
|
|
if (!colorSchema) return undefined;
|
|
return NodeBorderColors[colorSchema];
|
|
};
|
|
|
|
export const getColorSchemaByFlowNodeType = (
|
|
flowNodeType: FlowNodeTypeEnum
|
|
): keyof typeof NodeGradients | undefined => {
|
|
if (flowNodeType === FlowNodeTypeEnum.toolSet || flowNodeType === FlowNodeTypeEnum.pluginModule) {
|
|
return 'salmon';
|
|
}
|
|
if (flowNodeType === FlowNodeTypeEnum.appModule) {
|
|
return 'skyBlue';
|
|
}
|
|
return undefined;
|
|
};
|