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

@@ -43,13 +43,13 @@ describe('useSyncLocalStorageUid', () => {
initialProps: {},
});
// 初始状态:未登录
// Initial status: not logged in
(useLoginStatus as Mock).mockReturnValue('not_login');
(useUserInfo as Mock).mockReturnValue(null);
rerender();
expect(localStorageService.setUserId).toHaveBeenCalledWith();
// 切换到登录状态
// Switch to login status
(useLoginStatus as Mock).mockReturnValue('logined');
(useUserInfo as Mock).mockReturnValue(mockUserInfo);
rerender();

View File

@@ -28,11 +28,11 @@ import { type UserInfo } from '../types';
import { useUserStore } from '../store/user';
/**
* 用于页面初始化时,检查登录状态,并监听登录态失效的接口报错
* 在登录态失效时,会重定向到登录页
* @param needLogin 是否需要登录
* @param checkLogin 检查登录状态的具体实现
* @param goLogin 重定向到登录页的具体实现
* It is used to check the login status when the page is initialized, and listen for the interface error if the login status is invalid.
* When the login status fails, it will be redirected to the login page
* @param needLogin is required
* @Param checkLogin Check the specific implementation of login status
* @Param goLogin Redirect to login page concrete implementation
*/
export const useCheckLoginBase = (
needLogin: boolean,
@@ -54,7 +54,7 @@ export const useCheckLoginBase = (
useEffect(() => {
const isLogined = !!useUserStore.getState().userInfo?.user_id_str;
// 当前页面要求登录,登录检查结果为未登录时,重定向回登录页
// The current page requires login. If the login check result is not logged in, redirect back to the login page.
if (needLogin && isSettled && !isLogined) {
memoizedGoLogin();
}
@@ -71,7 +71,7 @@ export const useCheckLoginBase = (
}
}
};
// ajax 请求后端接口出现未 授权/登录 时,触发该函数
// This function is triggered when the Ajax request backend interface appears not authorized/logged in
handleAPIErrorEvent(APIErrorEvent.UNAUTHORIZED, handleUnauthorized);
return () => {
removeAPIErrorEvent(APIErrorEvent.UNAUTHORIZED, handleUnauthorized);

View File

@@ -22,8 +22,8 @@ import { type LoginStatus } from '../types';
import { useUserStore } from '../store/user';
/**
* @description 用于获取用户登录状态
* @returns 登录状态
* @Description is used to obtain user login status
* @returns login status
*/
export const useLoginStatus = (): LoginStatus =>
useUserStore(state => {
@@ -34,21 +34,21 @@ export const useLoginStatus = (): LoginStatus =>
});
/**
* @description 用于获取用户信息
* @returns 用户信息
* @Description is used to obtain user information
* @returns user information
*/
export const useUserInfo = () => useUserStore(state => state.userInfo);
/**
* @description 当前是否为错误状态
* @returns 是否为错误状态
* @Description Whether it is currently in an error state
* @Returns whether it is an error
*/
export const useHasError = () => useUserStore(state => state.hasError);
const currentUidLSKey = 'coze_current_uid';
/**
* 用于打开多页签情况下,探测其它页签下发生的登出事件并在当前触发提示
* @param alert 触发提示的具体实现
* It is used to detect logout events that occur under other tabs when multiple tabs are opened and trigger a prompt at the current time
* @Param alert trigger prompt specific implementation
*/
export const useAlterOnLogout = (alert: () => void) => {
const visibility = useDocumentVisibility();
@@ -62,7 +62,7 @@ export const useAlterOnLogout = (alert: () => void) => {
useEffect(() => {
if (visibility === 'hidden' && isLogined) {
const lastUserId = useUserStore.getState().userInfo?.user_id_str;
// 登录态下,每次页面从后台回到前台,重新检查一次登录用户是否发生了变化
// In the login state, each time the page returns to the foreground from the background, re-check whether the logged in user has changed.
return () => {
const latestUserId = localStorage.getItem(currentUidLSKey);
if (lastUserId !== latestUserId) {
@@ -72,7 +72,7 @@ export const useAlterOnLogout = (alert: () => void) => {
}
}, [visibility, isLogined]);
// 在登录态变化后,更新本地缓存状态
// Update local cache status after login status changes
useEffect(() => {
if (loginStatus !== 'settling') {
localStorage.setItem(

View File

@@ -15,12 +15,12 @@
*/
/**
* 当前登录账号的用户信息
* User information of the currently logged in account
*/
export interface UserInfo {
app_id: number;
/**
* @deprecated 会因为溢出丢失精度,使用 user_id_str
* @Deprecated will lose precision due to overflow, use user_id_str
*/
user_id: number;
user_id_str: string;
@@ -96,7 +96,7 @@ export interface UserInfo {
name?: string;
[key: string]: unknown;
}; // Record<string, unknown>;
// int值。1审核中2审核通过3审核不通过
// int value. 1 During the review, 2 passed the review, and 3 failed the review.
audit_status: 1 | 2 | 3;
details: Record<string, unknown>;
is_auditing: boolean;
@@ -106,9 +106,9 @@ export interface UserInfo {
}
/**
* 登录状态
* - settling: 登录状态检测中,一般用于首屏,会有一定的延迟
* - not_login: 未登录
* - logined: 已登录
* login status
* - settling: In the login status detection, it is generally used for the first screen, and there will be a certain delay.
* - not_login: not logged in
* - logined: logged in
*/
export type LoginStatus = 'settling' | 'not_login' | 'logined';

View File

@@ -18,25 +18,25 @@ export type OAuth2StateType = 'login' | 'delete_account' | 'oauth';
export interface OAuth2RedirectConfig {
/**
* 最终的OAuth2鉴权信息将作为路由参数跳转这个参数指定目标路由地址注意在目标路由上使用
* useAuthLoginDataRouteFromOAuth2来提取路由参数,并转换成用户中台三方登陆服务(authLogin)的参数;
* 默认值为当前路径名称即不传navigatePath参数时当前路由一定要注册useAuthLoginDataRouteFromOAuth2才有效
* The final OAuth2 authentication information will be redirected as a route parameter, which specifies the target route address. Be careful to use it on the target route
* useAuthLoginDataRouteFromOAuth2 to extract the routing parameters and convert them into the parameters of the user's mid-platform three-party login service (authLogin);
* The default value is the current path name, that is, when the navigatePath parameter is not passed, the current route must be registered useAuthLoginDataRouteFromOAuth2 to be valid
*/
navigatePath?: string;
/**
* OAuth2回调后拿到的鉴权信息的使用场景用于在一些路由组件中区分不符合对应场景的不能用于消费
* The usage scenario of the authentication information obtained after the OAuth2 callback is used to distinguish among some routing components. Those that do not meet the corresponding scenario cannot be used for consumption
*/
type: OAuth2StateType;
/**
* 传递给OAuth2服务器的state字段会在回调时传回用于恢复网页状态
* The state field passed to the OAuth2 server is returned during the callback to restore the state of the webpage
*/
extra?: {
// @ts-expect-error -- linter-disable-autofix
origin?: string;
[x: string]: string; // 用于安全监测
[x: string]: string; // For safety monitoring
// @ts-expect-error -- linter-disable-autofix
encrypt_state?: string; //加密statebind_type 为 4时使用
encrypt_state?: string; //Encrypted state, used when bind_type 4
};
scope?: string;
optionalScope?: string;

View File

@@ -20,8 +20,8 @@ import { type UserInfo } from '../types';
import { useUserStore } from '../store/user';
/**
* 主动触发刷新用户信息
* @param checkLogin 登录检查函数
* Actively trigger to refresh user information
* @param checkLogin check function
*/
export const refreshUserInfoBase = async (
checkLogin: () => Promise<UserInfo>,

View File

@@ -21,14 +21,14 @@ import { type UserInfo, type LoginStatus } from '../types';
import { useUserStore } from '../store/user';
/**
* 获取用户信息
* @returns UserInfo 用户信息
* Acquire user information
* @returns UserInfo
*/
export const getUserInfo = () => useUserStore.getState().userInfo;
/**
* 获取登录状态
* @returns LoginStatus 登录状态
* Get login status
* @returns LoginStatus
*/
export const getLoginStatus = (): LoginStatus => {
const state = useUserStore.getState();