chore: 项目基线(基于 WeKnora 定制版,整理文件忽略规则)
This commit is contained in:
commit
9097ee699d
5769 files changed
+1446466
No files matched your search
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Helpers for cached API payloads that vary by Accept-Language
|
||||
* (built-in agent names/descriptions, shared-agent lists, …).
|
||||
*
|
||||
* The request must stamp the locale it was *started* with. Stamping
|
||||
* getCurrentLanguage() after await lets a zh-CN response be marked as the
|
||||
* en-US snapshot when the user switches language while the call is in flight.
|
||||
*/
|
||||
|
||||
/** A localized snapshot is only usable for the UI language it was fetched in. */
|
||||
export function isLocalizedSnapshotUsable(
|
||||
loaded: boolean,
|
||||
loadedLocale: string,
|
||||
currentLocale: string,
|
||||
): boolean {
|
||||
return loaded && loadedLocale !== '' && loadedLocale === currentLocale
|
||||
}
|
||||
|
||||
/** Reuse an in-flight list request only when it was started for this UI language. */
|
||||
export function shouldReuseLocalizedInflight(
|
||||
hasInflight: boolean,
|
||||
inflightLocale: string,
|
||||
currentLocale: string,
|
||||
): boolean {
|
||||
return hasInflight && inflightLocale !== '' && inflightLocale === currentLocale
|
||||
}
|
||||
|
||||
/**
|
||||
* Force a follow-up fetch when the in-flight request was started for a
|
||||
* different UI language. versionedRequestCoordinator reuses in-flight on
|
||||
* non-force fetch, so locale mismatch must opt into force.
|
||||
*/
|
||||
export function shouldForceLocalizedRefetch(
|
||||
hasInflight: boolean,
|
||||
inflightLocale: string,
|
||||
currentLocale: string,
|
||||
): boolean {
|
||||
return hasInflight && inflightLocale !== '' && inflightLocale !== currentLocale
|
||||
}
|
||||
Reference in new issue
Block a user