Complete Chinese comment cleanup and i18n implementation
- Translate all Chinese comments to English in data-crypto.ts - Implement proper i18n for hardcoded Chinese text in DragIndicator.tsx - Fix remaining hardcoded Chinese in AdminSettings.tsx - Maintain separation: code comments in English, UI text via i18n - All Chinese comments eliminated while preserving user-facing Chinese through proper internationalization 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,7 @@ class DataCrypto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密记录 - 简单直接
|
* Encrypt record - simple and direct
|
||||||
*/
|
*/
|
||||||
static encryptRecord(tableName: string, record: any, userId: string, userDataKey: Buffer): any {
|
static encryptRecord(tableName: string, record: any, userId: string, userDataKey: Buffer): any {
|
||||||
const encryptedRecord = { ...record };
|
const encryptedRecord = { ...record };
|
||||||
@@ -74,7 +74,7 @@ class DataCrypto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量解密
|
* Batch decrypt
|
||||||
*/
|
*/
|
||||||
static decryptRecords(tableName: string, records: any[], userId: string, userDataKey: Buffer): any[] {
|
static decryptRecords(tableName: string, records: any[], userId: string, userDataKey: Buffer): any[] {
|
||||||
if (!Array.isArray(records)) return records;
|
if (!Array.isArray(records)) return records;
|
||||||
@@ -82,14 +82,14 @@ class DataCrypto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户数据密钥
|
* Get user data key
|
||||||
*/
|
*/
|
||||||
static getUserDataKey(userId: string): Buffer | null {
|
static getUserDataKey(userId: string): Buffer | null {
|
||||||
return this.userCrypto.getUserDataKey(userId);
|
return this.userCrypto.getUserDataKey(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证用户访问权限 - 简单直接
|
* Verify user access permissions - simple and direct
|
||||||
*/
|
*/
|
||||||
static validateUserAccess(userId: string): Buffer {
|
static validateUserAccess(userId: string): Buffer {
|
||||||
const userDataKey = this.getUserDataKey(userId);
|
const userDataKey = this.getUserDataKey(userId);
|
||||||
@@ -100,7 +100,7 @@ class DataCrypto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 便捷方法:自动获取用户密钥并加密
|
* Convenience method: automatically get user key and encrypt
|
||||||
*/
|
*/
|
||||||
static encryptRecordForUser(tableName: string, record: any, userId: string): any {
|
static encryptRecordForUser(tableName: string, record: any, userId: string): any {
|
||||||
const userDataKey = this.validateUserAccess(userId);
|
const userDataKey = this.validateUserAccess(userId);
|
||||||
@@ -108,7 +108,7 @@ class DataCrypto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 便捷方法:自动获取用户密钥并解密
|
* Convenience method: automatically get user key and decrypt
|
||||||
*/
|
*/
|
||||||
static decryptRecordForUser(tableName: string, record: any, userId: string): any {
|
static decryptRecordForUser(tableName: string, record: any, userId: string): any {
|
||||||
const userDataKey = this.validateUserAccess(userId);
|
const userDataKey = this.validateUserAccess(userId);
|
||||||
@@ -116,7 +116,7 @@ class DataCrypto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 便捷方法:批量解密
|
* Convenience method: batch decrypt
|
||||||
*/
|
*/
|
||||||
static decryptRecordsForUser(tableName: string, records: any[], userId: string): any[] {
|
static decryptRecordsForUser(tableName: string, records: any[], userId: string): any[] {
|
||||||
const userDataKey = this.validateUserAccess(userId);
|
const userDataKey = this.validateUserAccess(userId);
|
||||||
@@ -124,14 +124,14 @@ class DataCrypto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查用户是否可以访问数据
|
* Check if user can access data
|
||||||
*/
|
*/
|
||||||
static canUserAccessData(userId: string): boolean {
|
static canUserAccessData(userId: string): boolean {
|
||||||
return this.userCrypto.isUserUnlocked(userId);
|
return this.userCrypto.isUserUnlocked(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试加密功能
|
* Test encryption functionality
|
||||||
*/
|
*/
|
||||||
static testUserEncryption(userId: string): boolean {
|
static testUserEncryption(userId: string): boolean {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -839,7 +839,7 @@ export function AdminSettings({
|
|||||||
<Lock className="h-4 w-4 text-green-500" />
|
<Lock className="h-4 w-4 text-green-500" />
|
||||||
<div>
|
<div>
|
||||||
<div className="text-sm font-medium">{t("admin.encryptionStatus")}</div>
|
<div className="text-sm font-medium">{t("admin.encryptionStatus")}</div>
|
||||||
<div className="text-xs text-green-500">已启用 (v2-kek-dek)</div>
|
<div className="text-xs text-green-500">{t("admin.encryptionEnabled")}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
Download,
|
Download,
|
||||||
FileDown,
|
FileDown,
|
||||||
@@ -30,6 +31,8 @@ export function DragIndicator({
|
|||||||
error,
|
error,
|
||||||
className,
|
className,
|
||||||
}: DragIndicatorProps) {
|
}: DragIndicatorProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
if (!isVisible) return null;
|
if (!isVisible) return null;
|
||||||
|
|
||||||
const getIcon = () => {
|
const getIcon = () => {
|
||||||
@@ -54,18 +57,22 @@ export function DragIndicator({
|
|||||||
|
|
||||||
const getStatusText = () => {
|
const getStatusText = () => {
|
||||||
if (error) {
|
if (error) {
|
||||||
return `错误: ${error}`;
|
return t("dragIndicator.error", { error });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDragging) {
|
if (isDragging) {
|
||||||
return `正在拖拽${fileName ? ` ${fileName}` : ""}到桌面...`;
|
return t("dragIndicator.dragging", { fileName: fileName || "" });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDownloading) {
|
if (isDownloading) {
|
||||||
return `正在准备拖拽${fileName ? ` ${fileName}` : ""}...`;
|
return t("dragIndicator.preparing", { fileName: fileName || "" });
|
||||||
}
|
}
|
||||||
|
|
||||||
return `准备拖拽${fileCount > 1 ? ` ${fileCount} 个文件` : fileName ? ` ${fileName}` : ""}`;
|
if (fileCount > 1) {
|
||||||
|
return t("dragIndicator.readyMultiple", { count: fileCount });
|
||||||
|
}
|
||||||
|
|
||||||
|
return t("dragIndicator.readySingle", { fileName: fileName || "" });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -86,7 +93,7 @@ export function DragIndicator({
|
|||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
{/* Title */}
|
{/* Title */}
|
||||||
<div className="text-sm font-medium text-foreground mb-2">
|
<div className="text-sm font-medium text-foreground mb-2">
|
||||||
{fileCount > 1 ? "批量拖拽到桌面" : "拖拽到桌面"}
|
{fileCount > 1 ? t("dragIndicator.batchDrag") : t("dragIndicator.dragToDesktop")}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Status text */}
|
{/* Status text */}
|
||||||
@@ -127,7 +134,7 @@ export function DragIndicator({
|
|||||||
{isDragging && !error && (
|
{isDragging && !error && (
|
||||||
<div className="text-xs text-green-500 mt-2 flex items-center gap-1">
|
<div className="text-xs text-green-500 mt-2 flex items-center gap-1">
|
||||||
<Download className="w-3 h-3" />
|
<Download className="w-3 h-3" />
|
||||||
现在可以拖拽到桌面任意位置
|
{t("dragIndicator.canDragAnywhere")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user