diff --git a/README.md b/README.md
index 5a437cc3c5a51fcd25f82e7d8405c302426a956d..01becd566f9b23308d76914dd0544dc89850a4b6 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,14 @@
# 程序开发常用工具
使用过程中的任何问题或者需要新的工具欢迎提交`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一致
-
> 方法2 / 方法3 不定期维护 仅供网络环境特别恶劣的同学使用
+## 支持 utools
+
## 功能列表
|功能|说明|离线使用|
|---|---|---|
diff --git a/package.json b/package.json
index cc84f10dc3b11e804fd26d520e086f7ec9e5407e..b677d45fba293fe0a9d3b7d20afc4a26c4d4ae57 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "c-tool",
- "version": "1.4.3",
+ "version": "1.4.4",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 8081",
diff --git a/public/utools.html b/public/utools.html
new file mode 100644
index 0000000000000000000000000000000000000000..02431f4b0a49d3690b8fa1a91aa840b80a683c7b
--- /dev/null
+++ b/public/utools.html
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+ Ctool 程序开发常用工具
+
+
+
+
+
\ No newline at end of file
diff --git a/src/adapter/chrome/manifest.json b/src/adapter/chrome/manifest.json
index cf7589d2ada4d788d28dbeab436090f74913d53e..5ac9296892a021657943b88c62fa39f2a59a2cac 100644
--- a/src/adapter/chrome/manifest.json
+++ b/src/adapter/chrome/manifest.json
@@ -12,7 +12,6 @@
"default_title": "常用开发工具",
"default_popup": "index.html"
},
- "options_page": "setting.html",
"icons": {
"16": "img/icon128.png",
"48": "img/icon128.png",
diff --git a/src/adapter/utools/plugin.json b/src/adapter/utools/plugin.json
index f90801cce6f39db05414ea47109e2689d5a9e66a..48113c08decf757da7281edb38f1d24e01e48cf1 100644
--- a/src/adapter/utools/plugin.json
+++ b/src/adapter/utools/plugin.json
@@ -3,14 +3,14 @@
"description": "Ctool 程序开发常用工具",
"author": "baiy",
"homepage": "https://github.com/baiy/Ctool",
- "main": "tool.html",
+ "main": "utools.html",
"version": "##version##",
- "logo": "img/icon_utools.png",
+ "logo": "img/icon128.png",
"pluginSetting": {
- "single": false
+ "single": true
},
+ "features": "##features##",
"development": {
- "main": "http://localhost:8081/tool.html"
- },
- "features": "##features##"
+ "main": "http://localhost:8081/utools.html"
+ }
}
\ No newline at end of file
diff --git a/src/config.js b/src/config.js
index 6616257d2772cc6c982ff9b18f34e4ef397a7fcc..8971dfd59ac5f4be6c2d372cccf090de88cb5ae2 100644
--- a/src/config.js
+++ b/src/config.js
@@ -1,134 +1,37 @@
-// 工具缓存数据过期时间(秒)
-const TOOL_DATA_EXPIRY = 3600 * 24
-// 徽章过期时间(天)
-const BADGE_EXPIRY = 5
-// 分类徽章
-const BADGE_CATEGORY = []
-// 工具徽章
-const BADGE_TOOL = []
-// 默认常用工具
-const DEFAULT_COMMON_TOOL = [
- 'hash', 'encrypt', 'json', 'base64', 'url', 'timestamp',
- 'qrCode', 'pinyin', 'ip', 'code', 'unicode',
- 'text', 'randomString', 'diffs',
-]
-
const category = [
- {'name': 'common'},
- {'name': 'encryption'},
- {'name': 'conversion'},
- {'name': 'serialize'},
- {'name': 'check'},
- {'name': 'generate'},
- {'name': 'other'},
+ {'name': 'common', 'title': '常用工具'},
+ {'name': 'encryption', 'title': '加密解密'},
+ {'name': 'conversion', 'title': '编码转换'},
+ {'name': 'serialize', 'title': '序列化'},
+ {'name': 'other', 'title': '其他工具'},
]
const tool = [
- {
- 'name': 'hash',
- 'cat': ['encryption']
- },
- {
- 'name': 'encrypt',
- 'cat': ['encryption']
- },
- {'name': 'sign', 'cat': ['encryption','check']},
- {'name': 'base64', 'cat': ['encryption']},
- {'name': 'json', 'cat': ['conversion', 'serialize']},
- {'name': 'url', 'cat': ['conversion']},
- {'name': 'timestamp', 'cat': ['conversion']},
- {'name': 'qrCode', 'cat': ['generate']},
- {'name': 'barcode', 'cat': ['generate']},
- {'name': 'pinyin', 'cat': ['conversion']},
- {'name': 'ip', 'cat': ['other']},
- {'name': 'code', 'cat': ['other']},
- {'name': 'unicode', 'cat': ['conversion']},
- {'name': 'decimalConvert', 'cat': ['conversion']},
- {'name': 'regex', 'cat': ['check']},
- {'name': 'randomString', 'cat': ['generate']},
- {'name': 'serializeConversion', 'cat': ['conversion', 'serialize']},
- {'name': 'diffs', 'cat': ['check']},
- {'name': 'crontab', 'cat': ['check']},
- {'name': 'websocket', 'cat': ['other']},
- {'name': 'unit', 'cat': ['other']},
- {'name': 'time', 'cat': ['other']},
- {'name': 'uuid', 'cat': ['generate']},
- {'name': 'jsonToObject', 'cat': ['conversion', 'serialize']},
- {'name': 'ascii', 'cat': ['conversion']},
- {'name': 'variableConversion', 'cat': ['conversion']},
- {'name': 'jwt', 'cat': ['conversion']},
- {'name': 'hexString', 'cat': ['conversion']},
- {'name': 'text', 'cat': ['other']},
- {'name': 'html', 'cat': ['conversion']},
+ {'name': 'hash', 'title': '哈希(hash)', 'cat': ['encryption']},
+ {'name': 'encrypt', 'title': '加密/解密', 'cat': ['encryption']},
+ {'name': 'base64', 'title': 'BASE64编码', 'cat': ['encryption']},
+ {'name': 'json', 'title': 'JSON工具', 'cat': ['conversion', 'serialize']},
+ {'name': 'url', 'title': 'URL编码', 'cat': ['conversion']},
+ {'name': 'timestamp', 'title': '时间戳', 'cat': ['conversion']},
+ {'name': 'qrCode', 'title': '二维码', 'cat': ['other']},
+ {'name': 'pinyin', 'title': '汉字转拼音', 'cat': ['conversion']},
+ {'name': 'ip', 'title': 'IP地址查询', 'cat': ['other']},
+ {'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': 'serializeConversion', 'title': '序列化转换', 'cat': ['conversion', 'serialize']},
+ {'name': 'diffs', 'title': '文本差异化对比', 'cat': ['other']},
+ {'name': 'crontab', 'title': 'crontab校验', 'cat': ['other']},
+ {'name': 'websocket', 'title': 'websocket调试', 'cat': ['other']},
+ {'name': 'unit', 'title': '单位换算', 'cat': ['other']},
+ {'name': 'time', 'title': '时间计算器', 'cat': ['other']},
+ {'name': 'uuid', 'title': 'UUID生成', 'cat': ['other']},
+ {'name': 'jsonToObject', 'title': 'JSON转实体类', 'cat': ['conversion', 'serialize']},
]
-// 工具类功能配置
-const feature = {
- qrCode: [
- {name: "generate", title: '生成'},
- {name: "reader", title: '解析'}
- ]
-}
-
-const utools = {
- keyword: {
- hash: ['md5', 'sha1', 'sha256', 'sha512', 'sm3'],
- encrypt: ['AES', 'DES', 'RC4', 'Rabbit', 'TripleDes', 'sm2'],
- jwt: ['jwtDecode'],
- hexString: ['hex to string', 'string to hex', '十六进制转字符串', '字符串转十六机制'],
- text: ['文本处理', '大小写转换', '中英文标点转换', '简繁转换', '字符替换', '字符统计', '行去重', '添加行号', '行排序', '过滤行首尾不可见字符', '过滤空行'],
- sign: ['签名', '验签', 'rsa'],
- },
- cmds: {
- timestamp: [
- {
- "type": "regex",
- // "label": "", //程序自动根据tool title填充
- "match": "/(^\\d{10}(?:\\d{3})?$)|(^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?$)/i",
- "minLength": 10,
- "maxLength": 25
- }
- ],
- qrCode: [
- {
- "type": "regex",
- "match": "/[a-zA-z]+://[^\\s]*/i",
- "minLength": 8,
- "feature": 'generate' // 适配工具内功能
-
- },
- {
- "type": "regex",
- "match": "/[a-zA-z]+://[^\\s]*/i",
- "minLength": 8,
- "feature": 'reader' // 适配工具内功能
- }
- ],
- ip: [
- {
- "type": "regex",
- "match": "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/i",
- "minLength": 7,
- "maxLength": 15
- }
- ],
- unicode: [
- {
- "type": "regex",
- "match": "/\\\\u[0-9a-f]{4}/i",
- "minLength": 6
- }
- ]
- }
-}
module.exports = {
category,
- tool,
- feature,
- utools,
- toolDataExpiry: TOOL_DATA_EXPIRY,
- badgeExpiry: BADGE_EXPIRY,
- badgeCategory: BADGE_CATEGORY,
- badgeTool: BADGE_TOOL,
- defaultCommonTool: DEFAULT_COMMON_TOOL
-}
+ tool
+}
\ No newline at end of file
diff --git a/src/helper.js b/src/helper.js
index 7be8b500dd8a9371b8e17a709b065fc7df1d4d5a..e7969a18e1df32ef32274e04c06a88ae2d8f9cab 100644
--- a/src/helper.js
+++ b/src/helper.js
@@ -1,40 +1,58 @@
-import {v4 as uuidV4} from 'uuid';
-import {openUrl as chromiumOpenUrl} from './adapter/chromium/helper';
-import {openUrl as utoolsOpenUrl} from './adapter/utools/helper';
-import {openUrl as firefoxOpenUrl} from './adapter/firefox/helper';
+import {stringify as queryStringify} from "query-string"
-export const env = (key) => {
+export const env = function (key) {
return process['ctool'][key] ? process['ctool'][key] : "";
};
export const isChrome = !!env('isChrome')
-export const isEdge = !!env('isEdge')
-export const isFirefox = !!env('isFirefox')
-export const isChromium = !!env('isChromium')
export const isWeb = !!env('isWeb')
export const isUtools = !!env('isUtools')
-export const uuid = () => {
- return uuidV4().toLowerCase();
-}
-
-export const openUrl = (url) => {
- if (isChromium) {
- return chromiumOpenUrl(url)
+export const trim = function (str, char, type) {
+ if (char) {
+ if (type === 'left') {
+ return str.replace(new RegExp('^\\' + char + '+', 'g'), '');
+ } else if (type === 'right') {
+ return str.replace(new RegExp('\\' + char + '+$', 'g'), '');
+ }
+ return str.replace(new RegExp('^\\' + char + '+|\\' + char + '+$', 'g'), '');
}
- if (isUtools) {
- return utoolsOpenUrl(url)
+ return str.replace(/^\s+|\s+$/g, '');
+};
+
+export const inArray = function (value, arr) {
+ return arr.findIndex((v) => {
+ return value === v
+ }) !== -1
+};
+
+export const openTab = function (url) {
+ if (isChrome && chrome.tabs) {
+ return chrome.tabs.create({url: url, selected: true});
}
- if (isFirefox) {
- return firefoxOpenUrl(url)
+ if (isUtools && window.utools){
+ return window.utools.shellOpenExternal(url)
}
return window.open(url);
};
-export const version = env('version').trim()
+export const stat = function (action, data = {}) {
+ setTimeout(function () {
+ try {
+ let img = new Image(1, 1);
+ img.src = 'https://www.baiy.org/chrome_tool/stat/?' + queryStringify(
+ Object.assign(
+ {
+ v: env('version'),
+ a: action,
+ r: Math.random()
+ },
+ data
+ )
+ );
+ } catch (e) {
+ // todo
+ }
+ }, 3000)
+};
-export const setDisplayMode = (mode) => {
- mode = ['light', 'dark', 'auto'].includes(mode) ? mode : 'light'
- console.log(`set display mode:${mode}`)
- document.getElementsByTagName('html')[0].setAttribute('theme-mode', mode);
-}
diff --git a/src/setting.js b/src/setting.js
deleted file mode 100644
index 19447d49ee02aff8339d7535d410f3d8c41371d7..0000000000000000000000000000000000000000
--- a/src/setting.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import Vue from 'vue'
-import ViewUI from 'view-design';
-import 'view-design/dist/styles/iview.css';
-import App from './setting.vue'
-
-Vue.config.productionTip = false;
-
-Vue.use(ViewUI);
-
-new Vue({
- render: h => h(App)
-}).$mount('#app');
diff --git a/src/tool.js b/src/tool.js
index 6389deb99b68c16eef1f7edc5f226500ca5ee119..c6d51292a8857f9835cabfe5c707eef07c8957c8 100644
--- a/src/tool.js
+++ b/src/tool.js
@@ -3,8 +3,10 @@ import ViewUI from 'view-design'
import 'view-design/dist/styles/iview.css'
import router from './tool.router'
import optionBlock from './components/optionBlock'
-import { plugin as modelPlugin } from './tool/model'
+import model, {plugin as modelPlugin} from './tool/model'
import App from './tool.vue'
+import {isUtools} from './helper'
+import config from "./tool/config";
Vue.config.productionTip = false
@@ -13,7 +15,18 @@ Vue.use(modelPlugin)
Vue.component('option-block', optionBlock);
(function () {
- if (document.body.clientWidth > 900) {
+ if (isUtools) {
+ let tool = window.utools.db.get("_current_tool_");
+ if (tool && tool.data) {
+ let cat = config.getToolDefaultCategory(tool.data);
+ if (cat) {
+ model.setCategoryHistory(cat)
+ model.setToolHistory(cat, tool.data)
+ }
+ }
+ }
+
+ if (document.body.clientWidth > 900 || isUtools) {
console.log('调整窗口大小')
const page = document.getElementById('page')
page.style.width = 'auto'
@@ -21,7 +34,6 @@ Vue.component('option-block', optionBlock);
page.style.height = 'auto'
}
})()
-
new Vue({
router,
render: h => h(App),
diff --git a/src/tool.vue b/src/tool.vue
index 7bd5d4bdbf5a4acf720c126afb74fdb5a46164f1..979262fda329efe3ddd32e7112e7847a0bc17a23 100644
--- a/src/tool.vue
+++ b/src/tool.vue
@@ -10,7 +10,7 @@
{{ cat.title }}
-