feat: Synchronous Update

This commit is contained in:
Amery2010 2024-10-19 21:08:08 +08:00
commit e7ccf65fe5
95 changed files with 8870 additions and 5322 deletions

View file

@ -0,0 +1,13 @@
import { Braces } from '@vicons/tabler';
import { defineTool } from '../tool';
import { translate as t } from '@/plugins/i18n.plugin';
export const tool = defineTool({
name: t('tools.xml-to-json.title'),
path: '/xml-to-json',
description: t('tools.xml-to-json.description'),
keywords: ['xml', 'json'],
component: () => import('./xml-to-json.vue'),
icon: Braces,
createdAt: new Date('2024-08-09'),
});

View file

@ -0,0 +1,10 @@
tools:
xml-to-json:
title: XML to JSON
description: Convert XML to JSON.
inputLabel: Your XML content
inputPlaceholder: Paste your XML content here...
outputLabel: Converted JSON
invalidMessage: Provided XML is not valid.

View file

@ -0,0 +1,10 @@
tools:
xml-to-json:
title: XML vers JSON
description: Convertir XML en JSON.
inputLabel: Votre contenu XML
inputPlaceholder: Collez votre contenu XML ici...
outputLabel: JSON converti
invalidMessage: Le XML fourni n'est pas valide.

View file

@ -0,0 +1,10 @@
tools:
xml-to-json:
title: XML 转 JSON
description: 将 XML 转换为 JSON。
inputLabel: 您的 XML 内容
inputPlaceholder: 在此粘贴您的 XML 内容...
outputLabel: 转换后的 JSON
invalidMessage: 提供的 XML 不是有效的。

View file

@ -0,0 +1,33 @@
<script setup lang="ts">
import convert from 'xml-js';
import { isValidXML } from '../xml-formatter/xml-formatter.service';
import { withDefaultOnError } from '@/utils/defaults';
import type { UseValidationRule } from '@/composable/validation';
const { t } = useI18n();
const defaultValue = '<a x="1.234" y="It\'s"/>';
function transformer(value: string) {
return withDefaultOnError(() => {
return JSON.stringify(convert.xml2js(value, { compact: true }), null, 2);
}, '');
}
const rules: UseValidationRule<string>[] = [
{
validator: isValidXML,
message: t('tools.xml-to-json.invalidMessage'),
},
];
</script>
<template>
<format-transformer
input-label="t('tools.xml-to-json.inputLabel')"
:input-default="defaultValue"
input-placeholder="t('tools.xml-to-json.inputPlaceholder')"
output-label="t('tools.xml-to-json.outputLabel')"
output-language="json"
:transformer="transformer"
:input-validation-rules="rules"
/>
</template>