From ea3dcdeacc300268a62491da819f16168f00d854 Mon Sep 17 00:00:00 2001 From: baiy Date: Thu, 12 Aug 2021 17:04:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E6=9C=AC=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=B7=A5=E5=85=B7=20#58=20#55?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 52 +++--- package-lock.json | 7 +- package.json | 3 +- src/config.js | 48 +++-- src/tool.router.js | 4 + src/tool/config.js | 18 +- src/views/tool/library/text.js | 10 +- src/views/tool/text.vue | 325 +++++++++++++++------------------ src/views/tool/uuid.vue | 2 +- 9 files changed, 240 insertions(+), 229 deletions(-) diff --git a/README.md b/README.md index 8492a87..38e5983 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ # 程序开发常用工具 + 使用过程中的任何问题或者需要新的工具欢迎提交`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) diff --git a/package-lock.json b/package-lock.json index f9ba976..0688a58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "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", diff --git a/package.json b/package.json index 6a7e31d..5f35e0f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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", diff --git a/src/config.js b/src/config.js index 69b36c8..0d5e6b2 100644 --- a/src/config.js +++ b/src/config.js @@ -1,9 +1,26 @@ +// 工具缓存数据过期时间(秒) +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 diff --git a/src/tool.router.js b/src/tool.router.js index 7ce6d8a..5b05361 100644 --- a/src/tool.router.js +++ b/src/tool.router.js @@ -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) } ] diff --git a/src/tool/config.js b/src/tool/config.js index 44f696c..1f8acd6 100644 --- a/src/tool/config.js +++ b/src/tool/config.js @@ -1,22 +1,18 @@ 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 diff --git a/src/views/tool/library/text.js b/src/views/tool/library/text.js index bc083f6..cbd088c 100644 --- a/src/views/tool/library/text.js +++ b/src/views/tool/library/text.js @@ -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 diff --git a/src/views/tool/text.vue b/src/views/tool/text.vue index 7faf4a4..8b8d662 100644 --- a/src/views/tool/text.vue +++ b/src/views/tool/text.vue @@ -1,177 +1,162 @@ + \ No newline at end of file diff --git a/src/views/tool/uuid.vue b/src/views/tool/uuid.vue index d3a10c4..2e4651b 100644 --- a/src/views/tool/uuid.vue +++ b/src/views/tool/uuid.vue @@ -15,7 +15,7 @@ 过滤中划线(-) - 大写字母 + 大写 添加引号 -- GitLab