Skip to content

Commit 285939b

Browse files
committed
perf: lion error i18n
1 parent 085c46e commit 285939b

16 files changed

Lines changed: 273 additions & 27 deletions

File tree

‎ui/koko/workspaces/BaseWorkspaceShell.vue‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ defineEmits<{ retry: [] }>();
2424
<UButton v-if="error && retryLabel" size="sm" variant="soft" @click="void $emit('retry')">
2525
{{ retryLabel }}
2626
</UButton>
27+
<slot v-if="error" name="error-actions" />
2728
</div>
2829
</div>
2930
</div>

‎ui/lion/hooks/useGuacamoleClient.ts‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { MaybeRefOrGetter } from "vue";
22
import type { LionUploadCustomRequestOptions } from "@/lion/types/upload";
33
import type { LionOnlineUser } from "@/lion/workspaces/useLionWorkspaceSessionRegistry";
4+
import type { GuacamoleConnectionErrorDetails } from "@/lion/utils/status";
45
import { useDebounceFn } from "@vueuse/core";
56

67
import * as Guacamole from "guacamole-common-js-jumpserver/dist/guacamole-common";
@@ -10,7 +11,7 @@ import { withLionUrl } from "@/lion/utils/base";
1011
import { readClipboardText, writeClipboardBlob, writeClipboardText } from "@/lion/utils/clipboard";
1112

1213
import { lunaCommunicator } from "@/lion/utils/lunaBus";
13-
import { ConvertGuacamoleError as convertGuacamoleError, ErrorStatusCodes } from "@/lion/utils/status";
14+
import { ConvertGuacamoleError as convertGuacamoleError } from "@/lion/utils/status";
1415

