Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
Falcon
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Walter Huang
Falcon
Commits
a014e1d3
Commit
a014e1d3
authored
Jun 25, 2025
by
Lin Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: change the diff fields name
parent
0b0147cd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
43 deletions
+102
-43
section_selectors.ts
src/constant/section_selectors.ts
+43
-0
diffWithDeepDiff.ts
src/detect_section_selector_masters/diffWithDeepDiff.ts
+28
-12
handlePageContent.ts
src/detect_section_selector_masters/handlePageContent.ts
+31
-31
No files found.
src/constant/section_selectors.ts
View file @
a014e1d3
...
...
@@ -19,6 +19,27 @@ export const section_selectors = [
"27656391"
]
export
const
sectionSelectorLanguages
:
Record
<
string
,
string
>
=
{
"27328697"
:
"EN"
,
"27328389"
:
"DE"
,
"27328392"
:
"ES"
,
"27328396"
:
"PT"
,
"27328399"
:
"FR"
,
"27328401"
:
"IT"
,
"27328404"
:
"JP"
,
"27328406"
:
"ID"
,
"27328408"
:
"NL"
,
"27328410"
:
"FI"
,
"27328412"
:
"SV"
,
"27328414"
:
"CS"
,
"27328415"
:
"RO"
,
"27328416"
:
"CN_ZH"
,
"27328417"
:
"CN_TW"
,
"27328419"
:
"AR"
,
"27665235"
:
"NO"
,
"27656391"
:
"PL"
}
export
const
ai_section_selectors
=
[
"29279960"
,
"29286540"
,
...
...
@@ -39,3 +60,24 @@ export const ai_section_selectors = [
"29278297"
,
"29279930"
]
export
const
aiSectionSelectorsLanguages
:
Record
<
string
,
string
>
=
{
"29279960"
:
"EN"
,
"29286540"
:
"DE"
,
"29286613"
:
"ES"
,
"29286646"
:
"PT"
,
"29278357"
:
"FR"
,
"29286780"
:
"IT"
,
"29278350"
:
"JP"
,
"29286835"
:
"ID"
,
"29286857"
:
"NL"
,
"29279949"
:
"FI"
,
"29278331"
:
"SV"
,
"29278319"
:
"CS"
,
"29278287"
:
"RO"
,
"29278284"
:
"CN_ZH"
,
"29278371"
:
"CN_TW"
,
"29279914"
:
"AR"
,
"29278297"
:
"NO"
,
"29279930"
:
"PL"
}
\ No newline at end of file
src/detect_section_selector_masters/diffWithDeepDiff.ts
View file @
a014e1d3
...
...
@@ -2,7 +2,7 @@
import
{
diff
}
from
'deep-diff'
;
import
{
readFileSync
,
writeFileSync
,
mkdirSync
,
rmSync
}
from
'fs'
;
import
{
join
}
from
'path'
;
import
{
section_selectors
,
ai_section_selector
s
}
from
'../constant/section_selectors'
;
import
{
section_selectors
,
sectionSelectorLanguages
,
ai_section_selectors
,
aiSectionSelectorsLanguage
s
}
from
'../constant/section_selectors'
;
// Directory containing JSON outputs to compare
const
srcDir
=
'src/detect_section_selector_masters/extractOutput'
;
...
...
@@ -18,11 +18,12 @@ mkdirSync(outDir, { recursive: true });
const
useAiSelectors
=
process
.
env
.
USE_AI_SELECTORS
===
'true'
;
// 根据环境变量选择使用哪个 selector 数组
const
selectedSelectors
=
useAiSelectors
?
ai_section_selectors
:
section_selectors
;
const
selectedLanguages
=
useAiSelectors
?
aiSectionSelectorsLanguages
:
sectionSelectorLanguages
;
// Baseline section ID (override via BASELINE_ID env variable)
const
EN_SITE_ID
=
27328697
;
const
AI_EN_SITE_ID
=
29279960
;
const
baselineId
=
useAiSelectors
?
AI_EN_SITE_ID
:
EN_SITE_ID
;
const
baselineId
=
useAiSelectors
?
AI_EN_SITE_ID
:
EN_SITE_ID
;
const
baselineFile
=
`
${
baselineId
}
_extract.json`
;
// Read baseline data
...
...
@@ -48,14 +49,14 @@ selectedSelectors
if
(
typeof
first
===
'number'
)
{
const
pageA
=
baselineData
[
first
]
||
{};
const
pageB
=
otherData
[
first
]
||
{};
context
.
baselineData
=
{
pageUid
:
pageA
.
pageUid
,
pageTitle
:
pageA
.
pageTitle
,
sectionIndex
:
pageA
.
sectionIndex
};
context
.
testData
=
{
pageUid
:
pageB
.
pageUid
,
pageTitle
:
pageB
.
pageTitle
,
sectionIndex
:
pageB
.
sectionIndex
};
context
[
selectedLanguages
[
baselineId
]]
=
{
pageUid
:
pageA
.
pageUid
,
pageTitle
:
pageA
.
pageTitle
,
sectionIndex
:
pageA
.
sectionIndex
};
context
[
selectedLanguages
[
otherId
]]
=
{
pageUid
:
pageB
.
pageUid
,
pageTitle
:
pageB
.
pageTitle
,
sectionIndex
:
pageB
.
sectionIndex
};
const
idx
=
change
.
path
.
indexOf
(
'result'
);
if
(
idx
!==
-
1
)
{
const
itemIdx
=
change
.
path
[
idx
+
1
];
if
(
typeof
itemIdx
===
'number'
)
{
context
.
baselineData
.
id
=
pageA
.
result
?.[
itemIdx
]?.
id
;
context
.
testData
.
id
=
pageB
.
result
?.[
itemIdx
]?.
id
;
context
[
selectedLanguages
[
baselineId
]]
.
id
=
pageA
.
result
?.[
itemIdx
]?.
id
;
context
[
selectedLanguages
[
otherId
]]
.
id
=
pageB
.
result
?.[
itemIdx
]?.
id
;
}
}
}
...
...
@@ -64,15 +65,30 @@ selectedSelectors
// Convert to semantic format
const
semantic
=
annotated
.
map
(
change
=>
{
const
map
:
Record
<
string
,
string
>
=
{
E
:
'
modified'
,
N
:
'added'
,
D
:
'deleted'
,
A
:
'arrayChange
'
};
const
map
:
Record
<
string
,
string
>
=
{
E
:
'
修改'
,
N
:
'新增'
,
D
:
'删除'
,
A
:
'数组类型的变更
'
};
const
type
=
map
[
change
.
kind
]
||
change
.
kind
;
const
pathStr
=
(
change
.
path
||
[]).
map
(
seg
=>
typeof
seg
===
'number'
?
`[
${
seg
}
]`
:
seg
).
join
(
'.'
);
let
oldV
:
any
,
newV
:
any
;
if
(
change
.
kind
===
'E'
)
{
oldV
=
(
change
as
any
).
lhs
;
newV
=
(
change
as
any
).
rhs
;
}
else
if
(
change
.
kind
===
'N'
)
{
newV
=
(
change
as
any
).
rhs
;
}
else
if
(
change
.
kind
===
'D'
)
{
oldV
=
(
change
as
any
).
lhs
;
}
else
if
(
change
.
kind
===
'A'
)
{
oldV
=
(
change
as
any
).
item
.
lhs
;
newV
=
(
change
as
any
).
item
.
rhs
;
}
return
{
changeType
:
type
,
path
:
pathStr
,
oldValue
:
oldV
,
newValue
:
newV
,
context
:
change
.
context
};
if
(
change
.
kind
===
'E'
)
{
oldV
=
(
change
as
any
).
lhs
;
newV
=
(
change
as
any
).
rhs
;
}
else
if
(
change
.
kind
===
'N'
)
{
oldV
=
(
change
as
any
).
lhs
;
newV
=
(
change
as
any
).
rhs
;
}
else
if
(
change
.
kind
===
'D'
)
{
oldV
=
(
change
as
any
).
lhs
;
newV
=
(
change
as
any
).
rhs
;
}
else
if
(
change
.
kind
===
'A'
)
{
oldV
=
(
change
as
any
).
item
.
lhs
;
newV
=
(
change
as
any
).
item
.
rhs
;
}
return
{
"更改类型"
:
type
,
"问题类型"
:
pathStr
,
[
`
${
selectedLanguages
[
baselineId
]}
模版值`
]:
oldV
,
[
`
${
selectedLanguages
[
otherId
]}
模版值`
]:
newV
,
context
:
change
.
context
};
});
const
outFile
=
`
${
baselineId
}
_vs_
${
otherId
}
_diff.json`
;
...
...
src/detect_section_selector_masters/handlePageContent.ts
View file @
a014e1d3
...
...
@@ -25,11 +25,11 @@ const DETECT_ONLY = commandMode === 'detect';
function
handleFullDiffNode
(
node
:
any
,
path
:
string
[],
output
:
any
)
{
// 检查当前节点是否为 RichText
if
(
node
.
type
===
"RichText"
)
{
const
getInlineColors
=
extractInlineColors
(
node
.
value
);
const
getInlineColors
=
extractInlineColors
(
node
.
value
)
.
join
(
','
)
;
output
.
result
.
push
({
type
:
"RichText"
,
path
:
path
.
join
(
'.'
),
inlineColors
:
getInlineColors
,
RichText_
type
:
"RichText"
,
RichText_
path
:
path
.
join
(
'.'
),
RichText_color
:
getInlineColors
,
id
:
node
.
id
||
null
});
}
...
...
@@ -40,10 +40,10 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
const
items
=
node
.
components
.
block1
?.
items
||
[];
items
.
filter
((
btn
:
any
)
=>
btn
.
type
===
"Button"
).
forEach
((
btn
:
any
)
=>
{
output
.
result
.
push
({
type
:
"Button"
,
path
:
path
.
join
(
'.'
),
color
:
btn
.
color
,
backgroundSettings
:
btn
.
backgroundSettings
||
{},
Button_
type
:
"Button"
,
Button_
path
:
path
.
join
(
'.'
),
Button_
color
:
btn
.
color
,
Button_
backgroundSettings
:
btn
.
backgroundSettings
||
{},
id
:
btn
.
id
||
null
});
});
...
...
@@ -52,24 +52,24 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
// 检查当前节点是否为 Button
if
(
node
.
type
===
"Button"
)
{
output
.
result
.
push
({
type
:
"Button"
,
path
:
path
.
join
(
'.'
),
color
:
node
.
color
,
backgroundSettings
:
node
.
backgroundSettings
||
{},
Button_
type
:
"Button"
,
Button_
path
:
path
.
join
(
'.'
),
Button_
color
:
node
.
color
,
Button_
backgroundSettings
:
node
.
backgroundSettings
||
{},
id
:
node
.
id
||
null
});
}
if
(
node
.
type
===
"SlideSettings"
&&
node
.
layout_config
?.
hasOwnProperty
(
"card"
))
{
output
.
result
.
push
({
type
:
'SlideSettings.layout_config.card'
,
path
:
path
.
join
(
'.'
),
card
:
node
.
layout_config
.
card
,
card_color
:
node
.
layout_config
.
card_color
,
border
:
node
.
layout_config
.
border
,
border_color
:
node
.
layout_config
.
border_color
,
cardBackgroundSettings
:
node
.
layout_config
.
cardBackgroundSettings
||
{},
borderBackgroundSettings
:
node
.
layout_config
.
borderBackgroundSettings
||
{},
featureList_
type
:
'SlideSettings.layout_config.card'
,
featureList_
path
:
path
.
join
(
'.'
),
featureList_
card
:
node
.
layout_config
.
card
,
featureList_
card_color
:
node
.
layout_config
.
card_color
,
featureList_
border
:
node
.
layout_config
.
border
,
featureList_
border_color
:
node
.
layout_config
.
border_color
,
featureList_
cardBackgroundSettings
:
node
.
layout_config
.
cardBackgroundSettings
||
{},
featureList_
borderBackgroundSettings
:
node
.
layout_config
.
borderBackgroundSettings
||
{},
id
:
node
.
id
||
null
,
})
}
...
...
@@ -80,26 +80,26 @@ function handleFullDiffNode(node: any, path: string[], output: any) {
const
useVideo
=
node
.
videoHtml
if
(
useImage
)
{
output
.
result
.
push
({
type
:
"Background.textColor"
,
textColor
:
node
.
textColor
||
''
,
path
:
path
.
join
(
"."
),
Background_textColor_
type
:
"Background.textColor"
,
Background_
textColor
:
node
.
textColor
||
''
,
Background_textColor_
path
:
path
.
join
(
"."
),
id
:
node
.
id
||
null
,
note
:
"The background is image"
,
Background_textColor_
note
:
"The background is image"
,
})
}
else
if
(
useVideo
)
{
output
.
result
.
push
({
type
:
"Background.videoHtml"
,
path
:
path
.
join
(
"."
),
Background_video_
type
:
"Background.videoHtml"
,
Background_video_
path
:
path
.
join
(
"."
),
id
:
node
.
id
||
null
,
note
:
"The background is video"
,
Background_video_
note
:
"The background is video"
,
})
}
else
{
output
.
result
.
push
({
type
:
"BackgroundColor"
,
backgroundC
olor
:
node
.
backgroundColor
?.
value
||
''
,
path
:
path
.
join
(
"."
),
Background_color_
type
:
"BackgroundColor"
,
Background_c
olor
:
node
.
backgroundColor
?.
value
||
''
,
Background_color_
path
:
path
.
join
(
"."
),
id
:
node
.
id
||
null
,
note
:
"The background is background color"
,
Background_color_
note
:
"The background is background color"
,
})
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment