mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-08-09 07:25:18 +02:00
parent
e876d03608
commit
ebfae5e81c
10 changed files with 775 additions and 95 deletions
9
components.d.ts
vendored
9
components.d.ts
vendored
|
@ -109,6 +109,7 @@ declare module '@vue/runtime-core' {
|
|||
JsonDiff: typeof import('./src/tools/json-diff/json-diff.vue')['default']
|
||||
JsonMinify: typeof import('./src/tools/json-minify/json-minify.vue')['default']
|
||||
JsonToCsv: typeof import('./src/tools/json-to-csv/json-to-csv.vue')['default']
|
||||
JsonToPhpArray: typeof import('./src/tools/json-to-php-array/json-to-php-array.vue')['default']
|
||||
JsonToToml: typeof import('./src/tools/json-to-toml/json-to-toml.vue')['default']
|
||||
JsonToYaml: typeof import('./src/tools/json-to-yaml-converter/json-to-yaml.vue')['default']
|
||||
JsonViewer: typeof import('./src/tools/json-viewer/json-viewer.vue')['default']
|
||||
|
@ -130,21 +131,14 @@ declare module '@vue/runtime-core' {
|
|||
NCode: typeof import('naive-ui')['NCode']
|
||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||
NDivider: typeof import('naive-ui')['NDivider']
|
||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
NGi: typeof import('naive-ui')['NGi']
|
||||
NGrid: typeof import('naive-ui')['NGrid']
|
||||
NH1: typeof import('naive-ui')['NH1']
|
||||
NH3: typeof import('naive-ui')['NH3']
|
||||
NIcon: typeof import('naive-ui')['NIcon']
|
||||
NInputNumber: typeof import('naive-ui')['NInputNumber']
|
||||
NLabel: typeof import('naive-ui')['NLabel']
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSpin: typeof import('naive-ui')['NSpin']
|
||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
|
||||
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
|
||||
|
@ -152,6 +146,7 @@ declare module '@vue/runtime-core' {
|
|||
PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default']
|
||||
PercentageCalculator: typeof import('./src/tools/percentage-calculator/percentage-calculator.vue')['default']
|
||||
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
|
||||
PhpArrayToJson: typeof import('./src/tools/php-array-to-json/php-array-to-json.vue')['default']
|
||||
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
|
||||
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
|
||||
ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default']
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
"iarna-toml-esm": "^3.0.5",
|
||||
"ibantools": "^4.3.3",
|
||||
"json5": "^2.2.3",
|
||||
"jsonar-mod": "^1.9.0",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"libphonenumber-js": "^1.10.28",
|
||||
"lodash": "^4.17.21",
|
||||
|
@ -86,6 +87,7 @@
|
|||
"unicode-emoji-json": "^0.4.0",
|
||||
"unplugin-auto-import": "^0.16.4",
|
||||
"uuid": "^9.0.0",
|
||||
"vite-plugin-node-polyfills": "^0.21.0",
|
||||
"vue": "^3.3.4",
|
||||
"vue-i18n": "^9.9.1",
|
||||
"vue-router": "^4.1.6",
|
||||
|
|
750
pnpm-lock.yaml
generated
750
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,8 @@
|
|||
import { tool as base64FileConverter } from './base64-file-converter';
|
||||
import { tool as base64StringConverter } from './base64-string-converter';
|
||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||
import { tool as jsonToPhpArray } from './json-to-php-array';
|
||||
import { tool as phpArrayToJson } from './php-array-to-json';
|
||||
|
||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
|
@ -128,6 +130,8 @@ export const toolsByCategory: ToolCategory[] = [
|
|||
httpStatusCodes,
|
||||
jsonDiff,
|
||||
safelinkDecoder,
|
||||
jsonToPhpArray,
|
||||
phpArrayToJson,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
12
src/tools/json-to-php-array/index.ts
Normal file
12
src/tools/json-to-php-array/index.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { BrandPhp } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Json to PHP-Array',
|
||||
path: '/json-to-php-array',
|
||||
description: 'Convert JSON to PHP Array',
|
||||
keywords: ['json', 'php', 'array'],
|
||||
component: () => import('./json-to-php-array.vue'),
|
||||
icon: BrandPhp,
|
||||
createdAt: new Date('2024-05-11'),
|
||||
});
|
36
src/tools/json-to-php-array/json-to-php-array.vue
Normal file
36
src/tools/json-to-php-array/json-to-php-array.vue
Normal file
|
@ -0,0 +1,36 @@
|
|||
<script setup lang="ts">
|
||||
import jsonar from 'jsonar-mod';
|
||||
import JSON5 from 'json5';
|
||||
import type { UseValidationRule } from '@/composable/validation';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
|
||||
const defaultValue = `{
|
||||
a:"b",
|
||||
arr: [1, "2"],
|
||||
nested: {
|
||||
c:12,
|
||||
d: "az"
|
||||
}
|
||||
}`;
|
||||
function transformer(value: string) {
|
||||
return withDefaultOnError(() => jsonar.arrify(JSON5.parse(value), { prettify: true }), '');
|
||||
}
|
||||
|
||||
const rules: UseValidationRule<string>[] = [
|
||||
{
|
||||
validator: (v: string) => JSON5.parse(v),
|
||||
message: 'Provided JSON is not valid.',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<format-transformer
|
||||
input-label="Your JSON"
|
||||
:input-default="defaultValue"
|
||||
input-placeholder="Paste your JSON here..."
|
||||
output-label="PHP Array version"
|
||||
:input-validation-rules="rules"
|
||||
:transformer="transformer"
|
||||
/>
|
||||
</template>
|
4
src/tools/json-to-php-array/jsonar-mod.d.ts
vendored
Normal file
4
src/tools/json-to-php-array/jsonar-mod.d.ts
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
declare module 'jsonar-mod' {
|
||||
export function arrify(json: any, options?: { prettify?: boolean}): string
|
||||
export function parse(php: string): object
|
||||
}
|
12
src/tools/php-array-to-json/index.ts
Normal file
12
src/tools/php-array-to-json/index.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { BrandPhp } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'PHP-Array to JSON',
|
||||
path: '/php-array-to-json',
|
||||
description: 'Convert PHP Array to JSON',
|
||||
keywords: ['php', 'array', 'json'],
|
||||
component: () => import('./php-array-to-json.vue'),
|
||||
icon: BrandPhp,
|
||||
createdAt: new Date('2024-05-11'),
|
||||
});
|
39
src/tools/php-array-to-json/php-array-to-json.vue
Normal file
39
src/tools/php-array-to-json/php-array-to-json.vue
Normal file
|
@ -0,0 +1,39 @@
|
|||
<script setup lang="ts">
|
||||
import jsonar from 'jsonar-mod';
|
||||
import type { UseValidationRule } from '@/composable/validation';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
|
||||
const defaultValue = `array(
|
||||
"a" => "b",
|
||||
"arr" => array(
|
||||
1,
|
||||
"2"
|
||||
),
|
||||
"nested" => array(
|
||||
"c" => 12,
|
||||
"d" => "az"
|
||||
)
|
||||
);`;
|
||||
function transformer(value: string) {
|
||||
return withDefaultOnError(() => JSON.stringify(jsonar.parse(value), null, 2), '');
|
||||
}
|
||||
|
||||
const rules: UseValidationRule<string>[] = [
|
||||
{
|
||||
validator: (v: string) => v === '' || jsonar.parse(v),
|
||||
message: 'Provided PHP Array is not valid.',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<format-transformer
|
||||
input-label="Your PHP Array"
|
||||
:input-default="defaultValue"
|
||||
input-placeholder="Paste your PHP Array here..."
|
||||
output-label="JSON version"
|
||||
output-language="json"
|
||||
:input-validation-rules="rules"
|
||||
:transformer="transformer"
|
||||
/>
|
||||
</template>
|
|
@ -1,5 +1,6 @@
|
|||
import { resolve } from 'node:path';
|
||||
import { URL, fileURLToPath } from 'node:url';
|
||||
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
||||
|
||||
import VueI18n from '@intlify/unplugin-vue-i18n/vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
|
@ -97,6 +98,7 @@ export default defineConfig({
|
|||
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
|
||||
}),
|
||||
Unocss(),
|
||||
nodePolyfills(),
|
||||
],
|
||||
base: baseUrl,
|
||||
resolve: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue