-
Notifications
You must be signed in to change notification settings - Fork 16
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
11 changed files
with
255 additions
and
4 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,85 @@ | ||
<template> | ||
<div class="html-format"> | ||
<nya-container title="Html格式化"> | ||
<div class="radio-group"> | ||
<nya-radio-group v-model="index"> | ||
<nya-radio v-for="(label, i) in labels" class="mr-15" :value="i" :key="i" :label="label.label"/> | ||
</nya-radio-group> | ||
</div> | ||
|
||
<nya-input v-model="content" | ||
class="top-margin-1em" | ||
fullwidth | ||
rows="5" | ||
type="textarea" | ||
autofocus | ||
:label="labels[index].desc" | ||
/> | ||
</nya-container> | ||
|
||
<nya-container v-if="results" title="格式化输出"> | ||
<nya-copy :copy="results"> | ||
<pre>{{ results }}</pre> | ||
</nya-copy> | ||
</nya-container> | ||
|
||
<nya-foot-info title="Tips"> | ||
<li> 底层使用 <a href="https://github.com/beautify-web/js-beautify">js-beautify</a> 实现格式化</li> | ||
</nya-foot-info> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Dynamic from '@/components/Dynamic'; | ||
import beautify_js from 'js-beautify'; | ||
export default { | ||
name: 'htmlFormat', | ||
components: { | ||
Dynamic | ||
}, | ||
data() { | ||
return { | ||
content: '', | ||
results: '', | ||
index: 0, | ||
labels: [ | ||
{label: 'html', desc: "请在输入框内粘贴 HTML 内容"}, | ||
{label: 'js', desc: "请在输入框内粘贴 JavaScript 内容"}, | ||
{label: 'css', desc: "请在输入框内粘贴 CSS 内容"}, | ||
] | ||
}; | ||
}, | ||
watch: { | ||
content() { | ||
this.format_html(); | ||
}, | ||
index() { | ||
this.format_html(); | ||
} | ||
}, | ||
methods: { | ||
format_html() { | ||
if (!this.content) { | ||
return | ||
} | ||
// html 格式化 | ||
let js = beautify_js.html; | ||
if (this.index === 0) js = beautify_js.html; | ||
else if (this.index === 1) js = beautify_js.js; | ||
else js = beautify_js.css; | ||
this.results = js(this.content, {indent_size: 2, space_in_empty_paren: true}) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
.html-format { | ||
pre { | ||
font-family: sans-serif; | ||
} | ||
} | ||
</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
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,123 @@ | ||
<template> | ||
<div class="random"> | ||
<nya-container title="随机密码生成器"> | ||
<div class="nya-input mb-15 fullwidth"> | ||
<label class="input-title"> | ||
<span style="padding-right: 1em"> 使用字符: </span> | ||
<nya-checkbox v-model="lowAlpha" label="a-z"/> | ||
<nya-checkbox v-model="upAlpha" label="A-Z"/> | ||
<nya-checkbox v-model="numAlpha" label="0-9"/> | ||
<nya-checkbox v-model="specialAlpha" label="!@#$%^&*"/> | ||
<span style="padding: 0 1em; color:gray"> | </span> | ||
<div class="nya-btn" @click="gen"> | ||
生成密码 | ||
</div> | ||
</label> | ||
</div> | ||
|
||
<nya-input v-model.trim="alphaTxt" class="mb-15" fullwidth label="密码簿" placeholder="abcABC0-9" | ||
autocomplete="off"/> | ||
<nya-input v-model.trim="len" class="mb-15" type="number" label="密码长度" placeholder="16" | ||
autocomplete="off"/> | ||
<nya-input v-model.trim="num" class="mb-15" type="number" label="生成数量" placeholder="10" | ||
autocomplete="off"/> | ||
|
||
|
||
</nya-container> | ||
|
||
<nya-container v-if="results.length" title="随机密码如下"> | ||
<nya-copy :copy="results"> | ||
<pre>{{ results }}</pre> | ||
</nya-copy> | ||
</nya-container> | ||
|
||
<nya-foot-info title="Tips"> | ||
</nya-foot-info> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
const L_A = 'abcdefjhijklmnopqrstufwxyz'; | ||
const U_A = 'ABCDEFJHIJKLMNOPQRSTUFWXYZ'; | ||
const N_A = '0123456789'; | ||
const O_A = '!@#$%^&*.?|\'"'; | ||
import Dynamic from '@/components/Dynamic'; | ||
export default { | ||
name: 'Random', | ||
components: { | ||
Dynamic | ||
}, | ||
head() { | ||
return this.$store.state.currentTool.head; | ||
}, | ||
data() { | ||
return { | ||
lowAlpha: true, | ||
upAlpha: true, | ||
numAlpha: true, | ||
specialAlpha: false, | ||
alphaTxt: L_A + U_A + N_A, | ||
num: 4, // 密码个数 | ||
len: 16, // 密码长度 | ||
results: "", | ||
br: true, | ||
index: 0, | ||
labels: [ | ||
{label: "a-z"}, | ||
{label: "A-Z"}, | ||
{label: "0-9"}, | ||
{label: "!@#$%^&*"}, | ||
] | ||
}; | ||
}, | ||
watch: { | ||
lowAlpha() { | ||
this.alphaTxt = this.upAlphaTxt(); | ||
}, | ||
upAlpha() { | ||
this.alphaTxt = this.upAlphaTxt(); | ||
}, | ||
numAlpha() { | ||
this.alphaTxt = this.upAlphaTxt(); | ||
}, | ||
specialAlpha() { | ||
this.alphaTxt = this.upAlphaTxt(); | ||
} | ||
}, | ||
methods: { | ||
upAlphaTxt() { | ||
let txt = ''; | ||
if (this.lowAlpha) { | ||
txt += L_A; | ||
} | ||
if (this.upAlpha) { | ||
txt += U_A; | ||
} | ||
if (this.numAlpha) { | ||
txt += N_A; | ||
} | ||
if (this.specialAlpha) { | ||
txt += O_A; | ||
} | ||
return txt; | ||
}, | ||
gen() { | ||
let pwds = []; | ||
for (let i = 0; i < this.num; i++) { | ||
pwds.push(this.genOnePwd()); | ||
} | ||
this.results = pwds.join("\n"); | ||
}, | ||
genOnePwd() { | ||
let max = this.alphaTxt.length; | ||
let pwd = ''; | ||
for (let i = 0; i < this.len; i++) { | ||
const index = Math.floor(Math.random() * max); | ||
pwd += this.alphaTxt.charAt(index); | ||
} | ||
return pwd; | ||
} | ||
} | ||
}; | ||
</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
Oops, something went wrong.