mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-24 15:36:50 +08:00
Fix: Updated color parsing functions and optimized component logic. (#10159)
### What problem does this PR solve? refactor(timeline, modal, dataflow-result, dataset-overview): Updated color parsing functions and optimized component logic. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -45,6 +45,7 @@ export default {
|
||||
getKnowledgeGraph: (knowledgeId: string) =>
|
||||
`${api_host}/kb/${knowledgeId}/knowledge_graph`,
|
||||
getMeta: `${api_host}/kb/get_meta`,
|
||||
getKnowledgeBasicInfo: `${api_host}/kb/basic_info`,
|
||||
|
||||
// tags
|
||||
listTag: (knowledgeId: string) => `${api_host}/kb/${knowledgeId}/tags`,
|
||||
@ -192,7 +193,6 @@ export default {
|
||||
retrievalTestShare: `${ExternalApi}${api_host}/searchbots/retrieval_test`,
|
||||
|
||||
// data pipeline
|
||||
|
||||
fetchDataflow: (id: string) => `${api_host}/dataflow/get/${id}`,
|
||||
setDataflow: `${api_host}/dataflow/set`,
|
||||
removeDataflow: `${api_host}/dataflow/rm`,
|
||||
|
||||
@ -152,8 +152,11 @@ function getCSSVariableValue(variableName: string): string {
|
||||
return value;
|
||||
}
|
||||
|
||||
// Parse the color and convert to RGBA
|
||||
export function parseColorToRGBA(color: string): [number, number, number] {
|
||||
/**Parse the color and convert to RGB,
|
||||
* #fff -> [255, 255, 255]
|
||||
* var(--text-primary) -> [var(--text-primary-r), var(--text-primary-g), var(--text-primary-b)]
|
||||
* */
|
||||
export function parseColorToRGB(color: string): [number, number, number] {
|
||||
// Handling CSS variables (e.g. var(--accent-primary))
|
||||
let colorStr = color;
|
||||
if (colorStr.startsWith('var(')) {
|
||||
@ -203,3 +206,14 @@ export function parseColorToRGBA(color: string): [number, number, number] {
|
||||
console.error(`Unsupported colorStr format: ${colorStr}`);
|
||||
return [0, 0, 0];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param color eg: #fff, or var(--color-text-primary)
|
||||
* @param opcity 0~1
|
||||
* @return rgba(r,g,b,opcity)
|
||||
*/
|
||||
export function parseColorToRGBA(color: string, opcity = 1): string {
|
||||
const [r, g, b] = parseColorToRGB(color);
|
||||
return `rgba(${r},${g},${b},${opcity})`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user