-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<template> | ||
<h2>输入</h2> | ||
<n-input placeholder="输入" v-model:value="input" /> | ||
|
||
<h2>转换</h2> | ||
<n-flex vertical> | ||
<div v-for="(value, key) in values" :key="key"> | ||
<n-input-group> | ||
<n-input :placeholder="key" :value="value" /> | ||
<n-button type="primary" @click="copyToClipboard(value)">复制</n-button> | ||
</n-input-group> | ||
</div> | ||
</n-flex> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref, watch } from 'vue' | ||
import { NFlex, NInput, NInputGroup, NButton } from 'naive-ui' | ||
import jsConvert from 'js-convert-case' | ||
import { copyToClipboard } from '../utils' | ||
const input = ref('') | ||
const values = ref({ | ||
camelCase: '', | ||
snake_case: '', | ||
PascalCase: '', | ||
'dot.case': '', | ||
'path/case': '', | ||
'text case': '', | ||
'Sentence case': '', | ||
'Header Case': '', | ||
UPPERCASE: '', | ||
lowercase: '', | ||
'kebab-case': '', | ||
}) | ||
watch( | ||
() => input.value, | ||
(val) => { | ||
values.value['camelCase'] = jsConvert.toCamelCase(val) | ||
values.value['snake_case'] = jsConvert.toSnakeCase(val) | ||
values.value['PascalCase'] = jsConvert.toPascalCase(val) | ||
values.value['dot.case'] = jsConvert.toDotCase(val) | ||
values.value['path/case'] = jsConvert.toPathCase(val) | ||
values.value['text case'] = jsConvert.toTextCase(val) | ||
values.value['Sentence case'] = jsConvert.toSentenceCase(val) | ||
values.value['Header Case'] = jsConvert.toHeaderCase(val) | ||
values.value['UPPERCASE'] = jsConvert.toUpperCase(val) | ||
values.value['lowercase'] = jsConvert.toLowerCase(val) | ||
values.value['kebab-case'] = jsConvert.toKebabCase(val) | ||
} | ||
) | ||
</script> | ||
|
||
<style lang="scss" scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 命名风格转换 | ||
|
||
<CaseConverter /> | ||
|
||
<script setup lang="ts"> | ||
import CaseConverter from './CaseConverter.vue' | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 工具 | ||
|
||
各种小工具! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export function copyToClipboard(text: string) { | ||
if (navigator.clipboard) { | ||
navigator.clipboard.writeText(text) | ||
} else { | ||
const input = document.createElement('input') | ||
input.value = text | ||
document.body.appendChild(input) | ||
input.select() | ||
document.execCommand('copy') | ||
document.body.removeChild(input) | ||
} | ||
} |