1516
const testImages: Record<string, string> = {
1617
/**
@@ -169,7 +170,7 @@ export function useGuacamoleClient(
169170
info: (text: string) => toast.add({ title: text, color: "info" }),
170171
success: (text: string) => toast.add({ title: text, color: "success" }),
171172
warning: (text: string) => toast.add({ title: text, color: "warning" }),
172-
error: (text: string, _opts?: { duration?: number }) => addErrorToast({ title: text })
173+
error: (text: string, opts?: { duration?: number }) => addErrorToast({ title: text, duration: opts?.duration })
173174
};
174175
const guaClient = ref<any>(null);
175176
const guaTunnel = ref<any>(null);
@@ -181,6 +182,7 @@ export function useGuacamoleClient(
181182
// localized label via connectStatusLabel.
182183
const connectStatus = ref(1);
183184
const connectionError = shallowRef("");
185+
const connectionErrorDetails = shallowRef<GuacamoleConnectionErrorDetails>();
184186
const CONNECT_STATUS_KEYS: Record<number, string> = {
185187
0: "LionIdle",
186188
1: "LionConnecting",
@@ -275,6 +277,8 @@ export function useGuacamoleClient(
275277
) {
276278
disconnectGuaclient();
277279
connectionError.value = "";
280+
connectionErrorDetails.value = undefined;
281+
sessionObject.value = {};
278282
const generation = connectGeneration;
279283
loading.value = true;
280284
currentWidth.value = width || window.innerWidth;
@@ -765,13 +769,16 @@ export function useGuacamoleClient(
765769
function onClientError(status: any) {
766770
console.error("Guacamole client error:", status);
767771
loading.value = false;
768-
const code = status.code;
769-
let msg = t(ErrorStatusCodes[code] || convertGuacamoleError(status.message) || "UnknownError", {
770-
PLACEHOLDER: status.message
772+
const code = typeof status?.code === "number" && Number.isInteger(status.code) ? status.code : undefined;
773+
const rawMessage = typeof status?.message === "string" ? status.message : "";
774+
const msg = t(convertGuacamoleError(rawMessage, code), {
775+
PLACEHOLDER: rawMessage
771776
});
772-
if (code === 1006) {
773-
msg = `${msg}: ${status.message}`;
774-
}
777+
connectionErrorDetails.value = {
778+
code,
779+
message: rawMessage,
780+
sessionId: typeof sessionObject.value?.id === "string" ? sessionObject.value.id : undefined
781+
};
775782
connectionError.value = msg;
776783
message.error(msg, { duration: 10000 });
777784
}
@@ -1189,6 +1196,7 @@ export function useGuacamoleClient(
11891196
connectToGuacamole,
11901197
connectStatus,
11911198
connectionError,
1199+
connectionErrorDetails,
11921200
connectStatusLabel,
11931201
sessionObject,
11941202
action_permission,

‎ui/lion/locales/modules/en.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
{
2+
"GuaErrServerError": "The remote connection service encountered an error. Try again; if it persists, contact your administrator.",
3+
"GuaErrServerBusy": "The connection service is busy. Please try again later.",
4+
"GuaErrResourceNotFound": "The requested resource no longer exists or has expired. Please reconnect.",
5+
"GuaErrResourceConflict": "The requested resource is in use. Please try again later.",
6+
"GuaErrResourceClosed": "The requested resource has closed. Please reconnect.",
7+
"GuaErrUpStreamNotFound": "The target server could not be found. Check the asset address and network.",
8+
"GuaErrUpStreamUnavailable": "The target service is unavailable. Check that the remote desktop service is running.",
9+
"GuaErrClientTimeout": "The client response timed out. Check your local network and reconnect.",
10+
"GuaErrClientOverrun": "The data sent exceeds the limit. Reduce the amount of data and try again.",
11+
"GuaErrClientBadType": "The client sent an unsupported data format. Ask your administrator to check client and server compatibility.",
12+
"GuaErrClientTooMany": "The client resource limit has been reached. Close unused connections and try again.",
13+
"GuaErrConnectionClosed": "The connection ended unexpectedly. Reconnect; if it persists, contact your administrator.",
14+
"GuaErrorDetails": "Error details",
15+
"GuaErrorCode": "Error code",
16+
"GuaErrorMessage": "Original message",
17+
"GuaErrorSessionId": "Session ID",
218
"GuaErrUnSupport": "This operation is not supported",
319
"GuaErrUpStreamTimeout": "Connection timed out. Check the asset network and remote desktop service.",
420
"GuaErrSessionConflict": "The session was disconnected because it conflicted with another connection",

‎ui/lion/locales/modules/es.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
{
2+
"GuaErrServerError": "El servicio de conexión remota encontró un error. Inténtelo de nuevo; si persiste, contacte con el administrador.",
3+
"GuaErrServerBusy": "El servicio de conexión está ocupado. Inténtelo de nuevo más tarde.",
4+
"GuaErrResourceNotFound": "El recurso solicitado no existe o ha caducado. Vuelva a conectarse.",
5+
"GuaErrResourceConflict": "El recurso solicitado está en uso. Inténtelo de nuevo más tarde.",
6+
"GuaErrResourceClosed": "El recurso solicitado se ha cerrado. Vuelva a conectarse.",
7+
"GuaErrUpStreamNotFound": "No se encontró el servidor de destino. Compruebe la dirección del activo y la red.",
8+
"GuaErrUpStreamUnavailable": "El servicio de destino no está disponible. Compruebe que el servicio de escritorio remoto esté en ejecución.",
9+
"GuaErrClientTimeout": "La respuesta del cliente agotó el tiempo de espera. Compruebe su red local y vuelva a conectarse.",
10+
"GuaErrClientOverrun": "Los datos enviados superan el límite. Reduzca la cantidad de datos e inténtelo de nuevo.",
11+
"GuaErrClientBadType": "El cliente envió un formato de datos no compatible. Pida al administrador que compruebe la compatibilidad entre el cliente y el servidor.",
12+
"GuaErrClientTooMany": "Se alcanzó el límite de recursos del cliente. Cierre las conexiones que no utilice e inténtelo de nuevo.",
13+
"GuaErrConnectionClosed": "La conexión finalizó inesperadamente. Vuelva a conectarse; si persiste, contacte con el administrador.",
14+
"GuaErrorDetails": "Detalles del error",
15+
"GuaErrorCode": "Código de error",
16+
"GuaErrorMessage": "Mensaje original",
17+
"GuaErrorSessionId": "ID de sesión",
218
"GuaErrUnSupport": "Esta operación no es compatible",
319
"GuaErrUpStreamTimeout": "La conexión agotó el tiempo de espera. Compruebe la red del activo y el servicio de escritorio remoto.",
420
"GuaErrSessionConflict": "La sesión se desconectó por un conflicto con otra conexión",

‎ui/lion/locales/modules/ja.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
{
2+
"GuaErrServerError": "リモート接続サービスでエラーが発生しました。再試行し、解決しない場合は管理者に連絡してください。",
3+
"GuaErrServerBusy": "接続サービスが混み合っています。しばらくしてから再試行してください。",
4+
"GuaErrResourceNotFound": "要求したリソースが存在しないか、有効期限が切れています。再接続してください。",
5+
"GuaErrResourceConflict": "要求したリソースは使用中です。しばらくしてから再試行してください。",
6+
"GuaErrResourceClosed": "要求したリソースは閉じられました。再接続してください。",
7+
"GuaErrUpStreamNotFound": "接続先サーバーが見つかりません。資産のアドレスとネットワークを確認してください。",
8+
"GuaErrUpStreamUnavailable": "接続先のサービスを利用できません。リモートデスクトップサービスが起動しているか確認してください。",
9+
"GuaErrClientTimeout": "クライアントの応答がタイムアウトしました。ローカルネットワークを確認して再接続してください。",
10+
"GuaErrClientOverrun": "送信データが上限を超えています。データ量を減らして再試行してください。",
11+
"GuaErrClientBadType": "クライアントが未対応のデータ形式を送信しました。管理者にクライアントとサーバーの互換性の確認を依頼してください。",
12+
"GuaErrClientTooMany": "クライアントのリソース使用量が上限に達しました。不要な接続を閉じて再試行してください。",
13+
"GuaErrConnectionClosed": "接続が予期せず切断されました。再接続し、解決しない場合は管理者に連絡してください。",
14+
"GuaErrorDetails": "エラーの詳細",
15+
"GuaErrorCode": "エラーコード",
16+
"GuaErrorMessage": "元のメッセージ",
17+
"GuaErrorSessionId": "セッション ID",
218
"GuaErrUnSupport": "この操作はサポートされていません",
319
"GuaErrUpStreamTimeout": "接続がタイムアウトしました。資産のネットワークとリモートデスクトップサービスを確認してください。",
420
"GuaErrSessionConflict": "別の接続と競合したため、セッションが切断されました",

‎ui/lion/locales/modules/ko.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
{
2+
"GuaErrServerError": "원격 연결 서비스에 오류가 발생했습니다. 다시 시도하고, 문제가 계속되면 관리자에게 문의하세요.",
3+
"GuaErrServerBusy": "연결 서비스가 사용 중입니다. 잠시 후 다시 시도하세요.",
4+
"GuaErrResourceNotFound": "요청한 리소스가 없거나 만료되었습니다. 다시 연결하세요.",
5+
"GuaErrResourceConflict": "요청한 리소스가 사용 중입니다. 잠시 후 다시 시도하세요.",
6+
"GuaErrResourceClosed": "요청한 리소스가 닫혔습니다. 다시 연결하세요.",
7+
"GuaErrUpStreamNotFound": "대상 서버를 찾을 수 없습니다. 자산 주소와 네트워크를 확인하세요.",
8+
"GuaErrUpStreamUnavailable": "대상 서비스를 사용할 수 없습니다. 원격 데스크톱 서비스가 실행 중인지 확인하세요.",
9+
"GuaErrClientTimeout": "클라이언트 응답 시간이 초과되었습니다. 로컬 네트워크를 확인한 후 다시 연결하세요.",
10+
"GuaErrClientOverrun": "전송한 데이터가 제한을 초과했습니다. 데이터 양을 줄이고 다시 시도하세요.",
11+
"GuaErrClientBadType": "클라이언트가 지원되지 않는 데이터 형식을 전송했습니다. 관리자에게 클라이언트와 서버의 호환성 확인을 요청하세요.",
12+
"GuaErrClientTooMany": "클라이언트 리소스 사용량이 한도에 도달했습니다. 사용하지 않는 연결을 닫고 다시 시도하세요.",
13+
"GuaErrConnectionClosed": "연결이 예기치 않게 종료되었습니다. 다시 연결하고, 문제가 계속되면 관리자에게 문의하세요.",
14+
"GuaErrorDetails": "오류 세부 정보",
15+
"GuaErrorCode": "오류 코드",
16+
"GuaErrorMessage": "원본 메시지",
17+
"GuaErrorSessionId": "세션 ID",
218
"GuaErrUnSupport": "지원하지 않는 작업입니다",
319
"GuaErrUpStreamTimeout": "연결 시간이 초과되었습니다. 자산 네트워크와 원격 데스크톱 서비스를 확인하세요.",
420
"GuaErrSessionConflict": "다른 연결과 충돌하여 세션이 끊어졌습니다",

‎ui/lion/locales/modules/pt_br.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
{
2+
"GuaErrServerError": "O serviço de conexão remota encontrou um erro. Tente novamente; se persistir, entre em contato com o administrador.",
3+
"GuaErrServerBusy": "O serviço de conexão está ocupado. Tente novamente mais tarde.",
4+
"GuaErrResourceNotFound": "O recurso solicitado não existe ou expirou. Reconecte-se.",
5+
"GuaErrResourceConflict": "O recurso solicitado está em uso. Tente novamente mais tarde.",
6+
"GuaErrResourceClosed": "O recurso solicitado foi fechado. Reconecte-se.",
7+
"GuaErrUpStreamNotFound": "O servidor de destino não foi encontrado. Verifique o endereço do ativo e a rede.",
8+
"GuaErrUpStreamUnavailable": "O serviço de destino está indisponível. Verifique se o serviço de área de trabalho remota está em execução.",
9+
"GuaErrClientTimeout": "O tempo de resposta do cliente esgotou. Verifique sua rede local e reconecte-se.",
10+
"GuaErrClientOverrun": "Os dados enviados excedem o limite. Reduza a quantidade de dados e tente novamente.",
11+
"GuaErrClientBadType": "O cliente enviou um formato de dados incompatível. Peça ao administrador para verificar a compatibilidade entre o cliente e o servidor.",
12+
"GuaErrClientTooMany": "O limite de recursos do cliente foi atingido. Feche as conexões que não estiver usando e tente novamente.",
13+
"GuaErrConnectionClosed": "A conexão foi encerrada inesperadamente. Reconecte-se; se persistir, entre em contato com o administrador.",
14+
"GuaErrorDetails": "Detalhes do erro",
15+
"GuaErrorCode": "Código do erro",
16+
"GuaErrorMessage": "Mensagem original",
17+
"GuaErrorSessionId": "ID da sessão",
218
"GuaErrUnSupport": "Esta operação não é suportada",
319
"GuaErrUpStreamTimeout": "O tempo de conexão esgotou. Verifique a rede do ativo e o serviço de área de trabalho remota.",
420
"GuaErrSessionConflict": "A sessão foi desconectada por conflito com outra conexão",

‎ui/lion/locales/modules/ru.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
{
2+
"GuaErrServerError": "Произошла ошибка службы удалённого подключения. Повторите попытку; если ошибка повторится, обратитесь к администратору.",
3+
"GuaErrServerBusy": "Служба подключения занята. Повторите попытку позже.",
4+
"GuaErrResourceNotFound": "Запрошенный ресурс не существует или срок его действия истёк. Подключитесь заново.",
5+
"GuaErrResourceConflict": "Запрошенный ресурс уже используется. Повторите попытку позже.",
6+
"GuaErrResourceClosed": "Запрошенный ресурс закрыт. Подключитесь заново.",
7+
"GuaErrUpStreamNotFound": "Целевой сервер не найден. Проверьте адрес актива и сеть.",
8+
"GuaErrUpStreamUnavailable": "Целевая служба недоступна. Убедитесь, что служба удалённого рабочего стола запущена.",
9+
"GuaErrClientTimeout": "Истекло время ожидания ответа клиента. Проверьте локальную сеть и подключитесь заново.",
10+
"GuaErrClientOverrun": "Объём отправленных данных превышает лимит. Уменьшите объём данных и повторите попытку.",
11+
"GuaErrClientBadType": "Клиент отправил данные в неподдерживаемом формате. Попросите администратора проверить совместимость клиента и сервера.",
12+
"GuaErrClientTooMany": "Достигнут лимит ресурсов клиента. Закройте неиспользуемые подключения и повторите попытку.",
13+
"GuaErrConnectionClosed": "Соединение неожиданно прервано. Подключитесь заново; если ошибка повторится, обратитесь к администратору.",
14+
"GuaErrorDetails": "Сведения об ошибке",
15+
"GuaErrorCode": "Код ошибки",
16+
"GuaErrorMessage": "Исходное сообщение",
17+
"GuaErrorSessionId": "ID сеанса",
218
"GuaErrUnSupport": "Эта операция не поддерживается",
319
"GuaErrUpStreamTimeout": "Время ожидания подключения истекло. Проверьте сеть актива и службу удалённого рабочего стола.",
420
"GuaErrSessionConflict": "Сеанс отключён из-за конфликта с другим подключением",

‎ui/lion/locales/modules/vi.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
{
2+
"GuaErrServerError": "Dịch vụ kết nối từ xa gặp lỗi. Hãy thử lại; nếu lỗi vẫn xảy ra, hãy liên hệ quản trị viên.",
3+
"GuaErrServerBusy": "Dịch vụ kết nối đang bận. Vui lòng thử lại sau.",
4+
"GuaErrResourceNotFound": "Tài nguyên được yêu cầu không tồn tại hoặc đã hết hạn. Vui lòng kết nối lại.",
5+
"GuaErrResourceConflict": "Tài nguyên được yêu cầu đang được sử dụng. Vui lòng thử lại sau.",
6+
"GuaErrResourceClosed": "Tài nguyên được yêu cầu đã đóng. Vui lòng kết nối lại.",
7+
"GuaErrUpStreamNotFound": "Không tìm thấy máy chủ đích. Kiểm tra địa chỉ tài sản và mạng.",
8+
"GuaErrUpStreamUnavailable": "Dịch vụ đích không khả dụng. Kiểm tra xem dịch vụ máy tính từ xa có đang chạy không.",
9+
"GuaErrClientTimeout": "Đã hết thời gian chờ phản hồi của máy khách. Kiểm tra mạng cục bộ rồi kết nối lại.",
10+
"GuaErrClientOverrun": "Dữ liệu đã gửi vượt quá giới hạn. Giảm lượng dữ liệu rồi thử lại.",
11+
"GuaErrClientBadType": "Máy khách gửi dữ liệu ở định dạng không được hỗ trợ. Nhờ quản trị viên kiểm tra tính tương thích giữa máy khách và máy chủ.",
12+
"GuaErrClientTooMany": "Đã đạt giới hạn tài nguyên của máy khách. Đóng các kết nối không sử dụng rồi thử lại.",
13+
"GuaErrConnectionClosed": "Kết nối kết thúc đột ngột. Hãy kết nối lại; nếu lỗi vẫn xảy ra, hãy liên hệ quản trị viên.",
14+
"GuaErrorDetails": "Chi tiết lỗi",
15+
"GuaErrorCode": "Mã lỗi",
16+
"GuaErrorMessage": "Thông báo gốc",
17+
"GuaErrorSessionId": "ID phiên",
218
"GuaErrUnSupport": "Thao tác này không được hỗ trợ",
319
"GuaErrUpStreamTimeout": "Kết nối đã hết thời gian chờ. Kiểm tra mạng của tài sản và dịch vụ máy tính từ xa.",
420
"GuaErrSessionConflict": "Phiên đã bị ngắt do xung đột với kết nối khác",

‎ui/lion/locales/modules/zh.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
{
2+
"GuaErrServerError": "远程连接服务异常,请重试;若仍失败,请联系管理员。",
3+
"GuaErrServerBusy": "连接服务繁忙,请稍后重试。",
4+
"GuaErrResourceNotFound": "请求的资源不存在或已失效,请重新连接。",
5+
"GuaErrResourceConflict": "请求的资源正在使用中,请稍后重试。",
6+
"GuaErrResourceClosed": "请求的资源已关闭,请重新连接。",
7+
"GuaErrUpStreamNotFound": "无法找到目标服务器,请检查资产地址和网络。",
8+
"GuaErrUpStreamUnavailable": "目标服务暂不可用,请检查远程桌面服务是否启动。",
9+
"GuaErrClientTimeout": "客户端响应超时,请检查本地网络后重新连接。",
10+
"GuaErrClientOverrun": "发送的数据超过限制,请减少数据量后重试。",
11+
"GuaErrClientBadType": "客户端发送的数据格式不受支持,请联系管理员检查客户端与服务端的兼容性。",
12+
"GuaErrClientTooMany": "客户端资源使用已达上限,请关闭不需要的连接后重试。",
13+
"GuaErrConnectionClosed": "连接异常中断,请重新连接;若仍失败,请联系管理员。",
14+
"GuaErrorDetails": "错误详情",
15+
"GuaErrorCode": "错误码",
16+
"GuaErrorMessage": "原始消息",
17+
"GuaErrorSessionId": "会话 ID",
218
"GuaErrUnSupport": "不支持该操作",
319
"GuaErrUpStreamTimeout": "连接超时,请检查资产网络和远程桌面服务。",
420
"GuaErrSessionConflict": "会话与其他连接冲突,已断开",

0 commit comments

Comments
 (0)