Skip to content

extractColorsFromVueSection

从Vue文件的某个section中提取颜色。

函数签名

typescript
function extractColorsFromVueSection(
  section: VueSection,
  filePath: string,
  options?: VueProcessingOptions
): ColorReference[]

interface VueSection {
  type: VueSectionType
  content: string
  startLine: number
  endLine: number
}

参数

参数名类型必填说明
sectionVueSectionVue文件的section对象
filePathstring文件路径
optionsVueProcessingOptions处理选项

返回值

类型说明
ColorReference[]提取到的颜色引用数组

工作原理

根据section类型使用不同的提取策略:

  • template: 从HTML属性和文本中提取颜色
  • script: 从JavaScript代码中提取颜色值
  • style: 从CSS代码中提取颜色

适用于从Vue文件的特定部分提取颜色引用。