mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-24 23:00:19 +03:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6530d37b1a | ||
|
|
cb5b462e11 |
No files matched your search
Vendored
+1
-29
@@ -89,28 +89,17 @@ declare module '@vue/runtime-core' {
|
||||
HttpStatusCodes: typeof import('./src/tools/http-status-codes/http-status-codes.vue')['default']
|
||||
IbanValidatorAndParser: typeof import('./src/tools/iban-validator-and-parser/iban-validator-and-parser.vue')['default']
|
||||
'IconMdi:brushVariant': typeof import('~icons/mdi/brush-variant')['default']
|
||||
'IconMdi:contentCopy': typeof import('~icons/mdi/content-copy')['default']
|
||||
'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default']
|
||||
IconMdiArrowDown: typeof import('~icons/mdi/arrow-down')['default']
|
||||
IconMdiArrowRightBottom: typeof import('~icons/mdi/arrow-right-bottom')['default']
|
||||
IconMdiCamera: typeof import('~icons/mdi/camera')['default']
|
||||
IconMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default']
|
||||
IconMdiChevronRight: typeof import('~icons/mdi/chevron-right')['default']
|
||||
IconMdiClose: typeof import('~icons/mdi/close')['default']
|
||||
IconMdiContentCopy: typeof import('~icons/mdi/content-copy')['default']
|
||||
IconMdiDeleteOutline: typeof import('~icons/mdi/delete-outline')['default']
|
||||
IconMdiDownload: typeof import('~icons/mdi/download')['default']
|
||||
IconMdiEye: typeof import('~icons/mdi/eye')['default']
|
||||
IconMdiEyeOff: typeof import('~icons/mdi/eye-off')['default']
|
||||
IconMdiHeart: typeof import('~icons/mdi/heart')['default']
|
||||
IconMdiPause: typeof import('~icons/mdi/pause')['default']
|
||||
IconMdiPlay: typeof import('~icons/mdi/play')['default']
|
||||
IconMdiRecord: typeof import('~icons/mdi/record')['default']
|
||||
IconMdiRefresh: typeof import('~icons/mdi/refresh')['default']
|
||||
IconMdiSearch: typeof import('~icons/mdi/search')['default']
|
||||
IconMdiTranslate: typeof import('~icons/mdi/translate')['default']
|
||||
IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default']
|
||||
IconMdiVideo: typeof import('~icons/mdi/video')['default']
|
||||
InputCopyable: typeof import('./src/components/InputCopyable.vue')['default']
|
||||
IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default']
|
||||
Ipv4AddressConverter: typeof import('./src/tools/ipv4-address-converter/ipv4-address-converter.vue')['default']
|
||||
@@ -137,41 +126,25 @@ declare module '@vue/runtime-core' {
|
||||
MenuLayout: typeof import('./src/components/MenuLayout.vue')['default']
|
||||
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
||||
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
||||
NAlert: typeof import('naive-ui')['NAlert']
|
||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||
NCheckbox: typeof import('naive-ui')['NCheckbox']
|
||||
NCode: typeof import('naive-ui')['NCode']
|
||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||
NColorPicker: typeof import('naive-ui')['NColorPicker']
|
||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||
NDatePicker: typeof import('naive-ui')['NDatePicker']
|
||||
NDivider: typeof import('naive-ui')['NDivider']
|
||||
NDynamicInput: typeof import('naive-ui')['NDynamicInput']
|
||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||
NForm: typeof import('naive-ui')['NForm']
|
||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
NGi: typeof import('naive-ui')['NGi']
|
||||
NginxFormatter: typeof import('./src/tools/nginx-formatter/nginx-formatter.vue')['default']
|
||||
NGrid: typeof import('naive-ui')['NGrid']
|
||||
NH1: typeof import('naive-ui')['NH1']
|
||||
NH2: typeof import('naive-ui')['NH2']
|
||||
NH3: typeof import('naive-ui')['NH3']
|
||||
NIcon: typeof import('naive-ui')['NIcon']
|
||||
NImage: typeof import('naive-ui')['NImage']
|
||||
NInputGroup: typeof import('naive-ui')['NInputGroup']
|
||||
NInputGroupLabel: typeof import('naive-ui')['NInputGroupLabel']
|
||||
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']
|
||||
NProgress: typeof import('naive-ui')['NProgress']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSlider: typeof import('naive-ui')['NSlider']
|
||||
NSpin: typeof import('naive-ui')['NSpin']
|
||||
NStatistic: typeof import('naive-ui')['NStatistic']
|
||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||
NTable: typeof import('naive-ui')['NTable']
|
||||
NTag: typeof import('naive-ui')['NTag']
|
||||
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']
|
||||
@@ -186,7 +159,6 @@ declare module '@vue/runtime-core' {
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
|
||||
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
|
||||
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
|
||||
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
|
||||
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']
|
||||
|
||||
@@ -74,7 +74,6 @@
|
||||
"monaco-editor": "^0.43.0",
|
||||
"naive-ui": "^2.35.0",
|
||||
"netmask": "^2.0.2",
|
||||
"nginx-config-formatter": "^1.4.5",
|
||||
"node-forge": "^1.3.1",
|
||||
"oui-data": "^1.0.10",
|
||||
"pdf-signature-reader": "^1.4.2",
|
||||
@@ -87,7 +86,6 @@
|
||||
"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",
|
||||
|
||||
Generated
+101
-652
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -6,7 +6,7 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
import { tool as textToUnicode } from './text-to-unicode';
|
||||
import { tool as safelinkDecoder } from './safelink-decoder';
|
||||
import { tool as nginxFormatter } from './nginx-formatter';
|
||||
import { tool as rmbNumbers } from './rmb-numbers';
|
||||
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
|
||||
import { tool as numeronymGenerator } from './numeronym-generator';
|
||||
import { tool as macAddressGenerator } from './mac-address-generator';
|
||||
@@ -108,6 +108,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
listConverter,
|
||||
tomlToJson,
|
||||
tomlToYaml,
|
||||
rmbNumbers,
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -149,7 +150,6 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
dockerRunToDockerComposeConverter,
|
||||
xmlFormatter,
|
||||
yamlViewer,
|
||||
nginxFormatter,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Braces } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Nginx formatter',
|
||||
path: '/nginx-formatter',
|
||||
description: 'Format/prettify Nginx configuration files',
|
||||
keywords: ['nginx', 'formatter', 'prettier'],
|
||||
component: () => import('./nginx-formatter.vue'),
|
||||
icon: Braces,
|
||||
createdAt: new Date('2024-03-30'),
|
||||
});
|
||||
@@ -1,27 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { formatContent } from 'nginx-config-formatter';
|
||||
import type { UseValidationRule } from '@/composable/validation';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
|
||||
const defaultValue = '{\n\t"hello": [\n\t\t"world"\n\t]\n}';
|
||||
const transformer = (value: string) => withDefaultOnError(() => formatContent(value), '');
|
||||
|
||||
const rules: UseValidationRule<string>[] = [
|
||||
{
|
||||
validator: (v: string) => v === '' || formatContent(v),
|
||||
message: 'Provided Nginx config is not valid.',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<format-transformer
|
||||
input-label="Your Nginx config"
|
||||
:input-default="defaultValue"
|
||||
input-placeholder="Paste your Nginx config here..."
|
||||
output-label="Prettified Nginx config"
|
||||
output-language="json"
|
||||
:input-validation-rules="rules"
|
||||
:transformer="transformer"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { CurrencyYen } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'RMB Uppercase Converter',
|
||||
path: '/rmb-numbers',
|
||||
description: 'RMB/Renminbi Capitalization Conversion Tool',
|
||||
keywords: ['rmb', 'renminbi', 'cny', 'number', 'uppercase', '人民币', '大写', '转换'],
|
||||
component: () => import('./rmb-numbers.vue'),
|
||||
icon: CurrencyYen,
|
||||
createdAt: new Date('2024-04-29'),
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { rmb } from './rmb-numbers.service';
|
||||
|
||||
describe('rmb-case-converter', () => {
|
||||
it('rmb to convert rmb numbers to uppercase', async () => {
|
||||
expect(rmb(123)).to.deep.equal([
|
||||
{
|
||||
type: 'number',
|
||||
value: '壹',
|
||||
},
|
||||
{
|
||||
type: 'unit',
|
||||
value: '佰',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
value: '贰',
|
||||
},
|
||||
{
|
||||
type: 'unit',
|
||||
value: '拾',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
value: '叁',
|
||||
},
|
||||
{
|
||||
type: 'unit',
|
||||
value: '元',
|
||||
},
|
||||
{
|
||||
type: 'cut',
|
||||
value: '整',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,67 @@
|
||||
export { rmb };
|
||||
|
||||
const numbers = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
|
||||
const leftUnits = ['元', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿', '拾', '佰', '仟', '万', '拾', '佰', '仟', '万'];
|
||||
const rightUnits = ['角', '分'];
|
||||
|
||||
function rmb(value: number) {
|
||||
if (Object.prototype.toString.call(value) === '[object Number]' && value >= 0.01) {
|
||||
const fragment: any = [];
|
||||
const [leftValues, rightValues] = String(value).split('.').map(part => part.split('').map(i => Number(i)));
|
||||
|
||||
const leftValueLength = leftValues.length; // 整数部分位数
|
||||
const unit1 = leftValueLength - 1; // 元位
|
||||
const unit5 = leftValueLength - 5; // 万位
|
||||
const unit9 = leftValueLength - 9; // 亿位
|
||||
const unit13 = leftValueLength - 13; // 万亿位
|
||||
const unit17 = leftValueLength - 17; // 万万亿位
|
||||
const hasLeftValue = leftValueLength > 1 || leftValues[0] > 0; // 整数部分不为0
|
||||
const hasRightValue = rightValues && (rightValues[0] > 0 || rightValues[1] > 0); // 小数部分不为0
|
||||
const has678Value = leftValues[unit5 - 1] > 0 || leftValues[unit5 - 2] > 0 || leftValues[unit5 - 3] > 0; // 拾万、佰万或仟万位不为0
|
||||
const overflowIndex = leftValueLength - leftUnits.length; // 溢出位索引
|
||||
|
||||
let leftUnitIndex = 0;
|
||||
for (let i = leftValueLength - 1; i >= 0; i--) {
|
||||
if (leftValues[i] === 0 && (i === unit5 || i === unit9 || i === unit13 || i === unit17) && leftValues[i + 1] > 0) {
|
||||
// 当前位为0,且当前位为万、亿、万亿、万万亿,且低一位不为0
|
||||
fragment.unshift({ type: 'number', value: numbers[leftValues[i]] });
|
||||
}
|
||||
|
||||
if ((leftValues[i] > 0) || (i === unit1 && hasLeftValue) || (i === unit5 && has678Value) || i === unit9 || i === unit13 || i === unit17) {
|
||||
// 元、万、亿、万亿、万万亿或当前位不为0
|
||||
fragment.unshift({ type: 'unit', value: leftUnits[leftUnitIndex] });
|
||||
}
|
||||
|
||||
if (leftValues[i] > 0 || (leftValues[i + 1] > 0 && i !== unit5 && i !== unit9 && i !== unit13 && i !== unit17) || i <= overflowIndex) {
|
||||
// 当前位不为0,或低一位不为0且当前位非万、亿、万亿、万万亿,或当前为溢出位
|
||||
fragment.unshift({ type: 'number', value: numbers[leftValues[i]] });
|
||||
}
|
||||
|
||||
leftUnitIndex++;
|
||||
}
|
||||
|
||||
if (hasRightValue) {
|
||||
// 角
|
||||
if (rightValues[0] > 0 || hasLeftValue) { // 角位不为0,或整数位不为0
|
||||
fragment.push({ type: 'number', value: numbers[rightValues[0]] });
|
||||
}
|
||||
if (rightValues[0] > 0) { // 角位不为0
|
||||
fragment.push({ type: 'unit', value: rightUnits[0] });
|
||||
}
|
||||
// 分
|
||||
if (rightValues[1] > 0) {
|
||||
fragment.push({ type: 'number', value: numbers[rightValues[1]] });
|
||||
fragment.push({ type: 'unit', value: rightUnits[1] });
|
||||
}
|
||||
}
|
||||
else { // 没有小数位
|
||||
fragment.push({ type: 'cut', value: '整' });
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
return [
|
||||
{ type: 'number', value: '零' },
|
||||
{ type: 'unit', value: '元' },
|
||||
{ type: 'cut', value: '整' },
|
||||
];
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import { useThemeVars } from 'naive-ui';
|
||||
import { rmb } from './rmb-numbers.service';
|
||||
|
||||
const themeVars = useThemeVars();
|
||||
const inputRmb = ref(23);
|
||||
const outputRmb = computed(() => rmb(inputRmb.value)); ;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div flex flex-col gap-2>
|
||||
<c-card title="Lower Case Amount">
|
||||
<n-input-number v-model:value="inputRmb" max="100000000000" min="0" placeholder="Enter the amount in lowercase (example: 1314.52)" :show-button="false" w-full />
|
||||
</c-card>
|
||||
|
||||
<div my-16px divider />
|
||||
|
||||
<c-card title="Amount in Capital Letters" flex flex-col>
|
||||
<div m-0 m-x-auto>
|
||||
<span
|
||||
v-for="(item, index) in outputRmb"
|
||||
:key="index"
|
||||
:class="item.type"
|
||||
>
|
||||
{{ item.value }}
|
||||
</span>
|
||||
</div>
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.unit {
|
||||
font-size: 1.4em;
|
||||
color: v-bind('themeVars.successColor');
|
||||
}
|
||||
.number {
|
||||
font-size: 2.4em;
|
||||
}
|
||||
.cut {
|
||||
font-size: 1.4em;
|
||||
color: v-bind('themeVars.errorColor');
|
||||
}
|
||||
</style>
|
||||
@@ -23,7 +23,7 @@ const decodeInput = ref('Hello%20world%20%3A)');
|
||||
const decodeOutput = computed(() => withDefaultOnError(() => decodeURIComponent(decodeInput.value), ''));
|
||||
|
||||
const decodeValidation = useValidation({
|
||||
source: encodeInput,
|
||||
source: decodeInput,
|
||||
rules: [
|
||||
{
|
||||
validator: value => isNotThrowing(() => decodeURIComponent(value)),
|
||||
|
||||
@@ -15,7 +15,6 @@ import { VitePWA } from 'vite-plugin-pwa';
|
||||
import markdown from 'vite-plugin-vue-markdown';
|
||||
import svgLoader from 'vite-svg-loader';
|
||||
import { configDefaults } from 'vitest/config';
|
||||
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
||||
|
||||
const baseUrl = process.env.BASE_URL ?? '/';
|
||||
|
||||
@@ -98,7 +97,6 @@ export default defineConfig({
|
||||
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
|
||||
}),
|
||||
Unocss(),
|
||||
nodePolyfills(),
|
||||
],
|
||||
base: baseUrl,
|
||||
resolve: {
|
||||
@@ -114,8 +112,5 @@ export default defineConfig({
|
||||
},
|
||||
build: {
|
||||
target: 'esnext',
|
||||
rollupOptions: {
|
||||
external: ['node:fs/promises', 'fs'],
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user