chore: replace all cn comments of fe to en version by volc api (#320)

This commit is contained in:
tecvan
2025-07-31 10:32:15 +08:00
committed by GitHub
parent 716ec0cba8
commit 71f6245a01
2960 changed files with 15545 additions and 15545 deletions

View File

@@ -25,8 +25,8 @@ export interface HistoryState {
uri?: string;
/**
* 在栈中的索引
* react-router 使用「idx」使用「fIdx」防止串数据
* Index on the stack
* React-router uses "idx" and "fIdx" to prevent string data
*/
fIdx?: number;
}
@@ -71,8 +71,8 @@ export class BrowserHistory implements Disposable {
init() {
/**
* 初始化的时候 index 必然为 null
* 如果不是,说明有别的框架或者在直接使用 history.pushState 或者 history.replaceState 污染
* When initializing, the index must be null.
* If not, it means that there is another framework or pollution directly using history.pushState or history.replaceState
*/
if (this.idx === null) {
this.history.replaceState({ ...this.state, fIdx: -1, uri: '' }, '');
@@ -95,8 +95,8 @@ export class BrowserHistory implements Disposable {
this.history.pushState(state, '', url);
} catch {
/**
* history 还是有可能因为 state 或者浏览器等原因挂掉的
* 降级成直接跳转
* History may still die due to state or browser reasons
* Downgrade to direct jump
*/
this.window.location.assign(url);
}

View File

@@ -25,11 +25,11 @@ import {
import { type URI } from '../common';
import { BrowserHistory, type HistoryState } from './browser-history';
/** location 结构 */
/** Location structure */
interface Location {
/** 唯一标识,一般来说是 uri */
/** The unique identifier is usually a uri. */
uri: URI;
/** 预留字段 */
/** reserved field */
}
@injectable()
@@ -68,7 +68,7 @@ class NavigationHistory {
}
pushOrReplace(location: Location, replace = false) {
// 如果处于回退状态,则清除之后所有的历史
// If it is in a fallback state, all subsequent history is cleared
if (this.stack.length > this.idx + 1) {
this.stack = this.stack.slice(0, this.idx + 1);
}
@@ -99,7 +99,7 @@ class NavigationHistory {
private go(delta: number) {
const next = this.idx + delta;
const nextLocation = this.stack[next];
// 越界按照无效处理
// Crossing the border is treated as invalid
if (next >= this.stack.length || next < 0 || !nextLocation) {
return;
}
@@ -126,12 +126,12 @@ class NavigationHistory {
}
private listener = (state: HistoryState) => {
/** 无法正确识别 state 时不做任何处理 */
/** Do nothing when the state cannot be correctly recognized */
if (!state || !isNumber(state.fIdx) || !state.uri) {
return;
}
const { fIdx: idx } = state;
/** 索引越界 */
/** Index out of bounds */
if (idx >= this.stack.length || idx < 0) {
return;
}