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

添加文本处理工具 #58 #55

上级 a707f4c6
# 程序开发常用工具
使用过程中的任何问题或者需要新的工具欢迎提交`Issue`,新工具如果可以提供实现代码就完美了O(∩_∩)O
## chrome 安装
- 方法1: 在 [Chrome 应用商店](https://chrome.google.com/webstore/detail/ipfcebkfhpkjeikaammlkcnalknjahmh) 安装
- 方法2: [下载 .crx 安装包](https://github.com/baiy/Ctool/releases/latest)手动安装 [猛戳这里查看手动安装教程](http://www.cnplugins.com/tool/outline-install-crx-file.html)
- 方法3: [百度网盘下载](https://pan.baidu.com/s/1mhWbqWC) 安装方法和方法2一致
- 方法1: 在 [Chrome 应用商店](https://chrome.google.com/webstore/detail/ipfcebkfhpkjeikaammlkcnalknjahmh) 安装
- 方法2: [下载 .crx 安装包](https://github.com/baiy/Ctool/releases/latest)手动安装 [猛戳这里查看手动安装教程](http://www.cnplugins.com/tool/outline-install-crx-file.html)
- 方法3: [百度网盘下载](https://pan.baidu.com/s/1mhWbqWC) 安装方法和方法2一致
> 方法2 / 方法3 不定期维护 仅供网络环境特别恶劣的同学使用
### 本地打包/调试
```
# 打包
npm run build -adapter=chrome
......@@ -26,6 +30,7 @@ npm run serve -adapter=chrome
> 插件中心搜索`ctool`
### 本地打包/调试
```
# 打包
npm run build -adapter=utools
......@@ -36,6 +41,7 @@ npm run serve -adapter=utools
```
## 功能列表
|功能|说明|离线使用|
|---|---|---|
|哈希|`md5`, `sha1`, `sha256`, `sha512`,`sm3`|√|
......@@ -64,26 +70,28 @@ npm run serve -adapter=utools
|变量名格式转换|`Var Name`, `var-name`, `VAR_NAME`, `VarName`, `varName`, `var_name`, `var name`|√|
|jwt解码|`header`, `payload`|√|
|Hex/String转换|`hex to string`, `string to hex`, `十六进制转字符串`, `字符串转十六进制`|√|
|文本处理|'大小写转换', '中英文标点转换', '简繁转换', '替换', '字符统计', '行去重', '添加行号', '行排序', '过滤行首尾不可见字符','过滤空行'|√|
## 第三方开源库
项目诞生离不开这些优秀的开源程序
- [ajax-request](https://www.npmjs.com/package/ajax-request)
- [ajax-request](https://www.npmjs.com/package/ajax-request)
- [code-formatter](https://www.npmjs.com/package/code-formatter)
- [crypto-js](https://www.npmjs.com/package/crypto-js)
- [ipinyinjs](https://www.npmjs.com/package/ipinyinjs)
- [is-url](https://www.npmjs.com/package/is-url)
- [iview](https://www.npmjs.com/package/iview)
- [js-base64](https://www.npmjs.com/package/js-base64)
- [lscache](https://www.npmjs.com/package/lscache)
- [php-array-reader](https://www.npmjs.com/package/php-array-reader)
- [phparr](https://www.npmjs.com/package/phparr)
- [qrcode](https://www.npmjs.com/package/qrcode)
- [qrcode-parser](https://www.npmjs.com/package/qrcode-parser)
- [ipinyinjs](https://www.npmjs.com/package/ipinyinjs)
- [is-url](https://www.npmjs.com/package/is-url)
- [iview](https://www.npmjs.com/package/iview)
- [js-base64](https://www.npmjs.com/package/js-base64)
- [lscache](https://www.npmjs.com/package/lscache)
- [php-array-reader](https://www.npmjs.com/package/php-array-reader)
- [phparr](https://www.npmjs.com/package/phparr)
- [qrcode](https://www.npmjs.com/package/qrcode)
- [qrcode-parser](https://www.npmjs.com/package/qrcode-parser)
- [radix.js](https://www.npmjs.com/package/radix.js)
- [serialize-php](https://www.npmjs.com/package/serialize-php)
- [diff](https://www.npmjs.com/package/diff)
- [vue](https://www.npmjs.com/package/vue)
- [serialize-php](https://www.npmjs.com/package/serialize-php)
- [diff](https://www.npmjs.com/package/diff)
- [vue](https://www.npmjs.com/package/vue)
- [vue-router](https://www.npmjs.com/package/vue-router)
- [taobao](http://ip.taobao.com/)
- [layui](https://github.com/sentsin/layui/)
......@@ -99,8 +107,10 @@ npm run serve -adapter=utools
- [sm-crypto](https://github.com/JuneAndGreen/sm-crypto)
- [camelcaseplugin](https://github.com/netnexus/camelcaseplugin)
- [jwt-decode](https://www.npmjs.com/package/jwt-decode)
- [jian_fan](https://www.npmjs.com/package/jian_fan)
> 当然项目中还使用很多不知道姓名的大神的代码, 在这里就不一一感谢
## 先睹为快
> 当然项目中还使用很多不知道姓名的大神的代码, 在这里就不一一感谢
## 先睹为快
![](https://cdn.jsdelivr.net/gh/baiy/Ctool/dome.jpg)
![](https://cdn.jsdelivr.net/gh/baiy/Ctool/dome.jpg)
{
"name": "c-tool",
"version": "1.6.2",
"version": "1.6.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -6674,6 +6674,11 @@
"integrity": "sha1-FC0RHzpuPa6PSpr9d9RYVbWpzOM=",
"dev": true
},
"jian_fan": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/jian_fan/-/jian_fan-1.0.3.tgz",
"integrity": "sha512-b7Dr2hckX8zViAcEMBMQ/SPtqmfmqQ9Za6W9KD05rcZpb52E2PzxPUwTn0H2TMDv4gaqfa5tUrGNLci9dcnLxw=="
},
"js-base64": {
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.4.tgz",
......
{
"name": "c-tool",
"version": "1.6.5",
"version": "1.6.6",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 8081",
......@@ -19,6 +19,7 @@
"http-build-query": "^0.7.0",
"ipinyinjs": "^1.0.0",
"is-url": "^1.2.4",
"jian_fan": "^1.0.3",
"js-base64": "^2.6.4",
"js-yaml": "^3.14.1",
"json-to-properties": "^1.1.3",
......
// 工具缓存数据过期时间(秒)
const TOOL_DATA_EXPIRY = 3600 * 24
// 徽章过期时间(天)
const BADGE_EXPIRY = 5
// 分类徽章
const BADGE_CATEGORY = ['other']
// 工具徽章
const BADGE_TOOL = ['text','hexString']
// 默认常用工具
const DEFAULT_COMMON_TOOL = [
'hash', 'encrypt', 'json', 'base64', 'url', 'timestamp',
'qrCode', 'pinyin', 'ip', 'code', 'unicode',
'text', 'randomString', 'diffs',
]
const category = [
{'name': 'common', 'title': '常用工具'},
{'name': 'encryption', 'title': '解密'},
{'name': 'conversion', 'title': '编码转换'},
{'name': 'common', 'title': '常用'},
{'name': 'encryption', 'title': '加解密'},
{'name': 'conversion', 'title': '转换'},
{'name': 'serialize', 'title': '序列化'},
{'name': 'other', 'title': '其他工具'},
{'name': 'check', 'title': '校验'},
{'name': 'generate', 'title': '生成'},
{'name': 'other', 'title': '其他'},
]
const tool = [
......@@ -27,20 +44,21 @@ const tool = [
{'name': 'code', 'title': '代码格式化', 'cat': ['other']},
{'name': 'unicode', 'title': 'Unicode', 'cat': ['conversion']},
{'name': 'decimalConvert', 'title': '进制转换', 'cat': ['conversion']},
{'name': 'regex', 'title': '正则表达式', 'cat': ['other']},
{'name': 'randomString', 'title': '随机字符生成', 'cat': ['other']},
{'name': 'regex', 'title': '正则表达式', 'cat': ['check']},
{'name': 'randomString', 'title': '随机字符生成', 'cat': ['generate']},
{'name': 'serializeConversion', 'title': '序列化转换', 'cat': ['conversion', 'serialize']},
{'name': 'diffs', 'title': '文本差异化对比', 'cat': ['other']},
{'name': 'crontab', 'title': 'crontab校验', 'cat': ['other']},
{'name': 'diffs', 'title': '文本差异化对比', 'cat': ['check']},
{'name': 'crontab', 'title': 'crontab校验', 'cat': ['check']},
{'name': 'websocket', 'title': 'websocket调试', 'cat': ['other']},
{'name': 'unit', 'title': '单位换算', 'cat': ['other']},
{'name': 'time', 'title': '时间计算器', 'cat': ['other']},
{'name': 'uuid', 'title': 'UUID生成', 'cat': ['other']},
{'name': 'uuid', 'title': 'UUID生成', 'cat': ['generate']},
{'name': 'jsonToObject', 'title': 'JSON转实体类', 'cat': ['conversion', 'serialize']},
{'name': 'ascii', 'title': 'ascii转换', 'cat': ['conversion']},
{'name': 'ascii', 'title': 'ASCII转换', 'cat': ['conversion']},
{'name': 'variableConversion', 'title': '变量名转换', 'cat': ['conversion']},
{'name': 'jwt', 'title': 'jwt解码', 'cat': ['conversion']},
{'name': 'jwt', 'title': 'JWT解码', 'cat': ['conversion']},
{'name': 'hexString', 'title': 'Hex/String转换', 'cat': ['conversion']},
{'name': 'text', 'title': '文本处理', 'cat': ['other']},
]
// 工具类功能配置
......@@ -57,6 +75,7 @@ const utools = {
encrypt: ['AES', 'DES', 'RC4', 'Rabbit', 'TripleDes', 'sm2'],
jwt: ['jwtDecode'],
hexString: ['hex to string', 'string to hex', '十六进制转字符串', '字符串转十六机制'],
text: ['文本处理', '大小写转换', '中英文标点转换', '简繁转换', '字符替换', '字符统计', '行去重', '添加行号', '行排序', '过滤行首尾不可见字符', '过滤空行'],
},
cmds: {
timestamp: [
......@@ -104,5 +123,10 @@ module.exports = {
category,
tool,
feature,
utools
utools,
toolDataExpiry: TOOL_DATA_EXPIRY,
badgeExpiry: BADGE_EXPIRY,
badgeCategory: BADGE_CATEGORY,
badgeTool: BADGE_TOOL,
defaultCommonTool: DEFAULT_COMMON_TOOL
}
\ No newline at end of file
......@@ -109,6 +109,10 @@ const routes = [
{
path: '/tool/hexString',
component: r => require(['./views/tool/hexString.vue'], r)
},
{
path: '/tool/text',
component: r => require(['./views/tool/text.vue'], r)
}
]
......
import {env, inArray} from '../helper'
import cache from './cache'
const toolConfig = require('../config')
// 工具缓存数据过期时间(秒)
export const TOOL_DATA_EXPIRY = 3600 * 24
export const TOOL_DATA_EXPIRY = toolConfig.toolDataExpiry
// 徽章过期时间(天)
export const BADGE_EXPIRY = 10
export const BADGE_EXPIRY = toolConfig.badgeExpiry
// 分类徽章
export const BADGE_CATEGORY = []
export const BADGE_CATEGORY = toolConfig.badgeCategory
// 工具徽章
export const BADGE_TOOL = []
export const BADGE_TOOL = toolConfig.badgeTool
// 默认常用工具
export const DEFAULT_COMMON_TOOL = [
'hash', 'encrypt', 'json', 'base64', 'url', 'timestamp',
'qrCode', 'pinyin', 'ip', 'code', 'unicode',
'decimalConvert', 'randomString', 'diffs',
]
const toolConfig = require('../config')
export const DEFAULT_COMMON_TOOL = toolConfig.defaultCommonTool
const category = toolConfig.category
......
......@@ -40,9 +40,6 @@ class TextHandle {
// 行首大写
upperLineStart() {
return this.text.split(/\r?\n/).map((str) => {
if (str.length < 1){
return "";
}
return str[0].toUpperCase() + str.substr(1)
}).join("\n");
}
......@@ -50,9 +47,6 @@ class TextHandle {
// 行首小写
lowerLineStart() {
return this.text.split(/\r?\n/).map((str) => {
if (str.length < 1){
return "";
}
return str[0].toLowerCase() + str.substr(1)
}).join("\n");
}
......@@ -83,7 +77,7 @@ class TextHandle {
replace(search = [], replace = []) {
let text = this.text;
for (let i in search) {
if (search[i]) {
if (search[i]){
text = text.replace(new RegExp(regExpQuote(search[i]), 'g'), (i in replace ? replace[i] : ""));
}
}
......@@ -180,4 +174,4 @@ class TextHandle {
export default (text) => {
return new TextHandle(text)
}
}
\ No newline at end of file
<template>
<div>
<input-block right="15px" bottom="10px">
<heightResize :append="['.page-option-block']">
<autoHeightTextarea v-model="current.content" :placeholder="$t('text_input')"></autoHeightTextarea>
</heightResize>
<template slot="extra">
<Button type="dashed" @click="statShow = true" size="small">
{{ $t('text_stat_show',[stat.word_length,stat.byte_utf8_length,stat.byte_gbk_length]) }}
<Icon type="ios-more" />
</Button>
</template>
</input-block>
<option-block class="page-option-block">
<FormItem v-if="current.original.length > 0">
<Button type="default" :size="buttonSize"
@click="[current.content,current.original]=[current.original,current.content]">
{{ $t('text_resume') }}
</Button>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle(item)" transfer>
<Button :size="buttonSize" type="primary">
{{ $t('text_case_conversion') }}
<Icon type="ios-arrow-down"></Icon>
<Row :gutter="10">
<Col span="14">
<Tabs value="content">
<TabPane label="文本内容" name="content">
<Input v-model="current.content" :rows="12" type="textarea" placeholder="内容"></Input>
<option-block style="padding: 0 0">
<FormItem v-if="current.original.length > 0">
<Button type="default" :size="buttonSize"
@click="[current.content,current.original]=[current.original,current.content]">
恢复
</Button>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle(item)" transfer>
<Button :size="buttonSize" type="primary">
大小写转换
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="upper">全部大写</DropdownItem>
<DropdownItem name="lower">全部小写</DropdownItem>
<DropdownItem name="upperLineStart">行首大写</DropdownItem>
<DropdownItem name="lowerLineStart">行首小写</DropdownItem>
<DropdownItem name="upperStart">词首大写</DropdownItem>
<DropdownItem name="lowerStart">词首小写</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle('replacePunctuation',item)" transfer>
<Button :size="buttonSize" type="primary">
中英标点替换
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="en">中 -> 英</DropdownItem>
<DropdownItem name="zh">英 -> 中</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle('zhTran',item)" transfer>
<Button :size="buttonSize" type="primary">
简繁转换
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="simplified">繁 -> 简</DropdownItem>
<DropdownItem name="traditional">简 -> 繁</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
</option-block>
<option-block style="padding: 0 0">
<FormItem>
<Button :size="buttonSize" type="primary" @click="replace.show = true">字符替换</Button>
</FormItem>
<FormItem>
<Button :size="buttonSize" type="primary" @click="handle('lineRemoveRepeat')">行去重
</Button>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle(item)" transfer>
<Button :size="buttonSize" type="primary">
增/删行号
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="addLineIndex">添加行号</DropdownItem>
<DropdownItem name="removeLineIndex">移除行号</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle('lineSort',item)" transfer>
<Button :size="buttonSize" type="primary">
行排序
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="asc">升序</DropdownItem>
<DropdownItem name="desc">降序</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle(item)" transfer>
<Button :size="buttonSize" type="primary">
过滤
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="lineTrim">过滤行首尾不可见字符(trim)</DropdownItem>
<DropdownItem name="filterBlankLine">过滤多余空行</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
</option-block>
</TabPane>
</Tabs>
</Col>
<Col span="10">
<Tabs value="right">
<TabPane label="统计" name="right">
<Table :columns="statColumns" stripe border size="small" :data="stat">
</Table>
</TabPane>
<Button @click="statExplain.show = true" type="text" slot="extra">
<Icon type="md-help-circle"/>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="upper">{{ $t('text_upper_all') }}</DropdownItem>
<DropdownItem name="lower">{{ $t('text_lower_all') }}</DropdownItem>
<DropdownItem name="upperLineStart">{{ $t('text_upper_line_start') }}</DropdownItem>
<DropdownItem name="lowerLineStart">{{ $t('text_lower_line_start') }}</DropdownItem>
<DropdownItem name="upperStart">{{ $t('text_upper_word_start') }}</DropdownItem>
<DropdownItem name="lowerStart">{{ $t('text_lower_word_start') }}</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle('replacePunctuation',item)" transfer>
<Button :size="buttonSize" type="primary">
{{ $t('text_punctuation') }}
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="en">{{ $t('text_cn') }} -> {{ $t('text_en') }}</DropdownItem>
<DropdownItem name="zh">{{ $t('text_en') }} -> {{ $t('text_cn') }}</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle('zhTran',item)" transfer>
<Button :size="buttonSize" type="primary">
{{ $t('text_simplified_traditional') }}
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="simplified">{{ $t('text_simplified') }} -> {{ $t('text_traditional') }}</DropdownItem>
<DropdownItem name="traditional">{{ $t('text_traditional') }} -> {{ $t('text_simplified') }}</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
<FormItem>
<Button :size="buttonSize" type="primary" @click="replace.show = true">{{ $t('text_replace') }}</Button>
</FormItem>
<FormItem>
<Button :size="buttonSize" type="primary" @click="handle('lineRemoveRepeat')">
{{ $t('text_line_remove_duplicate') }}
</Button>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle(item)" transfer>
<Button :size="buttonSize" type="primary">
{{ $t('text_line_number') }}
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="addLineIndex">{{ $t('text_line_number_add') }}</DropdownItem>
<DropdownItem name="removeLineIndex">{{ $t('text_line_number_remove') }}</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle('lineSort',item)" transfer>
<Button :size="buttonSize" type="primary">
{{ $t('text_line_sort') }}
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="asc">{{ $t('text_line_sort_asc') }}</DropdownItem>
<DropdownItem name="desc">{{ $t('text_line_sort_desc') }}</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
<FormItem>
<Dropdown @on-click="(item)=>handle(item)" transfer>
<Button :size="buttonSize" type="primary">
{{ $t('text_filter') }}
<Icon type="ios-arrow-down"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="lineTrim">{{ $t('text_filter_trim') }}</DropdownItem>
<DropdownItem name="filterBlankLine">{{ $t('text_filter_blank_line') }}</DropdownItem>
</DropdownMenu>
</Dropdown>
</FormItem>
</option-block>
<Modal v-model="statShow" :styles="{top: '20px'}" width="700" footer-hide>
<Tabs value="stat">
<TabPane :label="$t('text_stat')" name="stat">
<Table :columns="statColumns" stripe border size="small" :data="statTable" />
</TabPane>
<TabPane :label="$t('text_stat_explain')" name="explain">
<Table :columns="statExplain.columns" border stripe size="small" :data="statExplain.data"/>
</TabPane>
</Tabs>
</Tabs>
</Col>
</Row>
<Modal v-model="statExplain.show" width="600" title="统计说明" class-name="ctool-stat-explain" footer-hide>
<Table :columns="statExplain.columns" stripe size="small" :data="statExplain.data"/>
</Modal>
<Modal v-model="replace.show" width="400" :title="$t('text_replace')">
<Modal v-model="replace.show" width="400" title="字符替换">
<Form label-position="top">
<Row :gutter="16">
<Col span="12">
<FormItem :label="$t('text_replace_search')">
<FormItem label="查找字符">
<Input v-model="replace.search" :rows="6" type="textarea"></Input>
</FormItem>
</Col>
<Col span="12">
<FormItem :label="$t('text_replace_replace')">
<FormItem label="替换字符">
<Input v-model="replace.replace" :rows="6" type="textarea"></Input>
</FormItem>
</Col>
</Row>
</Form>
<Alert>{{ $t('text_replace_explain') }}</Alert>
<Alert>可输入多行, 按行进行批量替换</Alert>
<div slot="footer">
<Button type="text" @click="replace.show = false">{{ $t('text_cancel') }}</Button>
<Button type="primary" @click="replaceRun()">{{ $t('text_submit') }}</Button>
<Button type="text" @click="replace.show = false">取消</Button>
<Button type="success" @click="replaceRun()">提交</Button>
</div>
</Modal>
</div>
</template>
<script>
import TextHandle from './library/text'
import autoHeightTextarea from "./components/autoHeightTextarea";
import heightResize from "./components/heightResize";
export default {
components:{
autoHeightTextarea,
heightResize
},
created() {
this.$initToolData('content')
this.current = Object.assign(this.current, this.$getToolData("content"))
},
computed: {
stat(){
return TextHandle(this.current.content).stat()
},
statTable() {
stat() {
let stat = TextHandle(this.current.content).stat();
return [
{
name1: this.$t('text_string_length'), value1: stat.string_length,
name2: this.$t('text_byte_length'), value2: `${stat.byte_utf8_length} / ${stat.byte_gbk_length}`
},
{
name1: this.$t('text_word_length'), value1: stat.word_length,
name2: this.$t('text_line_length'), value2: stat.line_length
},
{
name1: this.$t('text_zh_length'), value1: `${stat.zh_word} / ${stat.zh_punctuation}`,
name2: this.$t('text_en_length'), value2: `${stat.en_string} / ${stat.en_word} / ${stat.en_punctuation}`
},
{
name1: this.$t('text_int_length'), value1: `${stat.int_string} / ${stat.int_word}`,
name2: '-', value2: '-'
},
{name: "字符数", value: stat.string_length},
{name: "字节数(utf8/gbk)", value: `${stat.byte_utf8_length} / ${stat.byte_gbk_length}`},
{name: "字数", value: stat.word_length},
{name: "行数", value: stat.line_length},
{name: "(中文)字数/标点", value: `${stat.zh_word} / ${stat.zh_punctuation}`},
{name: "(英文)字母/单词/标点", value: `${stat.en_string} / ${stat.en_word} / ${stat.en_punctuation}`},
{name: "(数字)字符/单词", value: `${stat.int_string} / ${stat.int_word}`},
]
}
},
......@@ -182,9 +167,9 @@ export default {
this.current.original = this.current.content;
this.current.content = result;
this.$saveToolData(this.current);
this.$Message.success(this.$t('text_ok').toString())
this.$Message.success("完成")
} catch (e) {
this.$Message.error(this.$t('text_error',[e.message]).toString())
this.$Message.error(e.message)
}
},
replaceRun() {
......@@ -203,48 +188,40 @@ export default {
content: "",
original: "",
},
statShow:false,
statExplain: {
show: false,
columns: [
{
title: this.$t('text_item'),
title: '统计项目',
key: 'name',
width: 200
width: 100
},
{
title: this.$t('text_explain'),
title: '说明',
key: 'explain',
},
],
data: [
{name: this.$t('text_explain_byte_length_utf8_name'), explain: this.$t('text_explain_byte_length_utf8_info')},
{name: this.$t('text_explain_byte_length_gbk_name'), explain: this.$t('text_explain_byte_length_gbk_info')},
{name: this.$t('text_explain_string_length_name'), explain: this.$t('text_explain_string_length_info')},
{name: this.$t('text_explain_word_length_name'), explain: this.$t('text_explain_word_length_info')},
{name: this.$t('text_explain_int_length_name'), explain: this.$t('text_explain_int_length_info')},
{name: this.$t('text_explain_int_word_length_name'), explain: this.$t('text_explain_int_word_length_info')},
{name: this.$t('text_explain_blank_line_length_name'), explain: this.$t('text_explain_blank_line_length_info')},
{name: "字节数utf8", explain: "中文字符计3个长度"},
{name: "字节数gbk", explain: "中文字符计2个长度"},
{name: "字符数", explain: "中/英文字符均计1个长度 换行符不计入长度"},
{name: "字数", explain: "中文字数+英文单词数+中文标点数+英文标点数+数字单词数"},
// {name: "中文字数/标点",explain:"-"},
// {name: "英文字母/单词/标点",explain:"-"},
{name: "数字字符", explain: "统计单个数字出现次数 例如:'a1024 1024' 结果为:8"},
{name: "数字单词", explain: "例如:'a1024 1024' 结果为:1 其中:'a1024' 为英文单词 '1024' 为数字单词"},
{name: "行数", explain: "空行也会计入行数"},
]
},
statColumns: [
{
title: this.$t('text_item'),
key: 'name1',
width: 200
},
{
title: this.$t('text_value'),
key: 'value1',
align: "right"
},
{
title: this.$t('text_item'),
key: 'name2',
width: 200
title: '统计项目',
key: 'name',
width: 150
},
{
title: this.$t('text_value'),
key: 'value2',
title: '',
key: 'value',
align: "right"
},
],
......@@ -254,7 +231,7 @@ export default {
}
</script>
<style>
.ctool-stat-block .ivu-modal-body {
.ctool-stat-explain .ivu-modal-body {
padding: 0;
}
</style>
</style>
\ No newline at end of file
......@@ -15,7 +15,7 @@
<Checkbox v-model="current.filterLine">过滤中划线(-)</Checkbox>
</FormItem>
<FormItem>
<Checkbox v-model="current.isUpper">大写字母</Checkbox>
<Checkbox v-model="current.isUpper">大写</Checkbox>
</FormItem>
<FormItem>
<Checkbox v-model="current.isAddQuote">添加引号</Checkbox>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册