提交 b6fd1872 编写于 作者: B baiy 提交者: ninecents

添加uuid生成工具 #37

上级 bcb8af78
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
"serialize-php": "^1.1.2", "serialize-php": "^1.1.2",
"sm-crypto": "^0.1.4", "sm-crypto": "^0.1.4",
"system": "^2.0.1", "system": "^2.0.1",
"uuid": "^8.3.2",
"view-design": "^4.3.2", "view-design": "^4.3.2",
"vue": "^2.6.12", "vue": "^2.6.12",
"vue-codemirror": "^4.0.6", "vue-codemirror": "^4.0.6",
...@@ -11533,6 +11534,15 @@ ...@@ -11533,6 +11534,15 @@
"request": "^2.34" "request": "^2.34"
} }
}, },
"node_modules/request/node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true,
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/require-directory": { "node_modules/require-directory": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
...@@ -12349,6 +12359,15 @@ ...@@ -12349,6 +12359,15 @@
"node": ">=0.8.0" "node": ">=0.8.0"
} }
}, },
"node_modules/sockjs/node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true,
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/sort-keys": { "node_modules/sort-keys": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz",
...@@ -13907,12 +13926,11 @@ ...@@ -13907,12 +13926,11 @@
} }
}, },
"node_modules/uuid": { "node_modules/uuid": {
"version": "3.4.0", "version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"dev": true,
"bin": { "bin": {
"uuid": "bin/uuid" "uuid": "dist/bin/uuid"
} }
}, },
"node_modules/v-click-outside-x": { "node_modules/v-click-outside-x": {
...@@ -14764,6 +14782,15 @@ ...@@ -14764,6 +14782,15 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/webpack-log/node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true,
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/webpack-merge": { "node_modules/webpack-merge": {
"version": "4.2.2", "version": "4.2.2",
"resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz", "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz",
...@@ -24613,6 +24640,14 @@ ...@@ -24613,6 +24640,14 @@
"tough-cookie": "~2.5.0", "tough-cookie": "~2.5.0",
"tunnel-agent": "^0.6.0", "tunnel-agent": "^0.6.0",
"uuid": "^3.3.2" "uuid": "^3.3.2"
},
"dependencies": {
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true
}
} }
}, },
"request-promise-core": { "request-promise-core": {
...@@ -25299,6 +25334,14 @@ ...@@ -25299,6 +25334,14 @@
"faye-websocket": "^0.10.0", "faye-websocket": "^0.10.0",
"uuid": "^3.4.0", "uuid": "^3.4.0",
"websocket-driver": "0.6.5" "websocket-driver": "0.6.5"
},
"dependencies": {
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true
}
} }
}, },
"sockjs-client": { "sockjs-client": {
...@@ -26631,10 +26674,9 @@ ...@@ -26631,10 +26674,9 @@
"dev": true "dev": true
}, },
"uuid": { "uuid": {
"version": "3.4.0", "version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
"dev": true
}, },
"v-click-outside-x": { "v-click-outside-x": {
"version": "3.7.1", "version": "3.7.1",
...@@ -27309,6 +27351,14 @@ ...@@ -27309,6 +27351,14 @@
"requires": { "requires": {
"ansi-colors": "^3.0.0", "ansi-colors": "^3.0.0",
"uuid": "^3.3.2" "uuid": "^3.3.2"
},
"dependencies": {
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true
}
} }
}, },
"webpack-merge": { "webpack-merge": {
...@@ -85,6 +85,10 @@ const routes = [ ...@@ -85,6 +85,10 @@ const routes = [
{ {
path: '/tool/json', path: '/tool/json',
component: r => require(['./views/tool/json.vue'], r) component: r => require(['./views/tool/json.vue'], r)
},
{
path: '/tool/uuid',
component: r => require(['./views/tool/uuid.vue'], r)
} }
] ]
......
...@@ -6,9 +6,9 @@ export const TOOL_DATA_EXPIRY = 3600 * 24 ...@@ -6,9 +6,9 @@ export const TOOL_DATA_EXPIRY = 3600 * 24
// 徽章过期时间(天) // 徽章过期时间(天)
export const BADGE_EXPIRY = 10 export const BADGE_EXPIRY = 10
// 分类徽章 // 分类徽章
export const BADGE_CATEGORY = [] export const BADGE_CATEGORY = ['serialize','other']
// 工具徽章 // 工具徽章
export const BADGE_TOOL = [] export const BADGE_TOOL = ['uuid','serializeConversion']
// 默认常用工具 // 默认常用工具
export const DEFAULT_COMMON_TOOL = [ export const DEFAULT_COMMON_TOOL = [
'hash', 'encrypt', 'json', 'base64', 'url', 'timestamp', 'hash', 'encrypt', 'json', 'base64', 'url', 'timestamp',
...@@ -45,6 +45,7 @@ const tool = [ ...@@ -45,6 +45,7 @@ const tool = [
{'name': 'websocket', 'title': 'websocket调试', 'cat': ['other']}, {'name': 'websocket', 'title': 'websocket调试', 'cat': ['other']},
{'name': 'unit', 'title': '单位换算', 'cat': ['other']}, {'name': 'unit', 'title': '单位换算', 'cat': ['other']},
{'name': 'time', 'title': '时间计算器', 'cat': ['other']}, {'name': 'time', 'title': '时间计算器', 'cat': ['other']},
{'name': 'uuid', 'title': 'UUID生成', 'cat': ['other']},
] ]
// 徽章是否显示 // 徽章是否显示
......
<template> <template>
<div> <div>
<option-block class="page-option-block"> <option-block>
<FormItem style="width: 170px"> <FormItem>
<Input v-model="current.amount" type="number"> <Input v-model="current.amount">
<div slot="prepend">{{ $t('uuid_amount') }}</div> <div slot="prepend" style="width: 70px">生成数量</div>
<Button slot="append" icon="md-refresh" @click="handle()"></Button>
</Input> </Input>
</FormItem> </FormItem>
<FormItem style="width: 140px"> <FormItem>
<Input v-model="current.delimiter"> <Input v-model="current.delimiter">
<div slot="prepend">{{ $t('uuid_delimiter') }}</div> <div slot="prepend" style="width: 70px">分隔符</div>
</Input> </Input>
</FormItem> </FormItem>
<FormItem> <FormItem>
<Checkbox v-model="current.hyphens">{{ $t('uuid_hyphens') }}</Checkbox> <Checkbox v-model="current.filterLine">过滤中划线(-)</Checkbox>
</FormItem>
<FormItem>
<Checkbox v-model="current.isUpper">大写字母</Checkbox>
</FormItem> </FormItem>
<FormItem> <FormItem>
<Checkbox v-model="current.isUpper">{{ $t('uuid_is_upper') }}</Checkbox> <Checkbox v-model="current.isAddQuote">添加引号</Checkbox>
</FormItem> </FormItem>
<FormItem> <FormItem>
<Checkbox v-model="current.isAddQuote">{{ $t('uuid_is_add_quote') }}</Checkbox> <Checkbox v-model="current.uint8Array">Uint8 Array</Checkbox>
</FormItem> </FormItem>
<FormItem> <FormItem>
<Checkbox v-model="current.uint8Array">{{ $t('uuid_uint8_array') }}</Checkbox> <Button type="primary" @click="handle()">生成</Button>
</FormItem> </FormItem>
</option-block> </option-block>
<heightResize :append="['.page-option-block']"> <Input v-model="current.output" :rows="12" type="textarea" placeholder="结果"></Input>
<autoHeightTextarea v-model="output" :placeholder="$t('uuid_output')" />
</heightResize>
</div> </div>
</template> </template>
<script> <script>
import {parse as uuidParse, v4 as uuidV4} from 'uuid'; import {v4 as uuidV4,parse as uuidParse} from 'uuid';
import heightResize from "./components/heightResize";
import autoHeightTextarea from "./components/autoHeightTextarea";
export default { export default {
components:{
heightResize,
autoHeightTextarea
},
created() { created() {
this.$initToolData() this.current = Object.assign(this.current, this.$getToolData())
},
mounted() {
if (this.current.result.length < 1){
this.handle()
}
},
computed:{
output(){
if (this.current.result.length < 1){
return "";
}
return this.current.result.map((item)=>{
if (this.current.uint8Array) {
item = "[" + uuidParse(item).toString() + "]"
}
if (!this.current.hyphens) {
item = item.replace(/-/g, "")
}
item = this.current.isUpper ? item.toUpperCase() : item.toLowerCase()
if (this.current.isAddQuote){
item = `"${item}"`
}
return item
}).join(this.current.delimiter.replace(/\\n/g, "\n"));
}
}, },
methods: { methods: {
handle() { handle() {
let result = []; let result = [];
for (let i = 0, l = this.current.amount; i < l; i++) { for (let i = 0, l = this.current.amount; i < l; i++) {
result.push(uuidV4()); result.push(this.current.isAddQuote ? '"' + this.generate() + '"' : this.generate());
} }
this.current.result = result this.current.output = result.join(this.current.delimiter.replace(/\\n/g, "\n"));
this.$saveToolData(this.current); this.$saveToolData(this.current);
},
generate() {
let uuid = uuidV4()
if(this.current.uint8Array){
return "["+uuidParse(uuid).toString()+"]"
}
if (this.current.filterLine) {
uuid = uuid.replace(/-/g, "")
}
uuid = this.current.isUpper ? uuid.toUpperCase() : uuid.toLowerCase()
return uuid;
} }
}, },
data() { data() {
...@@ -82,13 +63,13 @@ export default { ...@@ -82,13 +63,13 @@ export default {
current: { current: {
amount: 10, amount: 10,
delimiter: ",\\n", delimiter: ",\\n",
hyphens: true, filterLine: false,
isAddQuote: false, isAddQuote: false,
isUpper: false, isUpper: false,
uint8Array: false, uint8Array: false,
result: [] output: ""
} }
} }
}, },
} }
</script> </script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册