Skip to content

Commit

Permalink
添加随机密码生成 & 添加行数统计 & 添加html美化
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyueyi committed Sep 30, 2022
1 parent 3e722e2 commit 8df3db3
Show file tree
Hide file tree
Showing 11 changed files with 255 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ yarn generate
| 编程 | | | | |
| | 时间戳转换 | [url](https://tool.hhui.top/tools/code/timestamp) | 在线时间戳转换 格式化工具 | 2022/07/07 |
| | markdown表格格式化 | [url](https://tool.hhui.top/tools/code/mdFormat) | markdown表格数据格式化 | 2022/07/07 |
| | html美化 | [url](https://tool.hhui.top/tools/code/htmlformat) | html美化 | 2022/09/30 |
| | HTTP解析 | [url](https://tool.hhui.top/tools/code/http) | HTTP参数解析、编解码、请求头处理 | 2022/07/07 |
| | UserAgent 解析 | [url](https://tool.hhui.top/tools/code/ua) | UserAgent 解析 | 2022/07/07 |
| | CSS 兼容性处理 | [url](https://tool.hhui.top/tools/code/autoprefixer) | 在线CSS兼容性处理 | 2022/07/07 |
Expand Down Expand Up @@ -214,6 +215,7 @@ yarn generate
| | 番茄时钟 | [url](https://tool.hhui.top/tools/other/pomodoro_technique) | 在线番茄时钟 | 2022/07/07 |
| | 人生小格 | [url](https://tool.hhui.top/tools/other/lifecount) | 人生小格 | 2022/07/07 |
| | 随机数生成 | [url](https://tool.hhui.top/tools/other/random) | 在线随机数生成 | 2022/07/07 |
| | 随机密码生成 | [url](https://tool.hhui.top/tools/other/random_pwd) | 随机密码生成 | 2022/09/30 |
| | LINE 贴纸下载 | [url](https://tool.hhui.top/tools/other/line_sticker_download) | LINE贴纸在线下载 | 2022/07/07 |
| | 帮你百度 | [url](https://tool.hhui.top/tools/other/search_help) | 帮你百度 | 2022/07/07 |
| | 这是什么动漫 | [url](https://tool.hhui.top/tools/other/what_anime_is_this) | 根据截图搜索动漫 | 2022/07/07 |
Expand Down
2 changes: 2 additions & 0 deletions assets/fonts/iconfont/iconfont.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="vfooter">
<div>
<span class="small-font">
更新时间: 2022-07-07 | 工具数量: <nya-link to="/">{{ this.toolNum }}</nya-link>
更新时间: 2022-09-30 | 工具数量: <nya-link to="/">{{ this.toolNum }}</nya-link>
</span>
</div>
<div>
Expand Down
2 changes: 1 addition & 1 deletion components/UI/nya-foot-info.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<nya-container :title="title" :icon="icon">
<ul class="nya-list">
<li>
该工具所有功能直接在浏览器端完成,请放心使用
该工具所有功能直接在浏览器端完成,无服务端交互,不会收集任何数据,请放心使用
</li>
<template>
<slot></slot>
Expand Down
5 changes: 5 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

### 2. 工具历史记录

**2022.09.30**

- html/js/css代码美化 [Html美化](https://tool.hhui.top/tools/code/htmlformat)
- 随机密码生成器 [随机密码生成](https://tool.hhui.top/tools/other/random_pwd)

**2022.07.19**

- 封面图合成插件,支持文字样式设置 [专栏封面](https://tool.hhui.top/tools/merge/blogCover/)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"html2canvas": "^1.0.0-rc.1",
"ismobilejs": "^1.0.3",
"isomorphic-dompurify": "^0.5.0",
"js-beautify": "^1.14.6",
"jsoneditor": "^9.9.0",
"jsqr": "^1.2.0",
"jump.js": "^1.0.2",
Expand Down
85 changes: 85 additions & 0 deletions pages/tools/code/htmlformat.vue
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>
3 changes: 3 additions & 0 deletions pages/tools/other/random.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<nya-container v-if="results.length" title="结果">
<Dynamic :template="results.join(br ? '<br>' : '\n')" />
</nya-container>

<nya-foot-info title="Tips">
</nya-foot-info>
</div>
</template>

Expand Down
123 changes: 123 additions & 0 deletions pages/tools/other/random_pwd.vue
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>
10 changes: 9 additions & 1 deletion pages/tools/text/wordcount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ export default {
},
computed: {
results() {
return "有效字符数:" + this.content.length;
let lines = this.content.split("\n");
let totalLineNum = lines.length;
let legalLineNum = 0;
for (let i = 0; i < totalLineNum; i++) {
if (lines[i]) {
legalLineNum += 1;
}
}
return "有效字符数:" + this.content.length + "\n总行数:" + totalLineNum + "\n非空行数:" + legalLineNum;
}
},
methods: {}
Expand Down
Loading

0 comments on commit 8df3db3

Please sign in to comment.