From 0be73600e5309f4db93286abd6f5c00b4c024106 Mon Sep 17 00:00:00 2001 From: KOMATA <20227709+HynoR@users.noreply.github.com> Date: Mon, 22 Dec 2025 18:22:29 +0800 Subject: [PATCH] feat: Implement Punycode utility functions and integrate into domain dispay (#11433) * feat: Implement Punycode utility functions and integrate into domain display * chore: Add punycode package and update import path in utility functions --- frontend/package.json | 1 + frontend/src/utils/util.ts | 28 +++++++++++++++++++ .../website/config/basic/domain/index.vue | 8 +++++- .../views/website/website/domain/index.vue | 6 +++- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index c15765d03..bc6134412 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -47,6 +47,7 @@ "nprogress": "^0.2.0", "pinia": "^2.1.7", "pinia-plugin-persistedstate": "^1.6.1", + "punycode": "^2.3.1", "qs": "^6.12.1", "screenfull": "^6.0.2", "uuid": "^10.0.0", diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts index fa6132344..f1629e2ce 100644 --- a/frontend/src/utils/util.ts +++ b/frontend/src/utils/util.ts @@ -7,6 +7,7 @@ import { v4 as uuidv4 } from 'uuid'; import JSEncrypt from 'jsencrypt'; import CryptoJS from 'crypto-js'; import { routerToPathWithQuery } from './router'; +import { toUnicode } from 'punycode'; export function deepCopy(obj: any): T { let newObj: any; @@ -919,3 +920,30 @@ export function sortMenu(arr) { arr.sort(compareById); } + +export function isPunycoded(domain: string): boolean { + return domain.includes('xn--'); +} + +export function GetPunyCodeDomain(domain: string): string { + if (!domain || typeof domain !== 'string') { + return ''; + } + + const lowerDomain = domain.toLowerCase(); + if (!lowerDomain.includes('xn--')) { + return ''; + } + + try { + const decoded = toUnicode(domain); + + if (decoded === domain) { + return ''; + } + + return decoded; + } catch (error) { + return ''; + } +} diff --git a/frontend/src/views/website/website/config/basic/domain/index.vue b/frontend/src/views/website/website/config/basic/domain/index.vue index 1de227bec..95a64714f 100644 --- a/frontend/src/views/website/website/config/basic/domain/index.vue +++ b/frontend/src/views/website/website/config/basic/domain/index.vue @@ -8,7 +8,12 @@ - + + +