@@ -222,7 +222,12 @@ const detectPageTechnologies = async (ruleConfig: Record<string, unknown> = {})
222222 }
223223
224224 function detectUiFrameworks ( add , resources , classes , cssVariables , html , externalRules ) {
225- if ( scoreTailwind ( classes ) >= 10 ) {
225+ const atomicCssOrigin = detectAtomicCssOrigin ( cssVariables )
226+ if ( atomicCssOrigin === 'unocss' ) {
227+ add ( 'UI / CSS 框架' , 'UnoCSS' , '高' , '存在 --un-* CSS 变量(UnoCSS 默认前缀)' )
228+ } else if ( atomicCssOrigin === 'tailwind' ) {
229+ add ( 'UI / CSS 框架' , 'Tailwind CSS' , '高' , '存在 --tw-* CSS 变量(Tailwind 默认前缀)' )
230+ } else if ( scoreTailwind ( classes ) >= 10 ) {
226231 add ( 'UI / CSS 框架' , 'Tailwind CSS' , '中' , '存在大量 Tailwind 风格原子类名' )
227232 }
228233
@@ -238,6 +243,45 @@ const detectPageTechnologies = async (ruleConfig: Record<string, unknown> = {})
238243 } )
239244 }
240245
246+ function detectAtomicCssOrigin ( cssVariables ) {
247+ const names = cssVariables ?. names || [ ]
248+ let hasUn = false
249+ let hasTw = false
250+ for ( const name of names ) {
251+ if ( ! hasUn && name . startsWith ( '--un-' ) ) hasUn = true
252+ if ( ! hasTw && name . startsWith ( '--tw-' ) ) hasTw = true
253+ if ( hasUn && hasTw ) break
254+ }
255+ if ( hasUn ) return 'unocss'
256+ if ( hasTw ) return 'tailwind'
257+
258+ try {
259+ for ( const sheet of document . styleSheets ) {
260+ let rules
261+ try {
262+ rules = sheet . cssRules
263+ } catch {
264+ continue
265+ }
266+ if ( ! rules ) continue
267+ const limit = rules . length < 400 ? rules . length : 400
268+ for ( let i = 0 ; i < limit ; i ++ ) {
269+ const text = rules [ i ] ?. cssText || ''
270+ if ( ! hasUn && text . includes ( '--un-' ) ) hasUn = true
271+ if ( ! hasTw && text . includes ( '--tw-' ) ) hasTw = true
272+ if ( hasUn || hasTw ) break
273+ }
274+ if ( hasUn || hasTw ) break
275+ }
276+ } catch {
277+ // ignore
278+ }
279+
280+ if ( hasUn ) return 'unocss'
281+ if ( hasTw ) return 'tailwind'
282+ return ''
283+ }
284+
241285 function detectAdditionalFrontendTechnologies ( add , resources , classes , html , externalRules ) {
242286 const text = `${ resources . text } \n${ html } `
243287 detectJsonRuleList ( add , externalRules , {
0 commit comments