mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-18 18:02:08 +08:00
fix(ui): use utf-8 encoding for inline SVG icons to support non-latin characters (#7892)
* fix(ui): use utf-8 encoding for inline SVG icons to support non-latin characters * chore(test-item): re-add data-sortable-handle to TestItem box * docs: update changelog
This commit is contained in:
@@ -72,16 +72,18 @@ export const TestItem = ({ itemData, onEdit, onDelete: removeTest }: Props) => {
|
||||
<Box sx={{ display: 'flex', justifyContent: 'center' }}>
|
||||
{icon.trim().startsWith('http') && (
|
||||
<img
|
||||
alt={name}
|
||||
src={iconCachePath === '' ? icon : iconCachePath}
|
||||
height="40px"
|
||||
/>
|
||||
)}
|
||||
{icon.trim().startsWith('data') && (
|
||||
<img src={icon} height="40px" />
|
||||
<img alt={name} src={icon} height="40px" />
|
||||
)}
|
||||
{icon.trim().startsWith('<svg') && (
|
||||
<img
|
||||
src={`data:image/svg+xml;base64,${btoa(icon)}`}
|
||||
alt={name}
|
||||
src={`data:image/svg+xml;charset=utf-8,${encodeURIComponent(icon)}`}
|
||||
height="40px"
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -75,34 +75,17 @@ export const TestViewer = forwardRef<TestViewerRef, Props>(
|
||||
throw new Error(t('tests.modals.test.errors.urlRequired'))
|
||||
}
|
||||
|
||||
let newList
|
||||
let uid
|
||||
|
||||
if (form.icon && form.icon.startsWith('<svg')) {
|
||||
// 移除 icon 中的注释
|
||||
if (form.icon) {
|
||||
form.icon = form.icon.replace(/<!--[\s\S]*?-->/g, '')
|
||||
}
|
||||
const doc = new DOMParser().parseFromString(
|
||||
form.icon,
|
||||
'image/svg+xml',
|
||||
)
|
||||
if (doc.querySelector('parsererror')) {
|
||||
throw new Error(t('tests.modals.test.errors.invalidSvg'))
|
||||
}
|
||||
}
|
||||
|
||||
if (openType === 'new') {
|
||||
uid = nanoid()
|
||||
const uid = nanoid()
|
||||
const item = { ...form, uid }
|
||||
newList = [...testList, item]
|
||||
const newList = [...testList, item]
|
||||
await patchVerge({ test_list: newList })
|
||||
onChange(uid)
|
||||
} else {
|
||||
if (!form.uid) {
|
||||
throw new Error(t('tests.modals.test.errors.uidMissing'))
|
||||
}
|
||||
uid = form.uid
|
||||
const uid = form.uid
|
||||
|
||||
await patchTestList(uid, form)
|
||||
onChange(uid, form)
|
||||
|
||||
Reference in New Issue
Block a user