Skip to content

Commit 1d21d63

Browse files
Search index race hardening, presence status fixes, and shun consensus correction (#295)
1 parent 5a8264d commit 1d21d63

69 files changed

Lines changed: 716 additions & 383 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.esh/commands/update-locales.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ def translate_value(value, source_lang, target_lang):
496496

497497

498498
# 与前端 translateSingularElement / i18n_refs.mjs 对齐的 DOM applicator 字段
499-
I18N_ELEMENT_APPLICATOR_KEYS = frozenset({
499+
I18N_ELEMENT_APPLICATOR_KEYS = {
500500
"placeholder",
501501
"title",
502502
"label",
@@ -506,7 +506,7 @@ def translate_value(value, source_lang, target_lang):
506506
"textContent",
507507
"innerHTML",
508508
"dataset",
509-
})
509+
}
510510

511511
# 同步过程中无法自动对齐的类型不匹配(脚本结束时 exit 1)
512512
type_mismatch_errors: list[str] = []

.github/actions/update-repo-description/pick.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def lunar_month_day(today: date) -> str | None:
3030
day = solar_day(today)
3131
if day.isLunarLeap():
3232
return None
33-
return f'{day.getLunarMonth():02d}-{day.getLunarDay():02d}'
33+
return f"{day.getLunarMonth():02d}-{day.getLunarDay():02d}"
3434

3535

3636
def solar_term_name(today: date) -> str | None:
@@ -41,24 +41,24 @@ def solar_term_name(today: date) -> str | None:
4141

4242

4343
def holiday_matches(holiday: dict, today: date) -> bool:
44-
if any(date_value in (today.strftime('%m-%d'), today.isoformat()) for date_value in holiday.get('dates') or ()):
44+
if any(date_value in (today.strftime("%m-%d"), today.isoformat()) for date_value in holiday.get("dates") or ()):
4545
return True
46-
lunar_dates = holiday.get('lunar') or ()
46+
lunar_dates = holiday.get("lunar") or ()
4747
if lunar_dates:
4848
lunar_date = lunar_month_day(today)
4949
if lunar_date and lunar_date in lunar_dates:
5050
return True
51-
terms = holiday.get('jieqi') or ()
51+
terms = holiday.get("jieqi") or ()
5252
if terms:
5353
solar_term = solar_term_name(today)
5454
if solar_term and solar_term in terms:
5555
return True
56-
yearday = holiday.get('yearday')
56+
yearday = holiday.get("yearday")
5757
return yearday is not None and today.timetuple().tm_yday == yearday
5858

5959

6060
def match_holiday(config: dict, today: date) -> dict | None:
61-
for holiday in config.get('holidays') or ():
61+
for holiday in config.get("holidays") or ():
6262
if holiday_matches(holiday, today):
6363
return holiday
6464
return None
@@ -67,9 +67,9 @@ def match_holiday(config: dict, today: date) -> dict | None:
6767
def pick_pool(config: dict, today: date) -> tuple[list[str], str | None]:
6868
holiday = match_holiday(config, today)
6969
if holiday:
70-
return list(holiday.get('descriptions') or ()), holiday.get('name') or 'holiday'
71-
core = list(config.get('core') or ())
72-
extras = config.get('extras')
70+
return list(holiday.get("descriptions") or ()), holiday.get("name") or "holiday"
71+
core = list(config.get("core") or ())
72+
extras = config.get("extras")
7373
extras = list(extras) if isinstance(extras, list) else []
7474
if core and extras:
7575
pool = core if random.random() < 0.7 else extras
@@ -87,46 +87,46 @@ def resolve_today(timezone: str, date_override: str) -> date:
8787

8888

8989
def write_github_output(description: str, holiday_name: str | None, today: date) -> None:
90-
path = os.environ.get('GITHUB_OUTPUT')
90+
path = os.environ.get("GITHUB_OUTPUT")
9191
if not path:
9292
return
93-
with open(path, 'a', encoding='utf-8') as output_file:
94-
output_file.write('description<<EOF\n')
95-
output_file.write(f'{description}\n')
96-
output_file.write('EOF\n')
97-
output_file.write(f'holiday={holiday_name or ""}\n')
98-
output_file.write(f'date={today.isoformat()}\n')
93+
with open(path, "a", encoding="utf-8") as output_file:
94+
output_file.write("description<<EOF\n")
95+
output_file.write(f"{description}\n")
96+
output_file.write("EOF\n")
97+
output_file.write(f"holiday={holiday_name or ''}\n")
98+
output_file.write(f"date={today.isoformat()}\n")
9999

100100

101101
def main(arguments: list[str] | None = None) -> int:
102102
arguments = list(sys.argv[1:] if arguments is None else arguments)
103103
if len(arguments) < 1:
104-
print('usage: pick.py <config.json> [timezone] [YYYY-MM-DD]', file=sys.stderr)
104+
print("usage: pick.py <config.json> [timezone] [YYYY-MM-DD]", file=sys.stderr)
105105
return 2
106106
config_path = arguments[0]
107-
timezone = arguments[1] if len(arguments) > 1 and arguments[1] else 'Asia/Shanghai'
108-
date_override = arguments[2] if len(arguments) > 2 else ''
107+
timezone = arguments[1] if len(arguments) > 1 and arguments[1] else "Asia/Shanghai"
108+
date_override = arguments[2] if len(arguments) > 2 else ""
109109

110-
with open(config_path, encoding='utf-8') as config_file:
110+
with open(config_path, encoding="utf-8") as config_file:
111111
config = json5.load(config_file)
112112

113113
today = resolve_today(timezone, date_override)
114114
pool, holiday_name = pick_pool(config, today)
115115
if not pool:
116-
print(f'No descriptions available for today ({today.isoformat()})', file=sys.stderr)
116+
print(f"No descriptions available for today ({today.isoformat()})", file=sys.stderr)
117117
return 1
118118
description = random.choice(pool)
119119
if len(description) > 350:
120-
print(f'Description exceeds 350 characters ({len(description)})', file=sys.stderr)
120+
print(f"Description exceeds 350 characters ({len(description)})", file=sys.stderr)
121121
return 1
122122

123123
write_github_output(description, holiday_name, today)
124-
print(f'date={today.isoformat()}', file=sys.stderr)
124+
print(f"date={today.isoformat()}", file=sys.stderr)
125125
if holiday_name:
126-
print(f'holiday={holiday_name}', file=sys.stderr)
127-
print(f'description={description}', file=sys.stderr)
126+
print(f"holiday={holiday_name}", file=sys.stderr)
127+
print(f"description={description}", file=sys.stderr)
128128
return 0
129129

130130

131-
if __name__ == '__main__':
131+
if __name__ == "__main__":
132132
raise SystemExit(main())

.github/pages/test/frontend/smoke.spec.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ test.describe('GitHub Pages smoke', () => {
2626

2727
test('utm_source shows welcome dialog after hero intro', async ({ page, baseUrl }) => {
2828
const dialog = page.locator('#utm-welcome-dialog')
29+
/**
30+
* 打开带 utm_source 的安装页并等待欢迎弹窗。
31+
*/
2932
const openWelcome = async () => {
3033
await page.goto(`${baseUrl}/wait/install/?utm_source=linux.sb`, { waitUntil: 'domcontentloaded' })
3134
await expect(page.locator('.hero-content.visible-after-intro')).toBeVisible({ timeout: 30_000 })

0 commit comments

Comments
 (0)