提交 5fb6fe7c 编写于 作者: B baiy 提交者: ninecents

update

上级 44394c7e
......@@ -62,9 +62,8 @@ npm run build -adapter=[chrome|edge|utools|firefox|web]
|websocket调试|`websocket`,`在线调试`|×|
|单位换算|`长度`,`面积`,`体积`,`质量`,`温度`,`压力`,`功率`,`功`,`密度`,`力`,`时间`,`速度`,`数据存储`,`角度`|√|
|时间计算器| - |√|
|JSON工具|`格式化`,`校验`,`压缩`,`转义`,`去除转义`,`Unicode转中文`,`中文转Unicode`,`转GET参数`|√|
|JSON工具|`格式化`,`校验`,`压缩`,`转义`,`去除转义`,`Unicode转中文`,`中文转Unicode`,`转GET参数`,`Java`, `C#`, `Go`, `Dart`,`csv`,`table`|√|
|UUID|在线生成uuid|√|
|JSON转实体类|`Java`, `C#`, `Go`, `Dart`|√|
|ascii编码转换|`十进制`, `十六进制`, `八进制`, `二进制`, `字符串`|√|
|变量名格式转换|`Var Name`, `var-name`, `VAR_NAME`, `VarName`, `varName`, `var_name`, `var name`|√|
|jwt解码|`header`, `payload`|√|
......
此差异已折叠。
{
"name": "c-tool",
"version": "1.9.3",
"version": "1.10.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 8081",
......@@ -9,34 +9,39 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"@babel/parser": "^7.16.4",
"@babel/parser": "^7.16.7",
"@prettier/plugin-php": "^0.17.6",
"@typescript-eslint/typescript-estree": "^5.4.0",
"@typescript-eslint/typescript-estree": "^5.8.1",
"angular-html-parser": "^1.8.0",
"axios": "^0.21.4",
"babel-runtime": "^6.26.0",
"bignumber.js": "^9.0.1",
"bignumber.js": "^9.0.2",
"code-formatter": "0.0.1",
"codemirror": "^5.64.0",
"codemirror-graphql": "^1.2.4",
"codemirror": "^5.65.0",
"codemirror-graphql": "^1.2.11",
"cosmiconfig": "^7.0.1",
"cron-parser": "^2.16.3",
"cronstrue": "^1.122.0",
"crypto-js": "^3.3.0",
"csv-parse": "^5.0.4",
"csv-stringify": "^6.0.5",
"darkreader": "^4.9.43",
"diff-match-patch": "^1.0.5",
"file": "^0.2.2",
"file-type": "^16.5.3",
"graphql": "15.7.2",
"hexy": "^0.3.4",
"ipinyinjs": "^1.0.0",
"jian_fan": "^1.0.3",
"jimp": "^0.16.1",
"js-base64": "^2.6.4",
"js-base64": "^3.7.2",
"js-htmlencode": "^0.3.0",
"js-yaml": "^3.14.1",
"jsbarcode": "^3.11.5",
"json-to-properties": "^1.1.3",
"json5": "^2.2.0",
"jsonlint": "^1.6.3",
"jsrsasign": "^10.5.0",
"jsrsasign": "^10.5.1",
"jsrsasign-util": "^1.0.5",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
......@@ -44,28 +49,28 @@
"moment": "^2.29.1",
"php-array-reader": "^1.3.2",
"phparr": "^0.2.0",
"postcss": "^8.4.4",
"postcss": "^8.4.5",
"postcss-less": "^5.0.0",
"postcss-scss": "^4.0.2",
"prettier": "^2.5.0",
"prettier": "^2.5.1",
"prettier-plugin-sql": "^0.3.0",
"properties-to-json": "^0.1.7",
"qrcode": "^1.5.0",
"qrcode-parser": "^1.2.0",
"query-string": "^6.14.1",
"serialize-php": "^1.1.2",
"sm-crypto": "^0.1.4",
"sm-crypto": "^0.3.7",
"system": "^2.0.1",
"typescript": "^4.5.2",
"typescript": "^4.5.4",
"uglify-js": "3.14.3",
"uuid": "^8.3.2",
"view-design": "^4.7.0",
"vue": "^2.6.14",
"vue-i18n": "^8.26.7",
"vue-i18n": "^8.26.8",
"vue-router": "^3.5.3",
"vuedraggable": "^2.24.3",
"x2js": "github:abdolence/x2js",
"xml-formatter": "^2.5.1"
"xml-formatter": "^2.6.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.12.1",
......
......@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Ctool 程序开发常用工具</title>
</head>
<body style="padding-bottom: 30px">
<body>
<div id="page" style="width: 800px;height: 550px;margin: 0 auto;padding: 0 10px;overflow-y:auto;">
<div id="app"></div>
</div>
......
{
"name": "Ctool 程序开发常用工具",
"description": "程序开发常用工具,哈希/加解密/编码转换/时间戳/二维码/拼音/IP查询/代码优化/Unicode/正则等...",
"name": "__MSG_main_manifest_name__",
"description": "__MSG_main_manifest_description__",
"version": "##version##",
"author": "wo@baiy.org",
"offline_enabled": true,
......@@ -9,7 +9,7 @@
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"browser_action": {
"default_icon": "img/icon_chrome.png",
"default_title": "常用开发工具",
"default_title": "__MSG_main_manifest_default_title__",
"default_popup": "index.html"
},
"background": {
......@@ -28,7 +28,7 @@
],
"commands": {
"panel": {
"description": "打开独立工具窗口",
"description": "__MSG_main_manifest_commands_panel_description__",
"global": true
}
},
......
{
"name": "Ctool 程序开发常用工具",
"description": "程序开发常用工具,哈希/加解密/编码转换/时间戳/二维码/拼音/IP查询/代码优化/Unicode/正则等...",
"name": "__MSG_main_manifest_name__",
"description": "__MSG_main_manifest_description__",
"version": "##version##",
"author": "wo@baiy.org",
"offline_enabled": true,
......@@ -9,7 +9,7 @@
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"browser_action": {
"default_icon": "img/icon_chrome.png",
"default_title": "常用开发工具",
"default_title": "__MSG_main_manifest_default_title__",
"default_popup": "index.html"
},
"background": {
......@@ -28,7 +28,7 @@
],
"commands": {
"panel": {
"description": "打开独立工具窗口",
"description": "__MSG_main_manifest_commands_panel_description__",
"global": true
}
}
......
export const openUrl = (url) => {
return browser.tabs.create({url:url});
}
export const getMessage = (messageName, values = {}, placeholders = []) => {
let substitutions = []
placeholders.forEach((key) => {
substitutions.push((key in values) ? values[key] : "")
})
return browser.i18n.getMessage(messageName, substitutions);
}
{
"name": "Ctool 程序开发常用工具",
"description": "程序开发常用工具,哈希/加解密/编码转换/时间戳/二维码/拼音/IP查询/代码优化/Unicode/正则等...",
"name": "__MSG_main_manifest_name__",
"description": "__MSG_main_manifest_description__",
"version": "##version##",
"author": "wo@baiy.org",
"homepage_url": "https://github.com/baiy/Ctool",
......@@ -8,9 +8,10 @@
"manifest_version": 2,
"browser_action": {
"default_icon": "img/icon_chrome.png",
"default_title": "常用开发工具",
"default_title": "__MSG_main_manifest_default_title__",
"default_popup": "index.html"
},
"default_locale": "zh_CN",
"background": {
"scripts": ["background.js"]
},
......@@ -28,7 +29,7 @@
"commands": {
"_execute_browser_action": {},
"panel": {
"description": "打开独立工具窗口"
"description": "__MSG_main_manifest_commands_panel_description__"
}
}
}
<template>
<div v-show="show" class="ctool-bottom">
<div class="ctool-bottom-block">
<notice-block/>
</div>
</div>
</template>
<script>
import Notice from './components/notice'
export default {
name: "bottom",
components: {
"notice-block": Notice
},
data() {
return {show: false}
},
methods: {
setShow() {
this.show = true
}
}
}
</script>
<style scoped>
.ctool-bottom {
width: 100%;
position: fixed;
z-index: 9999;
bottom: 0;
left: 0;
height: 30px;
overflow: hidden;
border-top: 1px solid #dcdee2;
background: #FFF;
}
.ctool-bottom-block {
height: 28px;
line-height: 28px;
overflow: hidden;
}
</style>
\ No newline at end of file
<template>
<div>
<div class="ctool-bottom">
<div class="ctool-bottom-right" style="width: 210px">
<Tooltip class="ctool-bottom-tooltip" transfer :content="$t('main_tool_'+currentTool) + ' -' + $t('main_history')" placement="top">
<Badge v-if="historyLength>0" dot :offset="[6,10]">
<Icon type="md-time" :size="22" @click="historyShow= true"/>
</Badge>
<template v-else>
<Icon type="md-time" :size="22" @click="historyShow= true"/>
</template>
</Tooltip>
<Tooltip class="ctool-bottom-tooltip" transfer content="Github" placement="top">
<Icon type="logo-github" :size="22" @click="openUrl('https://github.com/baiy/Ctool')"/>
</Tooltip>
<Tooltip class="ctool-bottom-tooltip" transfer :content="$t('main_ui_setting')" placement="top">
<Icon type="md-settings" :size="22" @click="settingShow = true"/>
</Tooltip>
<Tooltip class="ctool-bottom-tooltip" transfer :content="$t('main_ui_issues')" placement="top">
<Icon type="md-help-circle" :size="22" @click="openUrl('https://github.com/baiy/Ctool/issues')"/>
</Tooltip>
<Tooltip class="ctool-bottom-tooltip" transfer :content="$t('main_ui_open_full')" placement="top">
<Icon type="md-expand" :size="22" @click="openUrl('_new')" v-if="!isUtools"/>
</Tooltip>
</div>
<div class="ctool-bottom-block" style="margin-right: 210px">
<notice-block/>
</div>
</div>
<Drawer :title="$t('main_ui_setting')" v-model="settingShow" :width="400">
<setting-block v-if="settingShow"></setting-block>
</Drawer>
<Drawer :title="$t('main_tool_'+currentTool)+' - '+$t('main_history')" v-model="historyShow" :width="100">
<History v-if="historyShow" @close="historyShow = false"/>
</Drawer>
</div>
</template>
<script>
import Notice from './notice'
import History from './history'
import {isUtools, openUrl} from '../helper'
import settingBlock from "../views/setting/block"
import model from "../tool/model";
import historyFactory from "../tool/history";
export default {
name: "bottom",
components: {
"notice-block": Notice,
"setting-block": settingBlock,
History
},
data() {
return {
isUtools,
settingShow: false,
historyShow: false,
currentTool: model.getCurrentTool(),
currentToolSetInterval: null,
}
},
computed: {
historyLength() {
return historyFactory(this.currentTool).length()
}
},
created() {
this.currentToolSetInterval = setInterval(() => {
this.currentTool = model.getCurrentTool()
}, 2000);
},
methods: {
openUrl(url) {
openUrl(url === '_new' ? window.location.href : url)
}
},
destroyed() {
if (this.currentToolSetInterval !== null) {
clearInterval(this.currentToolSetInterval);
this.currentToolSetInterval = null
}
},
}
</script>
<style>
.ctool-bottom {
width: 100%;
position: fixed;
bottom: 0;
left: 0;
height: 33px;
padding-top: 2px;
overflow: hidden;
border-top: 1px solid #dcdee2;
background: #FFF;
}
.ctool-bottom-block {
height: 30px;
line-height: 30px;
overflow: hidden;
}
.ctool-bottom-right {
line-height: 30px;
float: right;
text-align: right;
}
.ctool-bottom-right .ivu-icon {
margin-right: 15px;
cursor: pointer;
}
.ctool-bottom-right .ivu-icon:hover {
color: #1abc9c;
}
</style>
<template>
<div>
<Table ref="historyTable" border :columns="columns" :data="lists" :height="tableHeight">
<template slot-scope="{ row }" slot="_value">
<div>{{ stringify(row.value) }}}</div>
</template>
<template slot-scope="{ index }" slot="_op">
<Button type="primary" size="small" @click="view(index)">{{ $t('main_ui_views') }}</Button>
<Button type="primary" style="margin-left: 5px" @click="load(index)" size="small">
{{ $t('main_ui_load') }}
</Button>
</template>
</Table>
<div class="drawer-footer">
<Button type="primary" @click="clear">{{ $t('main_history_clear') }}</Button>
</div>
</div>
</template>
<script>
import model from '../tool/model'
import historyFactory, {setForceLoadHistoryIndex} from "../tool/history";
export default {
name: "history",
data() {
return {
lists: [],
columns: [
{
title: this.$t('main_history_time'),
key: 'time',
width: 180
},
{
title: this.$t('main_history_data'),
slot: '_value',
ellipsis: true,
},
{
title: this.$t('main_history_op'),
slot: '_op',
width: 160
}
],
}
},
computed: {
tableHeight() {
// 设置表格高度
return window.innerHeight - 140
}
},
created() {
let history = historyFactory(this.currentTool())
if (history.length() < 1) {
return this.$Message.error(this.$t('main_history_null').toString())
}
this.lists = history.all()
},
methods: {
currentTool() {
return model.getCurrentTool()
},
stringify(value) {
return JSON.stringify(value)
},
view(index) {
this.$Modal.info({
render: (h) => {
return h('Input', {
props: {
type: "textarea",
rows: 10,
value: JSON.stringify(historyFactory(this.currentTool()).get(index), null, "\t"),
}
})
},
width: 700,
okText: this.$t('main_ui_close')
})
},
load(index) {
setForceLoadHistoryIndex(index)
this.close()
this.$router.push({
path: this.$router.currentRoute.fullPath,
query: {
t: Date.now(),
},
});
},
clear() {
historyFactory(model.getCurrentTool()).clear()
this.close()
},
close(){
this.$emit('close')
}
}
};
</script>
<style scoped>
.drawer-footer {
width: 100%;
position: absolute;
bottom: 0;
left: 0;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
background: #fff;
}
</style>
......@@ -16,6 +16,8 @@ import cache from "../tool/cache";
import user from "../tool/user";
import axios from "axios";
import _ from "lodash";
import {dispatchWindowResize} from '../tool/event'
import {getCurrentLocale} from "../i18n/index";
const CACHE_NAME = 'notice_item';
const CACHE_EXPIRY = 3600 * 24;
......@@ -86,6 +88,7 @@ export default {
url: 'https://www.baiy.org/chrome_tool/notice/',
responseType: 'json',
params: {
i: getCurrentLocale(),
v: env('version'),
p: env('platform'),
u: user.uid(),
......@@ -114,9 +117,9 @@ export default {
if (this.listData.length > 1) {
this.timer = setInterval(this.scrollAnimate, 6000);
}
if (this.listData.length > 0) {
this.$parent['setShow']()
}
this.$nextTick(()=>{
dispatchWindowResize()
})
},
scrollAnimate() {
this.animateUp = true
......
......@@ -4,30 +4,34 @@
</Form>
</template>
<script>
export default {
name: 'optionBlock',
props: {
center: {
type: Boolean,
default: false
},
export default {
name: 'optionBlock',
props: {
center: {
type: Boolean,
default: false
},
computed:{
style(){
let css = {
padding:"10px 0",
};
if (this.center){
css.textAlign = "center"
}
return css;
disablePadding: {
type: Boolean,
default: false
}
},
computed: {
style() {
let css = {
padding: !this.disablePadding ? "10px 0" : "0",
};
if (this.center) {
css.textAlign = "center"
}
return css;
}
};
}
};
</script>
<style>
.option-block .ivu-form-item{
margin-bottom: 0;
}
.option-block .ivu-form-item {
margin-bottom: 0;
}
</style>
import VueI18n from 'vue-i18n'
import Vue from 'vue'
import {getMessage as chromiumGetMessage} from "../adapter/chromium/helper"
import {isChromium} from "../helper";
import {getMessage as firefoxGetMessage} from "../adapter/firefox/helper"
import {isChromium,isFirefox} from "../helper";
import locales from "./locales/build.js";
Vue.use(VueI18n)
......@@ -35,7 +36,7 @@ const translate = (code, key, values = {}) => {
if (!key) return '';
let locale = code === "_default" ? DEFAULT_LOCALE : code;
if (isChromium && code === "_default") {
if (code === "_default" && (isChromium || isFirefox) ) {
let placeholders = []
if (
(locale in LOCALE_DETAIL)
......@@ -44,7 +45,12 @@ const translate = (code, key, values = {}) => {
) {
placeholders = LOCALE_DETAIL[locale][key]['placeholders']
}
return chromiumGetMessage(key, values, placeholders)
if (isChromium){
return chromiumGetMessage(key, values, placeholders)
}
if (isFirefox){
return firefoxGetMessage(key, values, placeholders)
}
}
let text = getMessage(code, key);
......
{
"input": "Input",
"encode":"Encode",
"encode": "Encode",
"decode": "Decode",
"url_safe":"Url Safe",
"upload_file": "Upload File",
"output":"Output"
"url_safe": "Url Safe",
"output": "Output",
"error": "error: {0}",
"hex_dump": "Hex Dump",
"setting": "Setting",
"hex_dump_show_mode": "Show Mode",
"hex_dump_format": "Format",
"hex_dump_caps": "Caps Lock",
"hex_dump_caps_lower": "Lower",
"hex_dump_caps_upper": "Upper",
"hex_dump_width": "Width",
"hex_dump_show_mode_hex": "Hex",
"hex_dump_show_mode_text": "Text",
"hex_dump_setting": "Hex Dump Setting",
"hex_dump_format_twos": "Twos",
"hex_dump_format_fours": "Fours",
"hex_dump_format_eights": "Eights",
"hex_dump_format_sixteens": "Sixteens",
"hex_dump_format_none": "None",
}
{
"input": "Input",
"content_empty": "Please enter content",
"output": "Output",
"json_input_empty": "Please Enter Json Content",
"error": "Exception:{0}",
"format": "Format",
"compress": "Compress",
"escape": "Escape",
"clear_escape": "Unescape",
"add_escape":"Add Escape",
"unicode":"Unicode",
"unicode_to_zh": "Unicode->Zh",
"zh_to_unicode": "Zh->Unicode",
"to_get": "To Get",
"get_to_json": "Get=>Json",
"clear": "Clear"
"complete": "Processing is complete",
"get": "Get Query",
"object":"To Object",
"csv": "CSV",
"table":"Html Table",
"add_quote":"Add Quote",
"column_name":"Column Name",
"json_type_json": "Json",
"json_type_keyed": "Keyed",
"json_type_array": "Array",
"json_type_column": "Column Array"
}
{
"input": "Input",
"output":"Output",
"type_error": "Conversion type error",
"format": "Beautify",
"error":"Error:{0}"
}
......@@ -5,7 +5,9 @@
"ui_views": "View",
"ui_load": "Loading",
"ui_close": "Close",
"ui_copy_text_ok": "Result Copied ^o^",
"ui_issues": "Issues Feedback",
"ui_open_full": "Open Full Screen Tab",
"ui_copy_text_ok": "Copy Success ^o^",
"ui_copy_image_ok": "Image Copied ^o^",
// views
"setting_language": "Language",
......@@ -60,7 +62,6 @@
"tool_unit": "Unit Convert",
"tool_time": "Time Calculator",
"tool_uuid": "UUID",
"tool_jsonToObject": "JSON to Object",
"tool_ascii": "ASCII",
"tool_variableConversion": "Variable Name",
"tool_jwt": "JWT",
......@@ -71,5 +72,10 @@
"tool_armConverter": "ARM/HEX",
// other
"css_main_category_item_style": "padding: 0 10px",
"editor_line_wrapping": "Line Wrapping"
"editor_line_wrapping": "Line Wrapping",
// manifest
"manifest_name": "Ctool Commonly Used Developer Tools",
"manifest_description": "Commonly Used Developer Tools: Hash/Encrypt/Decrypt/Code Convert/Timestamp/Qrcode/IP Query/Code Formatter/Unicode/Regex/...",
"manifest_default_title": "Commonly Used Developer Tools",
"manifest_commands_panel_description": "Open Popup Tool Winodws"
}
......@@ -4,7 +4,6 @@
"generate_error": "Generate Error:{0}",
"reader_title": "Reader",
"reader_input": "Please enter the QR code image url or click the button below to upload the image",
"reader_upload": "Upload Image",
"reader_output": "Output",
"reader_error": "Reader Error:{0}",
"reader_parsing_failure": "Image parsing failure",
......
......@@ -2,6 +2,7 @@
"reference": "Reference",
"expression": "Expression",
"replace_content": "Replace Content",
"replace": "Replace",
"delete": "Delete",
"input": "Input",
"global": "Global",
......@@ -10,23 +11,4 @@
"output_count": "{0} Total Matches",
"output_emty": "No match result, please check expression",
"error": "Error:{0}",
"reference_url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions",
"type_zh": "Chinese",
"type_complex": "Double-byte characters (including Chinese characters)",
"type_blank": "Blank lines",
"type_email": "Email",
"type_url": "URL",
"type_cn_mobile": "China Mobile Phone Number",
"type_ip": "IP",
"type_cn_tel": "China Phone Number",
"type_tencent_qq": "Tencent QQ",
"type_cn_postcode": "China Postcode",
"type_date": "Data (YYYY-MM-DD)",
"type_positive_integer": "Positive Integer",
"type_negative_integer": "Negative Integer",
"type_integer": "Integer",
"type_non_negative_integer": "Non Negative Integer",
"type_non_positive_integer": "Non Positive Integer",
"type_positive_float": "Positive Float",
"type_negative_float": "Negative Float"
}
......@@ -19,5 +19,12 @@
"day": "Day",
"hour": "Hour",
"minute": "Minute",
"second": "Second"
"second": "Second",
analyze: "Time Analyze",
analyze_year: "Year",
analyze_quarter: "Quarter",
analyze_month: "Month",
analyze_year_output: "{year}: Q{quarter},{weekOfYear} Week,{dayOfYear} Day,{hourOfYear} Hour,{minuteOfYear} Minute,{secondOfYear} Second",
analyze_quarter_output: "Q{quarter}:{weekOfQuarter} Week,{dayOfQuarter} Day,{hourOfQuarter} Hour,{minuteOfQuarter} Minute,{secondOfQuarter} Second",
analyze_month_output: "{month}:{weekOfMonth} Week,{hourOfMonth} Hour,{minuteOfMonth} Minute,{secondOfMonth} Second"
}
{
"input": "输入",
"encode":"编码",
"encode": "编码",
"decode": "解码",
"url_safe":"Url 安全",
"upload_file": "上传文件",
"output":"输出"
"url_safe": "Url 安全",
"output": "输出",
"error": "错误: {0}",
"hex_dump": "Hex Dump",
"setting": "配置",
"hex_dump_show_mode":"显示模式",
"hex_dump_format": "格式",
"hex_dump_caps": "大小写",
"hex_dump_caps_lower": "小写",
"hex_dump_caps_upper": "大写",
"hex_dump_width":"宽度",
"hex_dump_show_mode_hex": "十六进制",
"hex_dump_show_mode_text": "文本",
"hex_dump_setting": "十六进制显示配置",
"hex_dump_format_twos": "2位",
"hex_dump_format_fours": "4",
"hex_dump_format_eights": "8位",
"hex_dump_format_sixteens": "16位",
"hex_dump_format_none": "无分隔"
}
{
"input": "输入",
"content_empty": "请输入内容",
"output": "输出",
"json_input_empty": "请输入JSON内容",
"error":"异常:{0}",
"format": "格式化",
"compress":"压缩",
"escape": "转移",
"clear_escape":"去除转移",
"escape": "转义",
"clear_escape":"去除转义",
"add_escape":"添加转义",
"unicode":"Unicode",
"unicode_to_zh": "Unicode转中文",
"zh_to_unicode":"中文转Unicode",
"to_get": "转Get参数",
"get_to_json":"Get参数转Json",
"clear": "清空"
"complete": "处理完成",
"get": "Get参数",
"object":"转实体类",
"csv": "CSV",
"table":"Html Table",
"add_quote":"添加引号",
"column_name":"列名",
"json_type_json": "Json",
"json_type_keyed": "关联对象",
"json_type_array": "数组",
"json_type_column": "列数组",
}
{
"input": "输入",
"output":"输出",
"type_error": "转换类型错误",
"format": "格式化",
"error":"错误:{0}"
}
......@@ -5,7 +5,9 @@
"ui_views": "查看",
"ui_load": "加载",
"ui_close": "关闭",
"ui_copy_text_ok": "结果已复制 ^o^",
"ui_issues": "问题反馈",
"ui_open_full": "打开全屏窗口",
"ui_copy_text_ok": "复制成功 ^o^",
"ui_copy_image_ok": "图片已复制 ^o^",
// 界面
"setting_language": "语言",
......@@ -55,12 +57,11 @@
"tool_randomString": "随机字符生成",
"tool_serializeConversion": "序列化转换",
"tool_diffs": "文本比对",
"tool_crontab": "crontab",
"tool_websocket": "websocket",
"tool_crontab": "Crontab",
"tool_websocket": "Websocket",
"tool_unit": "单位换算",
"tool_time": "时间计算器",
"tool_uuid": "UUID生成",
"tool_jsonToObject": "JSON转实体类",
"tool_ascii": "ASCII",
"tool_variableConversion": "变量名",
"tool_jwt": "JWT解码",
......@@ -71,5 +72,10 @@
"tool_armConverter": "ARM/HEX",
// 其他
"css_main_category_item_style": "padding: 0 20px",
"editor_line_wrapping": "自动换行"
"editor_line_wrapping": "自动换行",
// manifest
"manifest_name": "Ctool 程序开发常用工具",
"manifest_description": "程序开发常用工具,哈希/加解密/编码转换/时间戳/二维码/拼音/IP查询/代码优化/Unicode/正则等...",
"manifest_default_title": "常用开发工具",
"manifest_commands_panel_description": "打开独立工具窗口",
}
......@@ -4,7 +4,6 @@
"generate_error": "生成错误:{0}",
"reader_title": "二维码解析",
"reader_input": "请输入二维码图片地址或点击下方按钮上传图片",
"reader_upload": "上传图片",
"reader_output": "输出",
"reader_error": "解析错误:{0}",
"reader_parsing_failure": "图片解析失败",
......
......@@ -2,6 +2,7 @@
"reference": "参考",
"expression": "正则表达式",
"replace_content": "替换内容",
"replace": "替换",
"delete": "删除",
"input": "输入待处理内容",
"global": "全局搜索",
......@@ -10,23 +11,4 @@
"output_count": "共 {0} 个匹配项",
"output_emty": "没有匹配结果,请检查正则",
"error": "错误:{0}",
"reference_url": "https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions",
"type_zh": "中文字符",
"type_complex": "双字节字符(包括汉字在内)",
"type_blank": "空白行",
"type_email": "Email地址",
"type_url": "网址URL",
"type_cn_mobile": "手机",
"type_ip": "IP地址",
"type_cn_tel": "国内电话号码",
"type_tencent_qq": "腾讯QQ号",
"type_cn_postcode": "中国邮政编码",
"type_date": "(年-月-日)格式日期",
"type_positive_integer": "正整数",
"type_negative_integer": "负整数",
"type_integer": "整数",
"type_non_negative_integer": "非负整数(正整数 + 0)",
"type_non_positive_integer": "非正整数(负整数 + 0)",
"type_positive_float": "正浮点数",
"type_negative_float": "负浮点数"
}
......@@ -19,5 +19,12 @@
"day": "日",
"hour": "小时",
"minute": "分钟",
"second": "秒"
"second": "秒",
analyze: "时间分析",
analyze_year: "年",
analyze_quarter: "季度",
analyze_month: "月",
analyze_year_output: "{year}年:{quarter}季度,{weekOfYear}周,{dayOfYear}天,{hourOfYear}小时,{minuteOfYear}分钟,{secondOfYear}秒",
analyze_quarter_output: "{quarter}季度:{weekOfQuarter}周,{dayOfQuarter}天,{hourOfQuarter}小时,{minuteOfQuarter}分钟,{secondOfQuarter}秒",
analyze_month_output: "{month}月:{weekOfMonth}周,{hourOfMonth}小时,{minuteOfMonth}分钟,{secondOfMonth}秒"
}
......@@ -4,7 +4,14 @@
@primary-color: #1abc9c;
@link-color: #1abc9c;
.ivu-tooltip-content .ivu-tooltip-arrow{
display: none;
}
// 设置代码等宽字体
.CodeMirror-sizer {
.CodeMirror-sizer
,.tool-monospace-font-family textarea
,.tool-monospace-font-family input
{
font-family: Consolas, Menlo, monospace, Courier;
}
......@@ -3,23 +3,30 @@ import ViewUI from 'view-design'
import './statics/theme.less'
import router from './tool.router'
import optionBlock from './components/optionBlock'
import inputBlock from './components/inputBlock'
import {plugin as modelPlugin} from './tool/model'
import cache from './tool/cache'
import setting from './tool/setting'
import App from './tool.vue'
import {isUtools,setDisplayMode} from './helper'
import {isUtools,isWeb} from './helper'
import theme from './tool/theme'
import {setCurrentLocale,i18n} from "./i18n";
const run = () => {
// 设置语言环境
setCurrentLocale(setting.locale())
// 设置显示模式
setDisplayMode(setting.displayMode())
theme(setting.displayMode())
Vue.config.productionTip = false
Vue.use(ViewUI)
Vue.use(modelPlugin)
Vue.component('option-block', optionBlock);
Vue.component('input-block', inputBlock);
new Vue({
i18n,
router,
render: h => h(App),
}).$mount('#app')
......@@ -31,17 +38,13 @@ const run = () => {
}
(function () {
if (document.body.clientWidth > 900 || isUtools) {
console.log('调整窗口大小')
if (document.body.clientWidth > 900 || isUtools || isWeb) {
const page = document.getElementById('page')
page.style.width = 'auto'
page.style.height = 'auto'
page.style.minHeight = '550px'
}
if (isUtools) {
window.utools.onPluginReady(() => {
// 重设高度
window.utools.setExpendHeight(582)
run()
})
} else {
......
......@@ -118,10 +118,6 @@ const routes = [
path: '/tool/uuid',
component: r => require(['./views/tool/uuid.vue'], r)
},
{
path: '/tool/jsonToObject',
component: r => require(['./views/tool/jsonToObject.vue'], r)
},
{
path: '/tool/ascii',
component: r => require(['./views/tool/ascii.vue'], r)
......
<template>
<div>
<Menu mode="horizontal" theme="light" :active-name="currentCategory" @on-select="categorySelect"
<Menu class="tool-category-menu-block" mode="horizontal" theme="light" :active-name="currentCategory" @on-select="categorySelect"
style="height: 45px;line-height: 45px;">
<MenuItem :name="cat.name" v-for="(cat) in category" :key="cat.name">
<MenuItem :style="$t('main_css_main_category_item_style')" :name="cat.name" v-for="(cat) in category" :key="cat.name">
<Badge v-if="badgeCategoryIsShow(cat.name)" dot :offset="[15,-10]">
{{ cat.title }}
{{ $t('main_category_'+cat.name) }}
</Badge>
<template v-else>
{{ cat.title }}
</template>
</MenuItem>
<MenuItem style="padding: 0 5px;float: right" name="_new" v-if="!isUtools">
<Icon type="md-expand" :size="24"/>
</MenuItem>
<MenuItem style="padding: 0 5px;float: right" name="_feedback">
<Icon type="md-help-circle" :size="24"/>
</MenuItem>
<MenuItem style="padding: 0 5px;float: right" name="_setting">
<Icon type="md-settings" :size="24"/>
</MenuItem>
<MenuItem style="padding: 0 5px;float: right" name="_about">
<Icon type="logo-github" :size="24"/>
</MenuItem>
<MenuItem style="padding: 0 5px;float: right" name="_history">
<Badge v-if="historyLength>0" dot :offset="[10,-3]">
<Icon type="md-time" :size="24"/>
</Badge>
<template v-else>
<Icon type="md-time" :size="24"/>
{{ $t('main_category_'+cat.name) }}
</template>
</MenuItem>
</Menu>
<RadioGroup :value="currentTool" @on-change="toolSelect" style="margin: 10px 0 10px 20px;line-height: 30px;">
<RadioGroup class="tool-select-block" :value="currentTool" @on-change="toolSelect" style="margin: 10px 0 10px 20px;line-height: 30px;">
<Radio :label="tool.name" v-for="(tool) in tools" :key="tool.name">
<Badge v-if="badgeToolIsShow(tool.name)" dot :offset="[5,-5]">
{{ tool.title }}
{{ $t('main_tool_'+tool.name) }}
</Badge>
<template v-else>
{{ tool.title }}
{{ $t('main_tool_'+tool.name) }}
</template>
</Radio>
</RadioGroup>
<div>
<router-view v-if="isRouterAlive" :key="$route.path + $route.query.t"/>
<router-view ref="routerView" v-if="isRouterAlive" :key="$route.path + $route.query.t"/>
</div>
<Drawer :title="currentToolTitle+' - 历史记录'" v-model="historyShow" :width="100">
<Table ref="historyTable" border :columns="historyColumns" :data="historyData" :height="historyTableHeight">
<template slot-scope="{ row }" slot="_value">
<div>{{ historyValue(row.value) }}}</div>
</template>
<template slot-scope="{ index }" slot="_op">
<Button type="primary" size="small" @click="historyView(index)">查看</Button>
<Button type="primary" style="margin-left: 5px" @click="historyLoad(index)" size="small">加载</Button>
</template>
</Table>
<div class="drawer-footer">
<Button type="primary" @click="historyClear">清空历史记录</Button>
</div>
</Drawer>
<Drawer title="设置" v-model="settingShow" :width="400">
<setting-block v-if="settingShow"></setting-block>
</Drawer>
<bottom-block/>
</div>
</template>
<script>
import config from './tool/config'
import {dispatchCategoryClickEvent} from './tool/event'
import {dispatchWindowResize, I18N_CHANGE} from './tool/event'
import instance from './tool/instance'
import BottomBlock from './bottom'
import settingBlock from "./views/setting/block"
import BottomBlock from './components/bottom'
import model from './tool/model'
import historyFactory, {setLoadHistoryIndex} from './tool/history'
import {isUtools, openUrl} from './helper'
import {isUtools} from './helper'
export default {
components: {
"setting-block": settingBlock,
"bottom-block": BottomBlock
},
data() {
......@@ -87,41 +47,11 @@ export default {
category: config.category,
currentCategory: '',
currentTool: '',
historyData: [],
settingShow: false,
historyShow: false,
historyColumns: [
{
title: '操作时间',
key: 'time',
width: 180
},
{
title: '数据',
slot: '_value',
ellipsis: true,
},
{
title: '操作',
slot: '_op',
width: 150
}
],
}
},
computed: {
tools() {
return config.getToolByCategory(this.currentCategory)
},
historyLength() {
return historyFactory(this.currentTool).length()
},
historyTableHeight() {
// 设置表格高度
return window.innerHeight - 140
},
currentToolTitle() {
return config.getToolTitle(this.currentTool)
}
},
watch: {
......@@ -133,6 +63,7 @@ export default {
created() {
if (this.isUtools) {
window.utools.onPluginEnter(({code, payload, type}) => {
window.utools.showMainWindow()
let tool = "";
let feature = "";
if (code.indexOf('ctool-') !== -1) {
......@@ -145,9 +76,8 @@ export default {
}
// 写入正则匹配数据到固定数据数据
if (type === "regex" && payload) {
if (["over","regex"].includes(type) && payload) {
model.setFixeInputData(payload)
}
if (feature) {
// 设置工具内功能
......@@ -175,6 +105,10 @@ export default {
},
mounted() {
instance.set(this)
window.addEventListener(I18N_CHANGE, ()=>{
this.$forceUpdate()
this.$refs.routerView.$forceUpdate()
});
},
methods: {
reload() {
......@@ -182,72 +116,13 @@ export default {
this.$nextTick(() => (this.isRouterAlive = true))
},
categorySelect(name) {
switch (name) {
case '_feedback':
openUrl('https://github.com/baiy/Ctool/issues')
break
case '_about':
openUrl('https://github.com/baiy/Ctool')
break
case '_setting':
this.settingShow = true;
break
case '_new':
openUrl(window.location.href)
break
case '_history':
this.history()
break
default:
this.currentCategory = name
model.setCategoryHistory(name)
this.currentTool = model.getToolHistory(this.currentCategory)
this.$nextTick(()=>{
dispatchCategoryClickEvent(name)
})
break
}
},
history() {
let history = historyFactory(this.currentTool)
if (history.length() < 1) {
return this.$Message.error('暂无历史记录')
}
this.historyData = history.all()
this.historyShow = true
},
historyValue(value) {
return JSON.stringify(value)
},
historyView(index) {
this.$Modal.info({
render: (h) => {
return h('Input', {
props: {
type: "textarea",
rows: 10,
value: JSON.stringify(historyFactory(this.currentTool).get(index), null, "\t"),
}
})
},
width: 700,
okText: "关闭"
this.currentCategory = name
model.setCategoryHistory(name)
this.currentTool = model.getToolHistory(this.currentCategory)
this.$nextTick(()=>{
dispatchWindowResize()
})
},
historyClear() {
historyFactory(this.currentTool).clear()
this.historyShow = false;
},
historyLoad(index) {
setLoadHistoryIndex(index)
this.historyShow = false;
this.$router.push({
path: this.$router.currentRoute.fullPath,
query: {
t: Date.now(),
},
});
},
toolSelect(name) {
model.setToolHistory(this.currentCategory, name)
this.currentTool = name
......@@ -261,15 +136,3 @@ export default {
},
}
</script>
<style scoped>
.drawer-footer {
width: 100%;
position: absolute;
bottom: 0;
left: 0;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
background: #fff;
}
</style>
\ No newline at end of file
const path = require('path');
const _ = require('lodash');
const fs = require('fs');
const i18nBuild = require('../i18n/build')
// 运行平台适配
let platform = process.env.hasOwnProperty('npm_config_adapter') ? process.env.npm_config_adapter : "";
platform = ['chrome', 'utools', 'edge', 'firefox','web'].includes(platform) ? platform : "web"
platform = ['chrome', 'utools', 'edge', 'firefox', 'web'].includes(platform) ? platform : "web"
const IS_CHROME = "chrome" === platform
const IS_EDGE = "edge" === platform
......@@ -31,10 +32,54 @@ const removeFile = (filePath) => {
fs.existsSync(filePath) && fs.unlinkSync(filePath)
}
// 删除目录
const removeDir = function (directoryPath) {
if (fs.existsSync(directoryPath)) {
fs.readdirSync(directoryPath).forEach((file) => {
const curPath = path.join(directoryPath, file);
if (fs.lstatSync(curPath).isDirectory()) {
removeDir(curPath);
} else {
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(directoryPath);
}
};
const chromiumAndFirefoxI18nBuild = ()=>{
// 生成语言包
const locales = i18nBuild.getLocales().detail
const localeDir = path.join(__dirname, '../../public/_locales/')
fs.mkdirSync(localeDir);
Object.keys(locales).forEach((_locale) => {
fs.mkdirSync(path.join(localeDir, _locale));
let messages = {}
Object.keys(locales[_locale]).forEach((key) => {
let message = {
message: locales[_locale][key]['message'].replace(new RegExp("{.+?}", 'g'), (item) => {
return `$${item.replace("{", "").replace("}", "").toUpperCase()}$`;
})
}
if ("placeholders" in locales[_locale][key]) {
message.placeholders = {}
let index = 1;
locales[_locale][key]['placeholders'].forEach((placeholder) => {
message.placeholders[placeholder] = {content: "$" + (index++)}
})
}
messages[key] = message
})
fs.writeFileSync(path.join(localeDir, `${_locale}/messages.json`), JSON.stringify(messages, null, 4));
})
}
const chromeConfigWrite = {
remove(){},
write(){
if (!IS_CHROME){
remove() {
},
write() {
if (!IS_CHROME) {
return;
}
fs.writeFileSync(
......@@ -45,9 +90,10 @@ const chromeConfigWrite = {
}
const edgeConfigWrite = {
remove(){},
write(){
if (!IS_EDGE){
remove() {
},
write() {
if (!IS_EDGE) {
return;
}
fs.writeFileSync(
......@@ -58,28 +104,34 @@ const edgeConfigWrite = {
}
const chromiumConfigWrite = {
remove(){
remove() {
removeFile(path.join(__dirname, '../../public/manifest.json'));
removeFile(path.join(__dirname, '../../public/background.js'));
// 移除语言包目录
removeDir(path.join(__dirname, '../../public/_locales/'))
},
write(){
if (!IS_CHROMIUM){
write() {
if (!IS_CHROMIUM) {
return;
}
fs.copyFileSync(
path.join(__dirname, "../adapter/chromium/background.js"),
path.join(__dirname, '../../public/background.js')
);
// 生成语言包
chromiumAndFirefoxI18nBuild()
}
}
const firefoxConfigWrite ={
remove(){
const firefoxConfigWrite = {
remove() {
removeFile(path.join(__dirname, '../../public/manifest.json'));
removeFile(path.join(__dirname, '../../public/background.js'));
// 移除语言包目录
removeDir(path.join(__dirname, '../../public/_locales/'))
},
write(){
if (!IS_FIREFOX){
write() {
if (!IS_FIREFOX) {
return;
}
fs.copyFileSync(
......@@ -90,17 +142,18 @@ const firefoxConfigWrite ={
path.join(__dirname, '../../public/manifest.json'),
fs.readFileSync(path.join(__dirname, "../adapter/firefox/manifest.json")).toString().replace(/##version##/g, process.env.npm_package_version)
);
// 生成语言包
chromiumAndFirefoxI18nBuild()
}
}
const utoolsConfigWrite = {
remove(){
remove() {
removeFile(path.join(__dirname, '../../public/plugin.json'));
},
write(){
if (!IS_UTOOLS){
write() {
if (!IS_UTOOLS) {
return;
}
let pluginPath = path.join(__dirname, '../../public/plugin.json');
......@@ -110,11 +163,12 @@ const utoolsConfigWrite = {
for (let tool of tools) {
// 初始化数据
let code = "ctool-" + tool.name;
let toolTitle = i18nBuild.translate(`main_tool_${tool.name}`)
let toolFeatures = featureConfig.hasOwnProperty(tool.name) ? featureConfig[tool.name] : []
if (!utoolsToolFeature.hasOwnProperty(code)) {
utoolsToolFeature[code] = {
"code": code,
"explain": tool.title,
"explain": toolTitle,
"cmds": []
}
if (toolFeatures.length > 0) {
......@@ -122,7 +176,7 @@ const utoolsConfigWrite = {
let toolFeatureCode = code + '-' + toolFeature['name']
utoolsToolFeature[toolFeatureCode] = {
"code": toolFeatureCode,
"explain": tool.title + ' - ' + toolFeature['title'],
"explain": toolTitle + ' - ' + toolFeature['title'],
"cmds": []
}
}
......@@ -132,7 +186,7 @@ const utoolsConfigWrite = {
// 关键字
let keyword = utoolsConfig['keyword'].hasOwnProperty(tool.name) ? utoolsConfig['keyword'][tool.name] : []
utoolsToolFeature[code].cmds.push(
...Array.from(new Set([tool.name, tool.title, "ctool-" + tool.name, ...keyword]))
...Array.from(new Set([tool.name, toolTitle, "ctool-" + tool.name, ...keyword]))
)
// cmds手动配置
......@@ -144,13 +198,13 @@ const utoolsConfigWrite = {
for (let _cmd of cmds) {
let cmd = _.cloneDeep(_cmd);
if (!cmd.hasOwnProperty('feature')) {
cmd['label'] = tool.title
cmd['label'] = toolTitle
utoolsToolFeature[code].cmds.push(cmd)
continue;
}
let toolFeatureCode = code + '-' + cmd.feature
if (utoolsToolFeature.hasOwnProperty(toolFeatureCode)) {
cmd['label'] = tool.title + ' - ' + getToolFeatureTitle(cmd.feature, toolFeatures)
cmd['label'] = toolTitle + ' - ' + getToolFeatureTitle(cmd.feature, toolFeatures)
delete cmd.feature
utoolsToolFeature[toolFeatureCode].cmds.push(cmd)
}
......@@ -195,5 +249,7 @@ module.exports = {
edgeConfigWrite.write();
firefoxConfigWrite.write();
utoolsConfigWrite.write();
// 生成运行时语言包
i18nBuild.generate()
}
}
// 定义分类点击事件
export const CATEGORY_CLICK_EVENT_NAME = "ctoolCategoryClick"
export const dispatchCategoryClickEvent = (name) => {
const event = new CustomEvent(CATEGORY_CLICK_EVENT_NAME, {detail: {name}})
window.dispatchEvent(event);
// 窗口大小调整事件
export const WINDOW_RESIZE = "ctoolWindowResize"
// 语言地区变化事件
export const I18N_CHANGE = "ctoolI18nChange"
export const dispatchWindowResize = () => {
window.dispatchEvent(new CustomEvent(WINDOW_RESIZE));
}
export const dispatchI18nChange = () => {
window.dispatchEvent(new CustomEvent(I18N_CHANGE));
}
// 原生窗口调整事件
window.addEventListener("resize", ()=>{
dispatchWindowResize()
});
import crypto from 'crypto-js'
import moment from 'moment'
import cache from './cache'
import { TOOL_DATA_EXPIRY } from './config'
import {TOOL_DATA_EXPIRY} from './config'
import _ from "lodash";
let loadHistoryIndex = -1
let forceLoadHistory = false
function queueDataFactory (value) {
function queueDataFactory(value) {
return {
'time': moment().format('YYYY-MM-DD HH:mm:ss'),
'hash': crypto.MD5(JSON.stringify(value)).toString(),
......@@ -18,18 +20,23 @@ class queue {
name = ''
max = 10
constructor (name, max = 50) {
constructor(name, max = 50) {
this.name = name
this.max = max
// 初始化数据
this.data = cache.get(this.getCacheName(), [])
}
getCacheName () {
getCacheName() {
return 'tool_data_history_' + this.name
}
push (value) {
push(value) {
// 过滤超大数据
if (JSON.stringify(value).length > 200 * 1024){
console.log("Data Too Big")
return;
}
let item = queueDataFactory(value)
// 删除已有
......@@ -49,23 +56,23 @@ class queue {
cache.set(this.getCacheName(), this.data, TOOL_DATA_EXPIRY)
}
length () {
length() {
return this.data.length
}
all () {
all() {
return this.data
}
clear(){
clear() {
cache.remove(this.getCacheName())
}
get (index) {
return this.data.hasOwnProperty(index) ? this.data[index].value : {}
get(index) {
return _.cloneDeep(this.data.hasOwnProperty(index) ? this.data[index].value : {})
}
current () {
current() {
if (loadHistoryIndex < 0) {
return this.get(0)
}
......@@ -75,10 +82,22 @@ class queue {
}
}
export default (name) => {
const history = (name) => {
return new queue(name)
}
export const setLoadHistoryIndex = (index) => {
export const setForceLoadHistoryIndex = (index) => {
forceLoadHistory = true
loadHistoryIndex = index
}
\ No newline at end of file
}
export const getForceLoadHistory = (name) => {
if (forceLoadHistory) {
forceLoadHistory = false
let data = history(name).current()
return _.isEmpty(data) ? null : data
}
return null
}
export default history
......@@ -2,7 +2,7 @@ import config from './config'
import clipboard from './clipboard'
import setting from './setting'
import cache from './cache'
import history from './history.js'
import history,{getForceLoadHistory} from './history.js'
import _ from "lodash";
let fixeInputData;
......@@ -52,12 +52,12 @@ const debounceSaveToolDataMethod = _.debounce(function () {
}, 1000)
const appendData = async function (check = "") {
const appendData = async function (check = "",all) {
const result = (data = "") => {
if (data) {
if (
!check
|| (_.isFunction(check) && check(data)) // 函数校验
|| (_.isFunction(check) && check(data,all)) // 函数校验
) {
return data
}
......@@ -89,6 +89,14 @@ export const plugin = {
install: function (Vue) {
Vue.prototype.$initToolData = function (input = "", inputCheck = "", field = "current", isLoadHistory = true) {
let current = _.cloneDeep(this[field])
//强制使用历史数据
let forceHistory = getForceLoadHistory(model.getCurrentTool())
if (forceHistory){
Object.assign(current, forceHistory)
this[field] = current
return;
}
let inputHistory = ""
let inputDefault = ""
let inputAppend = ""
......@@ -99,11 +107,11 @@ export const plugin = {
// 历史数据
if (isLoadHistory) {
let history = this.$getToolData()
Object.assign(current, history)
if (input && (input in history)) {
inputHistory = history[input]
delete history[input]
}
Object.assign(current, this.$getToolData())
}
if (!input) {
......@@ -112,13 +120,13 @@ export const plugin = {
}
// 追加剪贴板等数据
appendData(inputCheck).then((append) => {
appendData(inputCheck,current).then((append) => {
inputAppend = append
this[field] = Object.assign(
current,
{
// 历史数据 > 追加数据 > 默认数据
[input]: inputHistory ? inputHistory : (inputAppend ? inputAppend : inputDefault)
// 追加数据 > 历史数据 > 默认数据
[input]: inputAppend ? inputAppend : (inputHistory ? inputHistory : inputDefault)
}
)
})
......@@ -134,7 +142,12 @@ export const plugin = {
debounceSaveToolDataMethod()
}
Vue.prototype.$clipboardCopy = function (data, force = false) {
if ((setting.autoSaveCopy() || force) && data) {
if ((setting.autoSaveCopy() || force)) {
this.$copy(data)
}
}
Vue.prototype.$copy = function (data) {
if (data) {
clipboard.copy(data, () => {
this.$Message.success(this.$t('main_ui_copy_text_ok').toString())
})
......
export default (mode) => {
mode = ['light', 'dark', 'auto'].includes(mode) ? mode : 'light'
console.log(`set display mode:${mode}`)
document.getElementsByTagName('html')[0].setAttribute('theme-mode', mode);
}
......@@ -34,9 +34,11 @@
</template>
<script>
import {isChromium, isFirefox, isUtools, openUrl, setDisplayMode} from '../../helper'
import {isChromium, isFirefox, isUtools, openUrl} from '../../helper'
import theme from '../../tool/theme'
import {LOCALE_LISTS, setCurrentLocale} from '../../i18n'
import setting from '../../tool/setting'
import {dispatchI18nChange} from '../../tool/event'
import common from "./common"
export default {
components: {
......@@ -59,10 +61,11 @@ export default {
},
watch: {
display_mode(value) {
setDisplayMode(value)
theme(value)
},
locale(value) {
setCurrentLocale(value)
dispatchI18nChange()
}
},
created() {
......
......@@ -33,19 +33,19 @@
</div>
</Card>
<heightResize :reduce="45" :append="['.page-option-output-block']" @resize="resize">
<input-block :text="'ARM64'+endianPlaceholder" @on-default-right-bottom-click="()=>copy(outputArm64)">
<input-block :text="'ARM64'+endianPlaceholder" @on-default-right-bottom-click="()=>$copy(outputArm64)">
<autoHeightTextarea :value="outputArm64" :height="outputHeight" :placeholder="'ARM64'+endianPlaceholder"/>
</input-block>
<input-block :text="'ARM'+endianPlaceholder" @on-default-right-bottom-click="()=>copy(outputArm)">
<input-block :text="'ARM'+endianPlaceholder" @on-default-right-bottom-click="()=>$copy(outputArm)">
<autoHeightTextarea style="margin-top: 5px" :value="outputArm" :height="outputHeight" :placeholder="'ARM'+endianPlaceholder"/>
</input-block>
<input-block :text="'ARM Big Endian'" @on-default-right-bottom-click="()=>copy(outputArmBigEndian)" v-if="!isArmToHex">
<input-block :text="'ARM Big Endian'" @on-default-right-bottom-click="()=>$copy(outputArmBigEndian)" v-if="!isArmToHex">
<autoHeightTextarea style="margin-top: 5px" :value="outputArmBigEndian" :height="outputHeight" :placeholder="'ARM Big Endian'"/>
</input-block>
<input-block :text="'THUMB'+endianPlaceholder" @on-default-right-bottom-click="()=>copy(outputThumb)">
<input-block :text="'THUMB'+endianPlaceholder" @on-default-right-bottom-click="()=>$copy(outputThumb)">
<autoHeightTextarea style="margin-top: 5px" :value="outputThumb" :height="outputHeight" :placeholder="'THUMB'+endianPlaceholder"/>
</input-block>
<input-block :text="'THUMB Big Endian'" @on-default-right-bottom-click="()=>copy(outputThumbBigEndian)" v-if="!isArmToHex">
<input-block :text="'THUMB Big Endian'" @on-default-right-bottom-click="()=>$copy(outputThumbBigEndian)" v-if="!isArmToHex">
<autoHeightTextarea style="margin-top: 5px" :value="outputThumbBigEndian" :height="outputHeight" :placeholder="'THUMB Big Endian'"/>
</input-block>
</heightResize>
......@@ -102,11 +102,6 @@ export default {
}
},
methods: {
copy(data) {
if (data) {
this.$clipboardCopy(data)
}
},
resize(height) {
this.pageOutputHeight = height;
},
......
......@@ -14,17 +14,17 @@
</Col>
<Col span="16">
<input-block top="5px" :text="$t('binary_true_form')"
@on-default-right-bottom-click="()=>copy(result('trueForm'))">
@on-default-right-bottom-click="()=>$copy(result('trueForm'))">
<autoHeightTextarea :value="result('trueForm')" :height="outputHeight"
:placeholder="$t('binary_true_form')" style="margin-bottom: 10px"/>
</input-block>
<input-block top="5px" :text="$t('binary_inverse')"
@on-default-right-bottom-click="()=>copy(result('inverse'))">
@on-default-right-bottom-click="()=>$copy(result('inverse'))">
<autoHeightTextarea :value="result('inverse')" :height="outputHeight"
:placeholder="$t('binary_inverse')" style="margin-bottom: 10px"/>
</input-block>
<input-block top="5px" :text="$t('binary_complement')"
@on-default-right-bottom-click="()=>copy(result('complement'))">
@on-default-right-bottom-click="()=>$copy(result('complement'))">
<autoHeightTextarea :value="result('complement')" :height="outputHeight"
:placeholder="$t('binary_complement')"/>
</input-block>
......@@ -48,11 +48,6 @@ export default {
})
},
methods: {
copy(data) {
if (data) {
this.$clipboardCopy(data)
}
},
resize(height) {
this.inputHeight = height
this.outputHeight = Math.ceil((height - 20) / 3)
......
<template>
<div class="tool-disable-mask">
<div>
<div style="line-height: 24px;word-break:break-all;background-color: #fff;padding: 5px 10px;margin: 0 10px">
<slot></slot>
</div>
<div style="text-align: center;margin-top: 10px" v-if="!disableClose">
<Icon type="md-close-circle" style="cursor: pointer;" size="30" color="#FFF" @click="close" />
</div>
</div>
</div>
</template>
<script>
export default {
props:{
disableClose: {
type: Boolean,
default: false
},
},
methods:{
close(){
this.$emit('close')
}
}
};
</script>
<style scoped>
.tool-disable-mask{
position: absolute;
top: 0;
left: 0;
z-index: 8;
width: 100%;
height: 100%;
background-color: rgba(55, 55, 55, 0.2);
display: flex;
display: -webkit-flex;
align-items: center;
justify-content: center;
}
</style>
......@@ -4,7 +4,7 @@
</div>
</template>
<script>
import {CATEGORY_CLICK_EVENT_NAME} from '../../../tool/event'
import {WINDOW_RESIZE} from '../../../tool/event'
function getAbsoluteHeight(select) {
let el = document.querySelector(select)
if (el === null) {
......@@ -72,12 +72,10 @@ export default {
}
},
destroyed() {
window.removeEventListener("resize", this.reportWindowSize);
window.removeEventListener(CATEGORY_CLICK_EVENT_NAME, this.reportWindowSize);
window.removeEventListener(WINDOW_RESIZE, this.reportWindowSize);
},
mounted() {
window.addEventListener("resize", this.reportWindowSize);
window.addEventListener(CATEGORY_CLICK_EVENT_NAME, this.reportWindowSize);
window.addEventListener(WINDOW_RESIZE, this.reportWindowSize);
this.resize();
}
};
......
<template>
<div>
<div style="display: inline">
<slot></slot>
</div>
</template>
......
<template>
<div>
<Select @on-change="select" size="small" placeholder="Common" style="width:100px">
<Option v-for="(v,k) in expression" :value="v.regex" :key="k">{{ v.name }}</Option>
</Select>
<Button type="primary" style="margin-left: 5px" size="small" @click="referenceShow=true">Reference</Button>
<Drawer title="Reference" v-model="referenceShow" :width="100">
<Table :columns="referenceColumns" :data="reference">
<template slot-scope="{ row }" slot="_text">
<div v-html="row.text" style="padding: 10px 0"></div>
</template>
</Table>
</Drawer>
</div>
</template>
<script>
export default {
methods: {
select(regex) {
this.$emit('on-select', regex);
}
},
data() {
return {
referenceShow: false,
/* eslint-disable */
expression: [
{
regex: '(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|622((12[6-9]|1[3-9][0-9])|([2-8][0-9][0-9])|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10}|64[4-9][0-9]{13}|65[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})*',
name: "All major credit cards regex"
},
{regex: '[a-zA-Z0-9]*', name: "Alpha-numeric characters"},
{regex: '[a-zA-Z0-9 ]*', name: "Alpha-numeric characters with spaces"},
{regex: '[a-zA-Z]*', name: "Alphabetic characters"},
{regex: '(3[47][0-9]{13})*', name: "Amex credit card regex"},
{
regex: '((0[289][0-9]{2})|([1345689][0-9]{3})|(2[0-8][0-9]{2})|(290[0-9])|(291[0-4])|(7[0-4][0-9]{2})|(7[8-9][0-9]{2}))*',
name: "Australian Postal Codes"
},
{regex: '([ABCEGHJKLMNPRSTVXY][0-9][A-Z] [0-9][A-Z][0-9])*', name: "Canadian Postal Codes"},
{regex: '(?:AB|BC|MB|N[BLTSU]|ON|PE|QC|SK|YT)*', name: "Canadian Province Abbreviations"},
{
regex: '(0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)?[0-9]{2}',
name: "Date (MM/DD/YYYY)"
},
{
regex: '(19|20)?[0-9]{2}[- /.](0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])',
name: "Date (YYYY/MM/DD)"
},
{regex: '(3(?:0[0-5]|[68][0-9])[0-9]{11})*', name: "Diner's Club credit card regex"},
{
regex: '((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))*',
name: "IP address regex"
},
{regex: '([a-z])+', name: "Lowercase letters"},
{regex: '([A-Z])+', name: "Uppercase letters"},
{regex: '(5[1-5][0-9]{14})*', name: "MasterCard credit card numbers"},
{regex: '((([0-9]{1})*[- .(]*([0-9]{3})[- .)]*[0-9]{3}[- .]*[0-9]{4})+)*', name: "Phone number regex"},
{regex: '([0-9]{3}[-]*[0-9]{2}[-]*[0-9]{4})*', name: "SSN regex"},
{regex: '([A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2})*', name: "UK Postal Codes regex"},
{
regex: '(?:A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])*',
name: "US States regex"
},
{regex: '([0-9]{5}(?:-[0-9]{4})?)*', name: "US ZIP Codes regex"},
{regex: '(4[0-9]{12}(?:[0-9]{3})?)*', name: "Visa credit card numbers"},
{
regex: '(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})',
name: "All major credit cards regex"
},
{regex: '[a-zA-Z0-9]+', name: "alpha-numeric characters"},
{regex: '[a-zA-Z]+', name: "Alphabetic characters"},
{regex: '[ABCEGHJKLMNPRSTVXY][0-9][A-Z] [0-9][A-Z][0-9]', name: "Canadian Postal Codes"},
{regex: '[0-9]+', name: "digits"},
{regex: '[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}', name: "email regex"},
{
regex: '(([0-9]{1})*[- .(]*([0-9]{3})[- .)]*[0-9]{3}[- .]*[0-9]{4})+',
name: "phone number regex"
},
{
regex: '((http|https|ftp)://)?([[a-zA-Z0-9]\-\.])+(\.)([[a-zA-Z0-9]]){2,4}([[a-zA-Z0-9]/+=%&_\.~?\-]*)',
name: "URL regex"
},
{regex: '[0-9]{5}(?:-[0-9]{4})?', name: "US ZIP Codes regex"}
],
/* eslint-enable */
referenceColumns: [
{
title: 'Character',
key: 'name',
width: 120
},
{
title: 'What does it do?',
slot: '_text'
},
],
reference: [
{
"name": "\\",
"text": "Used to indicate that the next character should NOT be interpreted literally. For example, the character 'w' by itself will be interpreted as 'match the character w', but using '\\w' signifies 'match an alpha-numeric character including underscore'. Used to indicate that a metacharacter is to be interpreted literally. For example, the '.' metacharacter means 'match any single character but a new line', but if we would rather match a dot character instead, we would use '\\.'."
},
{
"name": "^",
"text": "Matches the beginning of the input. If in multiline mode, it also matches after a line break character, hence every new line. When used in a set pattern ([^abc]), it negates the set; match anything not enclosed in the brackets"
},
{
"name": "$",
"text": "Matches the end of the input. If in multiline mode, it also matches before a line break character, hence every end of line."
},
{
"name": "*",
"text": "Matches the preceding character 0 or more times."
},
{
"name": "+",
"text": "Matches the preceding character 1 or more times."
},
{
"name": "?",
"text": "Matches the preceding character 0 or 1 time. When used after the quantifiers *, +, ? or {}, makes the quantifier non-greedy; it will match the minimum number of times as opposed to matching the maximum number of times."
},
{
"name": ".",
"text": "Matches any single character except the newline character."
},
{
"name": "(x)",
"text": "Matches 'x' and remembers the match. Also known as capturing parenthesis."
},
{
"name": "(?:x)",
"text": "Matches 'x' but does NOT remember the match. Also known as NON-capturing parenthesis."
},
{
"name": "x(?=y)",
"text": "Matches 'x' only if 'x' is followed by 'y'. Also known as a lookahead."
},
{
"name": "x(?!y)",
"text": "Matches 'x' only if 'x' is NOT followed by 'y'. Also known as a negative lookahead."
},
{
"name": "x|y",
"text": "Matches 'x' OR 'y'."
},
{
"name": "{n}",
"text": "Matches the preceding character exactly n times."
},
{
"name": "{n,m}",
"text": "Matches the preceding character at least n times and at most m times. n and m can be omitted if zero.."
},
{
"name": "[abc]",
"text": "Matches any of the enclosed characters. Also known as a character set. You can create range of characters using the hyphen character such as A-Z (A to Z). Note that in character sets, special characters (., *, +) do not have any special meaning."
},
{
"name": "[^abc]",
"text": "Matches anything NOT enclosed by the brackets. Also known as a negative character set."
},
{
"name": "[\\b]",
"text": "Matches a backspace."
},
{
"name": "\\b",
"text": "Matches a word boundary. Boundaries are determined when a word character is NOT followed or NOT preceded with another word character."
},
{
"name": "\\B",
"text": "Matches a NON-word boundary. Boundaries are determined when two adjacent characters are word characters OR non-word characters."
},
{
"name": "\\cX",
"text": "Matches a control character. X must be between A to Z inclusive."
},
{
"name": "\\d",
"text": "Matches a digit character. Same as [0-9] or [0123456789]."
},
{
"name": "\\D",
"text": "Matches a NON-digit character. Same as [^0-9] or [^0123456789]."
},
{
"name": "\\f",
"text": "Matches a form feed."
},
{
"name": "\\n",
"text": "Matches a line feed."
},
{
"name": "\\r",
"text": "Matches a carriage return."
},
{
"name": "\\s",
"text": "Matches a single white space character. This includes space, tab, form feed and line feed."
},
{
"name": "\\S",
"text": "Matches anything OTHER than a single white space character. Anything other than space, tab, form feed and line feed."
},
{
"name": "\\t",
"text": "Matches a tab."
},
{
"name": "\\v",
"text": "Matches a vertical tab."
},
{
"name": "\\w",
"text": "Matches any alphanumeric character including underscore. Equivalent to [A-Za-z0-9_]."
},
{
"name": "\\W",
"text": "Matches anything OTHER than an alphanumeric character including underscore. Equivalent to [^A-Za-z0-9_]."
},
{
"name": "\\x",
"text": "A back reference to the substring matched by the x parenthetical expression. x is a positive integer."
},
{
"name": "\\0",
"text": "Matches a NULL character."
},
{
"name": "\\xhh",
"text": "Matches a character with the 2-digits hexadecimal code."
},
{
"name": "\\uhhhh",
"text": "Matches a character with the 4-digits hexadecimal code."
}
]
}
}
}
</script>
<template>
<div>
<Select @on-change="select" size="small" placeholder="常用" style="width:80px">
<Option v-for="(v,k) in expression" :value="v.regex" :key="k">{{v.name}}</Option>
</Select>
<Button type="primary" style="margin-left: 5px" size="small" @click="referenceShow=true">参考</Button>
<Drawer title="参考" v-model="referenceShow" :width="100">
<Table :columns="referenceColumns" :data="reference">
<template slot-scope="{ row }" slot="_text">
<div v-html="row.text" style="padding: 10px 0"></div>
</template>
</Table>
</Drawer>
</div>
</template>
<script>
export default {
methods:{
select(regex){
this.$emit('on-select',regex);
}
},
data(){
return {
referenceShow:false,
expression: [
{regex: "[\\u4e00-\\u9fa5]", name:"中文字符"},
{regex: "[^\\x00-\\xff]", name:"双字节字符(包括汉字在内)"},
{regex: "\\n\\s*\\r", name:"空白行"},
{
regex: "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?",
name:"Email地址"},
{regex: "[a-zA-z]+://[^\\s]*", name:"网址URL"},
{regex: "[1][3,4,5,7,8][0-9]{9}", name:"手机"},
{regex: "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}", name:"IP地址"},
{regex: "\\d{3}-\\d{8}|\\d{4}-\\d{7,8}", name:"国内电话号码"},
{regex: "[1-9][0-9]{4,}", name:"腾讯QQ号"},
{regex: "[1-9]\\d{5}(?!\\d)", name:"中国邮政编码"},
{
regex: "([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8])))",
name:"(年-月-日)格式日期"},
{regex: "[1-9]\\d*", name:"正整数"},
{regex: "-[1-9]\\d*", name:"负整数"},
{regex: "-?[1-9]\\d*", name:"整数"},
{regex: "[1-9]\\d*|0", name:"非负整数(正整数 + 0)"},
{regex: "-[1-9]\\d*|0", name:"非正整数(负整数 + 0)"},
{regex: "[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*", name:"正浮点数"},
{regex: "-[1-9]\\d*\\.\\d*|-0\\.\\d*[1-9]\\d*", name:"负浮点数"},
],
referenceColumns: [
{
title: '字符',
key: 'name',
width: 100
},
{
title: '描述',
slot: '_text'
},
],
reference: [
{
name: "\\",
text: "将下一个字符标记为一个特殊字符、或一个原义字符、或一个向后引用、或一个八进制转义符。例如,“<code>n</code>”匹配字符“<code>n</code>”。“<code>\\n</code>”匹配一个换行符。串行“<code>\\\\</code>”匹配“<code>\\</code>”而“<code>\\(</code>”则匹配“<code>(</code>”。"
},
{
name: "^",
text: "匹配输入字符串的开始位置。如果设置了RegExp对象的Multiline属性,^也匹配“<code>\\n</code>”或“<code>\\r</code>”之后的位置。"
},
{
name: "$",
text: "匹配输入字符串的结束位置。如果设置了RegExp对象的Multiline属性,$也匹配“<code>\\n</code>”或“<code>\\r</code>”之前的位置。"
},
{
name: "*",
text: "匹配前面的子表达式零次或多次。例如,zo*能匹配“<code>z</code>”以及“<code>zoo</code>”。*等价于{0,}。"
},
{
name: "+",
text: "匹配前面的子表达式一次或多次。例如,“<code>zo+</code>”能匹配“<code>zo</code>”以及“<code>zoo</code>”,但不能匹配“<code>z</code>”。+等价于{1,}。"
},
{
name: "?",
text: "匹配前面的子表达式零次或一次。例如,“<code>do(es)?</code>”可以匹配“<code>does</code>”或“<code>does</code>”中的“<code>do</code>”。?等价于{0,1}。"
},
{
name: "{n}",
text: "n是一个非负整数。匹配确定的n次。例如,“<code>o{2}</code>”不能匹配“<code>Bob</code>”中的“<code>o</code>”,但是能匹配“<code>food</code>”中的两个o。"
},
{
name: "{n,}",
text: "n是一个非负整数。至少匹配n次。例如,“<code>o{2,}</code>”不能匹配“<code>Bob</code>”中的“<code>o</code>”,但能匹配“<code>foooood</code>”中的所有o。“<code>o{1,}</code>”等价于“<code>o+</code>”。“<code>o{0,}</code>”则等价于“<code>o*</code>”。"
},
{
name: "{n,m}",
text: "m和n均为非负整数,其中n&lt;=m。最少匹配n次且最多匹配m次。例如,“<code>o{1,3}</code>”将匹配“<code>fooooood</code>”中的前三个o。“<code>o{0,1}</code>”等价于“<code>o?</code>”。请注意在逗号和两个数之间不能有空格。"
},
{
name: "?",
text: "当该字符紧跟在任何一个其他限制符(*,+,?,{n},{n,},{n,m})后面时,匹配模式是非贪婪的。非贪婪模式尽可能少的匹配所搜索的字符串,而默认的贪婪模式则尽可能多的匹配所搜索的字符串。例如,对于字符串“<code>oooo</code>”,“<code>o+?</code>”将匹配单个“<code>o</code>”,而“<code>o+</code>”将匹配所有“<code>o</code>”。"
},
{
name: ".",
text: "匹配除“<code>\\</code><code>n</code>”之外的任何单个字符。要匹配包括“<code>\\</code><code>n</code>”在内的任何字符,请使用像“<code>(.|\\n)</code>”的模式。"
},
{
name: "(pattern)",
text: "匹配pattern并获取这一匹配。所获取的匹配可以从产生的Matches集合得到,在VBScript中使用SubMatches集合,在JScript中则使用$0…$9属性。要匹配圆括号字符,请使用“<code>\\(</code>”或“<code>\\)</code>”。"
},
{
name: "(?:pattern)",
text: "匹配pattern但不获取匹配结果,也就是说这是一个非获取匹配,不进行存储供以后使用。这在使用或字符“<code>(|)</code>”来组合一个模式的各个部分是很有用。例如“<code>industr(?:y|ies)</code>”就是一个比“<code>industry|industries</code>”更简略的表达式。"
},
{
name: "(?=pattern)",
text: "正向肯定预查,在任何匹配pattern的字符串开始处匹配查找字符串。这是一个非获取匹配,也就是说,该匹配不需要获取供以后使用。例如,“<code>Windows(?=95|98|NT|2000)</code>”能匹配“<code>Windows2000</code>”中的“<code>Windows</code>”,但不能匹配“<code>Windows3.1</code>”中的“<code>Windows</code>”。预查不消耗字符,也就是说,在一个匹配发生后,在最后一次匹配之后立即开始下一次匹配的搜索,而不是从包含预查的字符之后开始。"
},
{
name: "(?!pattern)",
text: "正向否定预查,在任何不匹配pattern的字符串开始处匹配查找字符串。这是一个非获取匹配,也就是说,该匹配不需要获取供以后使用。例如“<code>Windows(?!95|98|NT|2000)</code>”能匹配“<code>Windows3.1</code>”中的“<code>Windows</code>”,但不能匹配“<code>Windows2000</code>”中的“<code>Windows</code>”。预查不消耗字符,也就是说,在一个匹配发生后,在最后一次匹配之后立即开始下一次匹配的搜索,而不是从包含预查的字符之后开始"
},
{
name: "(?&lt;=pattern)",
text: "反向肯定预查,与正向肯定预查类拟,只是方向相反。例如,“<code>(?&lt;=95|98|NT|2000)Windows</code>”能匹配“<code>2000Windows</code>”中的“<code>Windows</code>”,但不能匹配“<code>3.1Windows</code>”中的“<code>Windows</code>”。"
},
{
name: "(?&lt;!pattern)",
text: "反向否定预查,与正向否定预查类拟,只是方向相反。例如“<code>(?&lt;!95|98|NT|2000)Windows</code>”能匹配“<code>3.1Windows</code>”中的“<code>Windows</code>”,但不能匹配“<code>2000Windows</code>”中的“<code>Windows</code>”。"
},
{
name: "x|y",
text: "匹配x或y。例如,“<code>z|food</code>”能匹配“<code>z</code>”或“<code>food</code>”。“<code>(z|f)ood</code>”则匹配“<code>zood</code>”或“<code>food</code>”。"
},
{
name: "[xyz]",
text: "字符集合。匹配所包含的任意一个字符。例如,“<code>[abc]</code>”可以匹配“<code>plain</code>”中的“<code>a</code>”。"
},
{
name: "[^xyz]",
text: "负值字符集合。匹配未包含的任意字符。例如,“<code>[^abc]</code>”可以匹配“<code>plain</code>”中的“<code>p</code>”。"
},
{
name: "[a-z]",
text: "字符范围。匹配指定范围内的任意字符。例如,“<code>[a-z]</code>”可以匹配“<code>a</code>”到“<code>z</code>”范围内的任意小写字母字符。"
},
{
name: "[^a-z]",
text: "负值字符范围。匹配任何不在指定范围内的任意字符。例如,“<code>[^a-z]</code>”可以匹配任何不在“<code>a</code>”到“<code>z</code>”范围内的任意字符。"
},
{
name: "\\b",
text: "匹配一个单词边界,也就是指单词和空格间的位置。例如,“<code>er\\b</code>”可以匹配“<code>never</code>”中的“<code>er</code>”,但不能匹配“<code>verb</code>”中的“<code>er</code>”。"
},
{
name: "\\B",
text: "匹配非单词边界。“<code>er\\B</code>”能匹配“<code>verb</code>”中的“<code>er</code>”,但不能匹配“<code>never</code>”中的“<code>er</code>”。"
},
{
name: "\\cx",
text: "匹配由x指明的控制字符。例如,<code>\\cM</code>匹配一个Control-M或回车符。x的值必须为A-Z或a-z之一。否则,将c视为一个原义的“<code>c</code>”字符。"
},
{
name: "\\d",
text: "匹配一个数字字符。等价于[0-9]。"
},
{
name: "\\D",
text: "匹配一个非数字字符。等价于[^0-9]。"
},
{
name: "\\f",
text: "匹配一个换页符。等价于\\x0c和\\cL。"
},
{
name: "\\n",
text: "匹配一个换行符。等价于\\x0a和\\cJ。"
},
{
name: "\\r",
text: "匹配一个回车符。等价于\\x0d和\\cM。"
},
{
name: "\\s",
text: "匹配任何空白字符,包括空格、制表符、换页符等等。等价于[ \\f\\n\\r\\t\\v]。"
},
{
name: "\\S",
text: "匹配任何非空白字符。等价于[^ \\f\\n\\r\\t\\v]。"
},
{
name: "\\t",
text: "匹配一个制表符。等价于\\x09和\\cI。"
},
{
name: "\\v",
text: "匹配一个垂直制表符。等价于\\x0b和\\cK。"
},
{
name: "\\w",
text: "匹配包括下划线的任何单词字符。等价于“<code>[A-Za-z0-9_]</code>”。"
},
{
name: "\\W",
text: "匹配任何非单词字符。等价于“<code>[^A-Za-z0-9_]</code>”。"
},
{
name: "\\xn",
text: "匹配n,其中n为十六进制转义值。十六进制转义值必须为确定的两个数字长。例如,“<code>\\x41</code>”匹配“<code>A</code>”。“<code>\\x041</code>”则等价于“<code>\\x04&amp;1</code>”。正则表达式中可以使用ASCII编码。."
},
{
name: "\\num",
text: "匹配num,其中num是一个正整数。对所获取的匹配的引用。例如,“<code>(.)\\1</code>”匹配两个连续的相同字符。"
},
{
name: "\\n",
text: "标识一个八进制转义值或一个向后引用。如果\\n之前至少n个获取的子表达式,则n为向后引用。否则,如果n为八进制数字(0-7),则n为一个八进制转义值。"
},
{
name: "\\nm",
text: "标识一个八进制转义值或一个向后引用。如果\\nm之前至少有nm个获得子表达式,则nm为向后引用。如果\\nm之前至少有n个获取,则n为一个后跟文字m的向后引用。如果前面的条件都不满足,若n和m均为八进制数字(0-7),则\\nm将匹配八进制转义值nm。"
},
{
name: "\\nml",
text: "如果n为八进制数字(0-3),且m和l均为八进制数字(0-7),则匹配八进制转义值nml。"
},
{
name: "\\un",
text: "匹配n,其中n是一个用四个十六进制数字表示的Unicode字符。例如,\\u00A9匹配版权符号(©)。"
}
]
}
}
}
</script>
<template>
<Upload style="display: inline-block" action="#" :before-upload="handleUpload" :format="format" :showUploadList="false">
<Button shape="circle" icon="md-cloud-upload"/>
<template v-if="!disablePaste">
<pasteClipboardFlie v-if="type==='file'" @on-paste-file="handleUpload"/>
<pasteClipboardFlie v-if="type==='image'" @on-paste-image="handleUpload"/>
</template>
</Upload>
</template>
<script>
import pasteClipboardFlie from './pasteClipboardFlie';
export default {
components: {
pasteClipboardFlie,
},
props: {
disablePaste: {
type: Boolean,
default: false
},
type: {
type: String,
default: "file" // file,image
}
},
computed: {
format() {
if (this.type === "image") {
return ['jpg', 'jpeg', 'png']
}
return [];
}
},
methods: {
handleUpload(file) {
this.$emit('success', file)
}
}
};
</script>
<template>
<div style="padding: 0 70px">
<option-block>
<Input v-model="current.input" placeholder="请输入待转换数字">
<div slot="prepend" style="width: 70px"><strong>转换数字</strong></div>
<Input v-model="current.input" :placeholder="$t('decimalConvert_input_placeholder')">
<div slot="prepend" style="width: 70px"><strong>{{ $t('decimalConvert_input') }}</strong></div>
<Select v-model="current.decimal" slot="append" style="width:100px">
<OptionGroup :label="type.common.name">
<Option v-for="v in type.common.list" :value="v" :key="v">{{ v }} 进制</Option>
<OptionGroup :label="$t('decimalConvert_input_type_common')">
<Option v-for="v in type.common" :value="v" :key="v">{{
$t('decimalConvert_base', [v])
}}
</Option>
</OptionGroup>
<OptionGroup :label="type.other.name">
<Option v-for="v in type.other.list" :value="v" :key="v">{{ v }} 进制</Option>
<OptionGroup :label="$t('decimalConvert_input_type_other')">
<Option v-for="v in type.other" :value="v" :key="v">{{
$t('decimalConvert_base', [v])
}}
</Option>
</OptionGroup>
</Select>
</Input>
</option-block>
<option-block v-for="n in [1,2,3,4,5,6]" :key="n">
<Input v-model="current['resultOutput'+n]" readonly>
<div slot="prepend" style="width: 70px">转换结果{{ n }}</div>
<div slot="prepend" style="width: 70px">{{ $t('decimalConvert_result', [n]) }}</div>
<Select slot="append" v-model="current['resultDecimal'+n]" style="width:100px">
<OptionGroup :label="type.common.name">
<Option v-for="v in type.common.list" :value="v" :key="v">{{ v }} 进制</Option>
<OptionGroup :label="$t('decimalConvert_input_type_common')">
<Option v-for="v in type.common" :value="v" :key="v">{{
$t('decimalConvert_base', [v])
}}
</Option>
</OptionGroup>
<OptionGroup :label="type.other.name">
<Option v-for="v in type.other.list" :value="v" :key="v">{{ v }} 进制</Option>
<OptionGroup :label="$t('decimalConvert_input_type_other')">
<Option v-for="v in type.other" :value="v" :key="v">{{
$t('decimalConvert_base', [v])
}}
</Option>
</OptionGroup>
</Select>
</Input>
</option-block>
<option-block>
<Input v-model="current.alphabet">
<div slot="prepend" style="width: 70px">64位字母表</div>
<Button slot="append" @click="current.alphabet=alphabet" :disabled="current.alphabet===alphabet">恢复默认
<div slot="prepend">{{ $t('decimalConvert_alphabet') }}</div>
<Button slot="append" @click="current.alphabet=alphabet" :disabled="current.alphabet===alphabet">
{{ $t('decimalConvert_reset') }}
</Button>
</Input>
</option-block>
......@@ -41,21 +54,40 @@ import Radix from './library/radix.js'
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@";
export default {
created() {
this.current = Object.assign(this.current, this.$getToolData("input"))
this.$initToolData('input',(input,current)=>{
try {
const radix = new Radix(current.alphabet);
radix.convent(input, current.decimal, 2, true)
} catch (e) {
return false;
}
return true
})
},
watch: {
convert: function (val) {
if (val.alphabet.length !== 64) {
return this.$Message.error("转换字母表必须是64位长度");
for (let n = 1; n <= 6; n++) {
this.current['resultOutput' + n] = this.$t('decimalConvert_alphabet_length_error').toString()
}
return;
}
if (!val.input) {
return;
}
const radix = new Radix(val.alphabet);
let isError = false;
for (let n = 1; n <= 6; n++) {
this.current['resultOutput' + n] = radix.convent(val.input, val.decimal, val['resultDecimal' + n])
try {
this.current['resultOutput' + n] = radix.convent(val.input, val.decimal, val['resultDecimal' + n], true)
} catch (e) {
isError = true
this.current['resultOutput' + n] = e.toString()
}
}
if (!isError){
this.$saveToolData(this.current);
}
this.$saveToolData(this.current);
},
},
computed: {
......@@ -74,17 +106,11 @@ export default {
},
type() {
let type = {
common: {
name: "常用进制",
list: [2, 8, 10, 16]
},
other: {
name: "其他进制",
list: []
}
common: [2, 8, 10, 16],
other: []
}
for (let i = 2; i <= 64; i++) {
type.common.list.includes(i) || type.other.list.push(i);
type.common.includes(i) || type.other.push(i);
}
return type
}
......
<template>
<div id="tool-hash">
<Row :gutter="10">
<Col span="8">
<input-block>
<heightResize>
<autoHeightTextarea v-model="current.input" :placeholder="$t('hash_content')"/>
</heightResize>
<Checkbox slot="extra" v-model="current.isUppercase">{{ $t('hash_uppercase') }}</Checkbox>
</input-block>
<Col span="10">
<div style="position: relative;">
<input-block>
<heightResize>
<autoHeightTextarea v-model="current.input" :placeholder="$t('hash_content')"/>
</heightResize>
<template slot="extra">
<updateFile @success="handleUpload"/>
<Checkbox style="margin-left: 10px" v-model="current.isUppercase">{{
$t('hash_uppercase')
}}
</Checkbox>
</template>
</input-block>
<disableMask v-if="isUploadFile" @close="uploadFile = {}">
{{ this.uploadFile.file.name }}
</disableMask>
</div>
</Col>
<Col span="16">
<Col span="14">
<heightResize @resize="resize">
<input-block :style="`margin-top: ${no >0 ? 5 : 0}px;`" :text="type" v-for="(type,no) in types" :key="type" @on-default-right-bottom-click="()=>copy(type)">
<input-block :style="`margin-top: ${no >0 ? 5 : 0}px;`" :text="type" v-for="(type,no) in types"
:key="type" @on-default-right-bottom-click="()=>$copy(result(type))">
<autoHeightTextarea :value="result(type)" :height="outputHeight" :placeholder="type"/>
</input-block>
</heightResize>
......@@ -23,63 +35,77 @@
import crypto from "crypto-js"
import heightResize from "./components/heightResize";
import autoHeightTextarea from "./components/autoHeightTextarea";
import updateFile from './components/updateFile';
import disableMask from "./components/disableMask.vue";
const sm = require('sm-crypto');
export default {
components: {
updateFile,
heightResize,
autoHeightTextarea
autoHeightTextarea,
disableMask
},
created() {
this.$initToolData('input')
},
computed: {
realInput() {
return this.isUploadFile ? this.uploadFile.data : this.current.input
},
md5() {
let result = crypto.MD5(this.current.input).toString();
let result = crypto.MD5(this.realInput).toString();
return this.current.isUppercase ? result.toUpperCase() : result;
},
sha1() {
let result = crypto.SHA1(this.current.input).toString();
let result = crypto.SHA1(this.realInput).toString();
return this.current.isUppercase ? result.toUpperCase() : result;
},
sha256() {
let result = crypto.SHA256(this.current.input).toString();
let result = crypto.SHA256(this.realInput).toString();
return this.current.isUppercase ? result.toUpperCase() : result;
},
sha512() {
let result = crypto.SHA512(this.current.input).toString();
let result = crypto.SHA512(this.realInput).toString();
return this.current.isUppercase ? result.toUpperCase() : result;
},
sm3() {
let result = sm.sm3(this.current.input);
let result = sm.sm3(this.realInput);
return this.current.isUppercase ? result.toUpperCase() : result;
},
isUploadFile() {
return "file" in this.uploadFile
},
},
watch: {
current: {
handler() {
if (this.current.input){
if (this.current.input) {
this.$saveToolData(this.current);
}
},
deep: true
}
},
methods:{
result(type){
if (!this.current.input) {
methods: {
result(type) {
if (!this.realInput) {
return "";
}
return this[type]
},
copy(type){
if (this[type]){
this.$clipboardCopy(this[type])
resize(height) {
this.outputHeight = (height - 20) / 5
},
handleUpload(file) {
let r = new FileReader()
r.readAsBinaryString(file)
r.onloadend = () => {
let data = crypto.enc.Latin1.parse(r.result);
if (data) {
this.uploadFile = {file, data}
}
}
},
resize(height){
this.outputHeight = (height - 20)/5
}
},
data() {
return {
......@@ -87,8 +113,9 @@ export default {
input: "",
isUppercase: false,
},
uploadFile: {},
types: ['md5', 'sha1', 'sha256', 'sha512', "sm3"],
outputHeight:100
outputHeight: 100
}
},
}
......
......@@ -30,7 +30,7 @@ export default {
this.current.output = convert('utf8', 'hex')(this.current.input);
break;
case "str":
this.current.output = convert('hex', 'utf8')(this.current.input);
this.current.output = convert('hex', 'utf8')(this.current.input.trim().replace(/\s+/g, ""));
break;
default:
return;
......
<template>
<Row :gutter="10">
<Col span="10">
<Card :padding="0">
<p slot="title">JSON内容</p>
<code-editor v-model="current.json" :auto-height="330" language="json"></code-editor>
</Card>
<option-block>
<FormItem>
<Input v-model="current.package">
<div slot="prepend">namespace/package</div>
</Input>
</FormItem>
</option-block>
<option-block>
<FormItem>
<Input v-model="current.class">
<div slot="prepend">class/struct</div>
</Input>
</FormItem>
</option-block>
</Col>
<Col span="14">
<Card :padding="0">
<p slot="title">转换结果</p>
<template slot="extra">
<Button style="margin-right: 5px" size="small" v-for="(item,key) in type" :key="key" type="primary"
@click="handle(item)">{{ item }}
</Button>
</template>
<code-editor v-model="current.output" :auto-height="220" :language="languages[current.type]"></code-editor>
</Card>
</Col>
</Row>
</template>
<script>
import codeEditor from "./components/codeEditor";
import json2Go from './library/json2Go'
import json2CSharp from './library/json2CSharp'
import json2Java from './library/json2Java'
import json2Dart from './library/json2Dart'
export default {
components: {
codeEditor,
},
created() {
this.current = Object.assign(this.current, this.$getToolData())
},
methods: {
handle(type) {
try {
require('jsonlint').parse(this.current.json)
if (!this.type.includes(type)) {
throw new Error("转换类型错误")
}
this.current.type = type;
switch (type) {
case "Go":
this.current.output = json2Go(this.current.json, this.current.class, this.current.package).go
break;
case "Java":
this.current.output = json2Java(JSON.parse(this.current.json), this.current.class, this.current.package)
break;
case "Dart":
this.current.output = json2Dart(JSON.parse(this.current.json), this.current.class)
break;
case "C#":
this.current.output = json2CSharp.convert(JSON.parse(this.current.json), this.current.class, this.current.package)
break;
}
} catch (error) {
this.$Notice.error({
title: '错误提示',
desc: error.message,
})
return
}
this.$saveToolData(this.current)
}
},
data() {
return {
current: {
json: "",
type: "Java",
package: "pag",
class: "RootName",
output: "",
},
type: ["Java", "C#", "Go",'Dart'],
languages: {
"Java": "java",
"Dart": "dart",
"C#": "csharp",
"Go": "go"
},
}
},
}
</script>
......@@ -14,6 +14,8 @@ import "codemirror/mode/css/css.js";
import "codemirror/mode/xml/xml.js";
import "codemirror/mode/sql/sql.js";
import "codemirror/mode/php/php.js";
import "codemirror/mode/ruby/ruby.js";
import "codemirror/mode/python/python.js";
import "codemirror/mode/clike/clike.js";
import "codemirror/mode/go/go.js";
import "codemirror/mode/vue/vue.js";
......@@ -41,8 +43,10 @@ const modes = {
scss: "text/x-scss",
graphql: "graphql",
java: "text/x-java",
ruby: "text/x-ruby",
markdown: "text/x-markdown",
php: "text/x-php",
python: "text/x-python",
sql: "text/x-sql",
yaml: "text/x-yaml",
ts: "application/typescript",
......
<template>
<input-block right="10px" bottom="40px">
<input-block right="10px" bottom="10px">
<code-editor :height="`${height}px`" :placeholder="`Csv ${$t('json_input')}`" v-model="options.input" language="text"/>
<template slot="extra">
<RadioGroup size="small" v-model="options.type" type="button" button-style="solid">
<Radio :label="item.k" v-for="item in types" :key="item.k">
<span>{{ item.n }}</span>
</Radio>
</RadioGroup>
</template>
</input-block>
<template slot="extra">
<Select size="small" v-model="options.keyed_key" v-if="options.type === 'keyed'" style="width: 150px">
<Option v-for="(key,k) in csvKeys" :key="k" :value="k">{{ key }}</Option>
</Select>
</template>
</input-block>
</template>
<script>
import jsonInstance from "../index";
import codeEditor from "../../../components/codeEditor";
import csvToJsonHandler from '../csvToJson';
export default {
props: {
value: {
type: Object,
default: function () {
return {}
}
},
height: {
type: Number,
default: 100
}
},
components: {
codeEditor
},
created() {
this.options = Object.assign(this.options, this.value)
},
computed: {
csvKeys() {
try {
let input = this.options.input.trim();
if (this.options.type === "keyed" && input) {
let json = csvToJsonHandler(this.options.input)
return Object.keys(json[0])
}
} catch {
//
}
return [];
}
},
watch: {
options: {
handler(val) {
let input = val.input.trim();
if (input) {
try {
const option = {
keyed_key: val.keyed_key,
type: val.type
}
// json变化事件
this.$emit('change', jsonInstance.csvToJson(input, option));
this.$emit('input', val);
// 保存数据
this.$emit('saveToolData');
} catch (e) {
this.$emit('change', this.$t('json_error', [e.message]).toString());
}
}
},
deep: true
}
},
data() {
return {
options: {
input: "",
type: "json",
keyed_key: 0
},
types: [
{k: "json", n: this.$t('json_json_type_json')},
{k: "keyed", n: this.$t('json_json_type_keyed')},
{k: "array", n: this.$t('json_json_type_array')},
{k: "column", n: this.$t('json_json_type_column')},
]
}
},
}
</script>
<template>
<input-block right="10px">
<code-editor :height="`${height}px`" :placeholder="`Csv ${$t('json_output')}`" :value="output"/>
<template slot="extra">
<Checkbox v-model="options.quoted">{{ $t('json_add_quote') }}</Checkbox>
<Checkbox v-model="options.header">{{ $t('json_column_name') }}</Checkbox>
</template>
</input-block>
</template>
<script>
import codeEditor from "../../../components/codeEditor";
import jsonInstance from "../index";
export default {
props: {
value: {
type: Object,
default: function () {
return {}
}
},
json: {
type: String,
default: ""
},
height: {
type: Number,
default: 100
}
},
created() {
this.options = Object.assign(this.options, this.value)
},
components: {
codeEditor,
},
computed: {
output() {
const json = this.json.trim();
if (!json) {
return "";
}
try {
let result = jsonInstance.jsonToCsv(JSON.parse(json), {quoted: this.options.quoted,header:this.options.header})
this.$emit('input', this.options);
// 保存数据
this.$emit('saveToolData');
return result;
} catch (error) {
return this.$t('json_error', [error.message]).toString()
}
}
},
data() {
return {
options: {
quoted: false,
header: true
}
}
},
}
</script>
<template>
<div>
<div>
<option-block disable-padding>
<Input v-model="options.packageName">
<div slot="prepend">namespace/package</div>
</Input>
</option-block>
<option-block>
<Input v-model="options.className">
<div slot="prepend">class/struct</div>
</Input>
</option-block>
</div>
<input-block bottom="10px" right="10px">
<code-editor :height="`${height - 84}px`" :placeholder="`Object ${$t('json_output')}`" :value="output"
:language="languages[options.type]"/>
<template slot="extra">
<RadioGroup size="small" v-model="options.type" type="button" button-style="solid">
<Radio :label="type" v-for="(type) in types" :key="type">
<span>{{ type }}</span>
</Radio>
</RadioGroup>
</template>
</input-block>
</div>
</template>
<script>
import codeEditor from "../../../components/codeEditor";
import json2Go from '../json2Go'
import json2CSharp from '../json2CSharp'
import json2Java from '../json2Java'
import json2Dart from '../json2Dart'
export default {
props: {
value: {
type: Object,
default: function () {
return {}
}
},
json: {
type: String,
default: ""
},
height: {
type: Number,
default: 100
}
},
created() {
this.options = Object.assign(this.options, this.value)
},
components: {
codeEditor,
},
computed: {
output() {
const json = this.json.trim();
if (!json) {
return "";
}
try {
let result = "";
require('jsonlint').parse(json)
switch (this.options.type) {
case "Go":
result = json2Go(json, this.options.className, this.options.packageName).go
break
case "Java":
result = json2Java(JSON.parse(json), this.options.className, this.options.packageName)
break
case "Dart":
result = json2Dart(JSON.parse(json), this.options.className)
break
case "C#":
result = json2CSharp.convert(JSON.parse(json), this.options.className, this.options.packageName)
break
default:
throw new Error('language type error')
}
this.$emit('input', this.options);
// 保存数据
this.$emit('saveToolData');
return result;
} catch (error) {
return this.$t('json_error', [error.message]).toString()
}
},
types() {
return Object.keys(this.languages)
}
},
data() {
return {
options: {
type: "Java",
packageName: "pag",
className: "RootName",
},
languages: {
"Java": "java",
"Dart": "dart",
"C#": "csharp",
"Go": "go"
},
}
},
}
</script>
<template>
<input-block right="10px">
<code-editor :height="`${height}px`" :placeholder="`Html Table ${$t('json_output')}`" :value="output" language="html"/>
<template slot="extra">
<Checkbox v-model="options.header">{{ $t('json_column_name') }}</Checkbox>
</template>
</input-block>
</template>
<script>
import codeEditor from "../../../components/codeEditor";
import jsonInstance from "../index";
export default {
props: {
value: {
type: Object,
default: function () {
return {}
}
},
json: {
type: String,
default: ""
},
height: {
type: Number,
default: 100
}
},
created() {
this.options = Object.assign(this.options, this.value)
},
components: {
codeEditor,
},
computed: {
output() {
const json = this.json.trim();
if (!json) {
return "";
}
try {
let result = jsonInstance.jsonToTable(JSON.parse(json), {header:this.options.header})
this.$emit('input', this.options);
// 保存数据
this.$emit('saveToolData');
return result;
} catch (error) {
return this.$t('json_error', [error.message]).toString()
}
}
},
data() {
return {
options: {
header: true
}
}
},
}
</script>
<template>
<input-block right="10px" bottom="40px">
<input-block right="10px" bottom="10px">
<code-editor :height="`${height}px`" :placeholder="`Html Table ${$t('json_input')}`" v-model="options.input" language="html"/>
<template slot="extra">
<RadioGroup size="small" v-model="options.type" type="button" button-style="solid">
<Radio :label="item.k" v-for="item in types" :key="item.k">
<span>{{ item.n }}</span>
</Radio>
</RadioGroup>
</template>
</input-block>
<template slot="extra">
<Select size="small" v-model="options.keyed_key" v-if="options.type === 'keyed'" style="width: 150px">
<Option v-for="(key,k) in tableKeys" :key="k" :value="k">{{ key }}</Option>
</Select>
</template>
</input-block>
</template>
<script>
import jsonInstance from "../index";
import codeEditor from "../../../components/codeEditor";
import {tableKeys} from '../tableToJson';
export default {
props: {
value: {
type: Object,
default: function () {
return {}
}
},
height: {
type: Number,
default: 100
}
},
components: {
codeEditor
},
created() {
this.options = Object.assign(this.options, this.value)
},
computed: {
tableKeys() {
try {
let input = this.options.input.trim();
if (this.options.type === "keyed" && input) {
return tableKeys(this.options.input)
}
} catch {
//
}
return [];
}
},
watch: {
options: {
handler(val) {
let input = val.input.trim();
if (input) {
try {
const option = {
keyed_key: val.keyed_key,
type: val.type
}
// json变化事件
this.$emit('change', jsonInstance.tableToJson(input, option));
this.$emit('input', val);
// 保存数据
this.$emit('saveToolData');
} catch (e) {
console.log(e)
this.$emit('change', this.$t('json_error', [e.message]).toString());
}
}
},
deep: true
}
},
data() {
return {
options: {
input: "",
type: "json",
keyed_key: 0
},
types: [
{k: "json", n: this.$t('json_json_type_json')},
{k: "keyed", n: this.$t('json_json_type_keyed')},
{k: "array", n: this.$t('json_json_type_array')},
{k: "column", n: this.$t('json_json_type_column')},
]
}
},
}
</script>
import {parse} from 'csv-parse/lib/sync';
import {jsonOutputFormat} from './helper';
const convert = (csv = "", {type = "json",keyed_key=0} = {}) => {
return jsonOutputFormat(
parse(csv, {columns: true, skip_empty_lines: true}),
type,
keyed_key
)
}
export default convert
export const createTempElement = (innerHTML = "", type = "div", id = "") => {
const el = document.createElement(type);
el.id = id ? id : `ctool-temp-${Math.ceil(Math.random() * 99999)}`
el.style.cssText = "display:none;"
document.body.appendChild(el);
// 移除script标签
el.innerHTML = innerHTML.replace(/<script/gmi, "<xxxxx")
return el;
}
export const jsonOutputFormat = (json, type = "json", keyed_key = 0) => {
if (type === "keyed") {
const keys = Object.keys(json[0])
let result = {}
for (let item of json) {
let item_key = keys[keyed_key]
result[item[item_key]] = item
}
return result
}
if (type === "array") {
let result = json.map((item) => {
return Object.values(item)
})
if (result.length > 0) {
result = [
Object.keys(json[0]),
...result
]
}
return result
}
if (type === "column") {
const keys = Object.keys(json[0])
let result = {}
for (let key of keys) {
result[key] = json.map((item) => {
return item[key]
})
}
return result
}
return json
}
import Unicode from "../unicode";
import formatter from "../formatter/json";
import csvToJson from './csvToJson';
import tableToJson from './tableToJson';
import jsonToTable from './jsonToTable';
import {stringify} from 'csv-stringify/lib/sync';
// 校验语法
export const check = (content) => {
require('jsonlint').parse(content)
return content;
}
// 美化
export const beautify = (content) => {
return formatter.beautify(check(content))
}
// 压缩
export const compress = (content) => {
return formatter.compress(content)
}
// unicode2zh
export const unicode2zh = (content) => {
return Unicode.decode(
content.replace(/\\U[0-9a-fA-F]{4}/g, (item) => {
// \Uxxxx=>\uxxxx
return item.replace("\\U", "\\u");
})
)
}
// zh2unicode
export const zh2unicode = (content) => {
if (content) {
let newStr = ''
for (let i = 0; i < content.length; i++) {
let str = content.charAt(i)
newStr += /[\u4e00-\u9fa5]/.test(str) ? '\\u' + str.charCodeAt(0).toString(16) : str
}
return newStr
}
return content
}
// 转义
export const escape = (content) => {
return content.trim().replace(/\\/g, '\\\\').replace(/"/g, '\\"')
}
// 去转义
export const clearEscape = (content) => {
return content.trim().replace(/\\\\/g, '\\').replace(/\\"/g, '"')
}
// 转get参数
export const toGet = (content) => {
check(content)
return require('query-string').stringify(
JSON.parse(content), {arrayFormat: 'bracket'}
)
}
// get转json
export const fromGet = (content) => {
return beautify(JSON.stringify(require('query-string').parse(content.trim(), {arrayFormat: 'bracket'})))
}
export default {
check,
beautify,
compress,
unicode2zh,
zh2unicode,
escape,
clearEscape,
toGet,
fromGet,
csvToJson: (csv = "", option = {}) => {
return beautify(JSON.stringify(csvToJson(csv, option)))
},
jsonToCsv: (json = [], {quoted = false, header = true} = {}) => {
return stringify(json, {quoted, header})
},
tableToJson: (table = "", option = {}) => {
return beautify(JSON.stringify(tableToJson(table, option)))
},
jsonToTable: (json = [], option = {}) => {
return jsonToTable(json, option)
},
}
/*
JSON-to-Go
by Matt Holt
https://github.com/mholt/json-to-go
A simple utility to translate JSON into a Go type definition.
*/
export default function (json, typename, pag, flatten = true) {
let data;
let scope;
let go = "";
let tabs = 0;
const seen = {};
const stack = [];
let accumulator = "";
let innerTabs = 0;
let parent = "";
try {
data = JSON.parse(json.replace(/:(\s*\d*)\.0/g, ":$1.1")); // hack that forces floats to stay as floats
scope = data;
} catch (e) {
return {
go: "",
error: e.message
};
}
typename = format(typename || "AutoGenerated");
append(`package ${pag}\n\n`);
append(`type ${typename} `);
parseScope(scope);
return {
go: flatten
? go += accumulator
: go
};
function parseScope(scope, depth = 0) {
if (typeof scope === "object" && scope !== null) {
if (Array.isArray(scope)) {
let sliceType;
const scopeLength = scope.length;
for (let i = 0; i < scopeLength; i++) {
const thisType = goType(scope[i]);
if (!sliceType)
sliceType = thisType;
else if (sliceType !== thisType) {
sliceType = mostSpecificPossibleGoType(thisType, sliceType);
if (sliceType === "interface{}")
break;
}
}
const slice = flatten && ["struct", "slice"].includes(sliceType)
? `[]${parent}`
: `[]`;
if (flatten && depth >= 2)
appender(slice);
else
append(slice)
if (sliceType === "struct") {
const allFields = {};
// for each field counts how many times appears
for (let i = 0; i < scopeLength; i++) {
const keys = Object.keys(scope[i])
for (let k in keys) {
let keyname = keys[k];
if (!(keyname in allFields)) {
allFields[keyname] = {
value: scope[i][keyname],
count: 0
}
} else {
const existingValue = allFields[keyname].value;
const currentValue = scope[i][keyname];
if (compareObjects(existingValue, currentValue)) {
const comparisonResult = compareObjectKeys(
Object.keys(currentValue),
Object.keys(existingValue)
)
if (!comparisonResult) {
keyname = `${keyname}_${uuidv4()}`;
allFields[keyname] = {
value: currentValue,
count: 0
};
}
}
}
allFields[keyname].count++;
}
}
// create a common struct with all fields found in the current array
// omitempty dict indicates if a field is optional
const keys = Object.keys(allFields), struct = {}, omitempty = {};
for (let k in keys) {
const keyname = keys[k], elem = allFields[keyname];
struct[keyname] = elem.value;
omitempty[keyname] = elem.count !== scopeLength;
}
parseStruct(depth + 1, innerTabs, struct, omitempty); // finally parse the struct !!
} else if (sliceType === "slice") {
parseScope(scope[0], depth)
} else {
if (flatten && depth >= 2) {
appender(sliceType || "interface{}");
} else {
append(sliceType || "interface{}");
}
}
} else {
if (flatten) {
if (depth >= 2) {
appender(parent)
} else {
append(parent)
}
}
parseStruct(depth + 1, innerTabs, scope);
}
} else {
if (flatten && depth >= 2) {
appender(goType(scope));
} else {
append(goType(scope));
}
}
}
function parseStruct(depth, innerTabs, scope, omitempty) {
if (flatten) {
stack.push(
depth >= 2
? "\n"
: ""
)
}
if (flatten && depth >= 2) {
const parentType = `type ${parent}`;
const scopeKeys = formatScopeKeys(Object.keys(scope));
// this can only handle two duplicate items
// future improvement will handle the case where there could
// three or more duplicate keys with different values
if (parent in seen && compareObjectKeys(scopeKeys, seen[parent])) {
stack.pop();
return
}
seen[parent] = scopeKeys;
appender(`${parentType} struct {\n`);
++innerTabs;
const keys = Object.keys(scope);
for (let i in keys) {
const keyname = getOriginalName(keys[i]);
indenter(innerTabs)
const typename = format(keyname)
appender(typename + " ");
parent = typename
parseScope(scope[keys[i]], depth);
appender(' `json:"' + keyname);
if (omitempty && omitempty[keys[i]] === true) {
appender(',omitempty');
}
appender('"`\n');
}
indenter(--innerTabs);
appender("}");
} else {
append("struct {\n");
++tabs;
const keys = Object.keys(scope);
for (let i in keys) {
const keyname = getOriginalName(keys[i]);
indent(tabs);
const typename = format(keyname);
append(typename + " ");
parent = typename
parseScope(scope[keys[i]], depth);
append(' `json:"' + keyname);
if (omitempty && omitempty[keys[i]] === true) {
append(',omitempty');
}
append('"`\n');
}
indent(--tabs);
append("}");
}
if (flatten)
accumulator += stack.pop();
}
function indent(tabs) {
for (let i = 0; i < tabs; i++)
go += '\t';
}
function append(str) {
go += str;
}
function indenter(tabs) {
for (let i = 0; i < tabs; i++)
stack[stack.length - 1] += '\t';
}
function appender(str) {
stack[stack.length - 1] += str;
}
// Sanitizes and formats a string to make an appropriate identifier in Go
function format(str) {
if (!str)
return "";
else if (str.match(/^\d+$/))
str = "Num" + str;
else if (str.charAt(0).match(/\d/)) {
const numbers = {
'0': "Zero_", '1': "One_", '2': "Two_", '3': "Three_",
'4': "Four_", '5': "Five_", '6': "Six_", '7': "Seven_",
'8': "Eight_", '9': "Nine_"
};
str = numbers[str.charAt(0)] + str.substr(1);
}
return toProperCase(str).replace(/[^a-z0-9]/ig, "") || "NAMING_FAILED";
}
// Determines the most appropriate Go type
function goType(val) {
if (val === null)
return "interface{}";
switch (typeof val) {
case "string":
if (/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(\+\d\d:\d\d|Z)/.test(val))
return "time.Time";
else
return "string";
case "number":
if (val % 1 === 0) {
if (val > -2147483648 && val < 2147483647)
return "int";
else
return "int64";
} else
return "float64";
case "boolean":
return "bool";
case "object":
if (Array.isArray(val))
return "slice";
return "struct";
default:
return "interface{}";
}
}
// Given two types, returns the more specific of the two
function mostSpecificPossibleGoType(typ1, typ2) {
if (typ1.substr(0, 5) === "float"
&& typ2.substr(0, 3) === "int")
return typ1;
else if (typ1.substr(0, 3) === "int"
&& typ2.substr(0, 5) === "float")
return typ2;
else
return "interface{}";
}
// Proper cases a string according to Go conventions
function toProperCase(str) {
// https://github.com/golang/lint/blob/5614ed5bae6fb75893070bdc0996a68765fdd275/lint.go#L771-L810
const commonInitialisms = [
"ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP",
"HTTPS", "ID", "IP", "JSON", "LHS", "QPS", "RAM", "RHS", "RPC", "SLA",
"SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "UID", "UUID",
"URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS"
];
return str.replace(/(^|[^a-zA-Z])([a-z]+)/g, function (unused, sep, frag) {
if (commonInitialisms.indexOf(frag.toUpperCase()) >= 0)
return sep + frag.toUpperCase();
else
return sep + frag[0].toUpperCase() + frag.substr(1).toLowerCase();
}).replace(/([A-Z])([a-z]+)/g, function (unused, sep, frag) {
if (commonInitialisms.indexOf(sep + frag.toUpperCase()) >= 0)
return (sep + frag).toUpperCase();
else
return sep + frag;
});
}
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
function getOriginalName(unique) {
const reLiteralUUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
const uuidLength = 36;
if (unique.length >= uuidLength) {
const tail = unique.substr(-uuidLength);
if (reLiteralUUID.test(tail)) {
return unique.slice(0, -1 * (uuidLength + 1))
}
}
return unique
}
function compareObjects(objectA, objectB) {
const object = "[object Object]";
return Object.prototype.toString.call(objectA) === object
&& Object.prototype.toString.call(objectB) === object;
}
function compareObjectKeys(itemAKeys, itemBKeys) {
const lengthA = itemAKeys.length;
const lengthB = itemBKeys.length;
// nothing to compare, probably identical
if (lengthA === 0 && lengthB === 0)
return true;
// duh
if (lengthA !== lengthB)
return false;
for (let item of itemAKeys) {
if (!itemBKeys.includes(item))
return false;
}
return true;
}
function formatScopeKeys(keys) {
for (let i in keys) {
keys[i] = format(keys[i]);
}
return keys
}
}
\ No newline at end of file
const IMPORT_MAP = {'Date': 'java.util.Date', 'List': 'java.util.List'}
let attrClassAry = [];
function firstToUpperCase(str) {
return str.substr(0, 1).toUpperCase() + str.substr(1);
}
function camelCase(input) {
return input.toLowerCase().replace(/_(.)/g, function (match, group1) {
return group1.toUpperCase();
});
}
function camelCaseWithFirstCharUpper(input) {
if (!input) {
return ""
}
input = camelCase(input);
return input[0].toUpperCase() + input.substr(1);
}
function isDate(date) {
return new Date(date) !== "Invalid Date" && !isNaN(new Date(date)) && isNaN(+date);
}
function isInt(n) {
return n % 1 === 0;
}
function toBeanText(bean, packageName) {
let beanFields = bean.val;
let className = bean.name;
let importText = "";
let fieldText = "";
let setterText = "";
let typeSet = {};
let shoudImportJackson = false;
let tpl = " public void setA(T a) {\n \
this.a = a;\n \
}\n \
public T getA() {\n \
return a;\n \
}\n";
for (let key in beanFields) {
let camelKey = camelCase(key);
if (camelKey !== key) {
fieldText += ' @JsonProperty("' + key + '")\n';
shoudImportJackson = true;
}
fieldText += " private " + beanFields[key] + " " + camelKey + ";\n";
let type = beanFields[key];
if (type.indexOf("List<") > -1) {
type = beanFields[key].replace('List<', "");
type = type.replace('>', "");
typeSet["List"] = 'true';
}
typeSet[type] = 'true';
let tplMap = {a: camelKey, A: firstToUpperCase(camelKey), T: beanFields[key]};
setterText += tpl.replace(/a|A|T/g, function (matched) {
return tplMap[matched];
});
}
for (let t in typeSet) {
if (IMPORT_MAP[t]) {
importText += "import " + IMPORT_MAP[t] + ";\n";
}
}
if (shoudImportJackson) {
importText += "import org.codehaus.jackson.annotate.JsonIgnoreProperties;\nimport org.codehaus.jackson.annotate.JsonProperty;\n"
}
if (packageName) {
importText = "package " + packageName + ";\n" + importText;
}
return "/*=============="+className+".java file============*/\n"+importText + "\n" + "public class " + className + " {\n" + fieldText + setterText + "}\n\n";
}
function getBeanFieldFromJson(json, className) {
let jsonObject;
let text = JSON.stringify(json);
if (text[0] === "[" && text[text.length - 1] === "]") {
text = '{ "list": ' + text + '}';
jsonObject = JSON.parse(text).list[0];
} else {
jsonObject = JSON.parse(text);
}
let bean = {};
attrClassAry = []
for (let key in jsonObject) {
const val = jsonObject[key];
bean[key] = getTypeFromJsonVal(val, key, attrClassAry);
}
if (!className) {
className = "AtoolBean";
}
bean = {name: className, val: bean};
return [bean, ...attrClassAry];
}
function getTypeFromJsonVal(val, key, attrClassAry) {
if (val && val.replace) {
val = val.replace(/ /g, "");
}
let typeofStr = typeof (val);
if (typeofStr === 'number') {
if (isInt(val)) {
return "int";
} else {
return "double";
}
} else if (typeofStr === 'boolean') {
return typeofStr;
} else if (isDate(val)) {
return "Date";
} else if (!val) {
return "String";
} else if (typeofStr === 'string') {
return "String";
} else {
if (Array.isArray(val)) {
let type = getTypeFromJsonVal(val[0], key, attrClassAry);
return "List<" + type + ">";
} else {
let typeName = camelCaseWithFirstCharUpper(key);
let bean = {};
for (key in val) {
let fieldValue = val[key];
bean[key] = getTypeFromJsonVal(fieldValue, key, attrClassAry);
}
attrClassAry.push({name: typeName, val: bean});
return typeName;
}
}
}
export default (json, cls = "JsonRootBean", pag = "pag.json2bean") => {
let beans = [];
let temp = getBeanFieldFromJson(json, cls);
for (let key in temp) {
beans.push(toBeanText(temp[key], pag));
}
return beans.join("\n");
}
\ No newline at end of file
import _ from "lodash";
import {beautify} from "../formatter/html";
const convert = (json = [], {header = true} = {}) => {
if (!_.isArray(json) || json.length < 1) {
return ""
}
let html = ["<table>"];
let keys = Object.keys(json[0])
if (header) {
html.push(
'<thead>',
'<tr>',
...keys.map((item) => {
return `<th>${item}</th>`
}),
'</tr>',
'</thead>'
)
}
html.push("<tbody>")
for (let row of json) {
html.push("<tr>", ...keys.map((item) => {
return `<td>${item in row ? row[item] : ""}</td>`
}), '</tr>');
}
html.push("</tbody></table>")
return beautify(html.join(""))
}
export default convert
import {createTempElement, jsonOutputFormat} from "./helper";
import _ from "lodash";
const nodeFilter = (item) => {
if (item == null) {
return "";
}
const re = new RegExp("<\/?\\w+((\\s+\\w+(\\s*=\\s*(?:\".*?\"|'.*?'|[^'\">\\s]+))?)+\\s*|\\s*)\/?>", 'igm');
item = item.replace(/\r\n|\r|\n/gmi, ' ');
item = item.replace(/\n|<br>|<br\/>|<br \/>/gmi, '\n');
item = item.replace(re, '');
item = _.unescape(item);
item = item.replace(/&nbsp;/gmi, " ");
return item.trim();
}
export const tableKeys = (table) => {
table = table.trim();
if (!table) {
return [];
}
const tableElement = createTempElement(table).getElementsByTagName('table')[0];
let cells = tableElement.getElementsByTagName('tr')[0].querySelectorAll('td,th');
let result = [];
for (let n = 0; n < cells.length; n++) {
result.push(nodeFilter(cells[n].innerHTML))
}
return result;
}
const convert = (table = "", {
keyed_key = 0,
type = "json"
} = {}) => {
table = table.trim();
if (!table) {
return "";
}
let keys = tableKeys(table)
const rows = createTempElement(table).getElementsByTagName('table')[0].getElementsByTagName('tr')
let result = [];
for (let i = 1; i < rows.length; i++) {
const row = rows[i].querySelectorAll('td');
let resultRow = {}
for (let k = 0; k < keys.length; k++) {
resultRow[keys[k]] = nodeFilter(k in row ? row[k].innerHTML : "")
}
result.push(resultRow)
}
return jsonOutputFormat(
result,
type,
keyed_key
)
}
export default convert
......@@ -5,8 +5,14 @@ class Radix {
BigNumber.config({ALPHABET: formatter})
}
convent(base, source, target) {
convent(base, source, target, debug = false) {
if (debug){
BigNumber.DEBUG = true
}
let sourceNum = new BigNumber(base, source);
if (debug){
BigNumber.DEBUG = false
}
return sourceNum.toString(target);
}
}
......
......@@ -21,13 +21,9 @@
<TabPane :label="$t('qrCode_reader_title')" name="reader">
<Row :gutter="16">
<Col span="14">
<input-block style="margin-bottom: 10px" bottom="0px" right="10px" class="tool-reader-input">
<pasteClipboardFlie @on-paste-image="handleUpload">
<Input v-model="current.readerInput" :rows="5" type="textarea" :placeholder="$t('qrCode_reader_input')"></Input>
</pasteClipboardFlie>
<Upload slot="extra" action="#" :before-upload="handleUpload">
<Button size="small" type="primary" icon="ios-cloud-upload-outline">{{ $t('qrCode_reader_upload') }}</Button>
</Upload>
<input-block style="margin-bottom: 10px" class="tool-reader-input">
<Input v-model="current.readerInput" :rows="5" type="textarea" :placeholder="$t('qrCode_reader_input')" />
<updateFile slot="extra" type="image" @success="handleUpload" />
</input-block>
<heightResize :reduce="52" :append="['.tool-reader-input']">
<autoHeightTextarea :value="readerOutput" :placeholder="$t('qrCode_reader_output')" />
......@@ -48,13 +44,13 @@ import generator from 'qrcode'
import qrcodeParser from 'qrcode-parser'
import model from '../../tool/model'
import Jimp from 'jimp';
import pasteClipboardFlie from './components/pasteClipboardFlie';
import updateFile from './components/updateFile';
import heightResize from "./components/heightResize";
import autoHeightTextarea from "./components/autoHeightTextarea";
export default {
components: {
pasteClipboardFlie,
updateFile,
heightResize,
autoHeightTextarea
},
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
<template>
<div>
<heightResize ignore @resize="resize">
<Row :gutter="10">
<Col span="6" style="margin-top: 10px">
<Card :padding="0">
<p slot="title">输入变量名</p>
<template slot="extra">
<Button size="small" type="primary" @click="handle()">转换
</Button>
</template>
<Input v-model="current.input" :rows="4" type="textarea" placeholder="变量名 一行一个"></Input>
</Card>
<Col span="6">
<input-block top="4px" :text="$t('variableConversion_input')">
<autoHeightTextarea :height="height1" v-model="current.input" :placeholder="$t('variableConversion_input_placeholder')" />
</input-block>
</Col>
<Col span="6" v-for="(item,key) in resultColumns" :key="key" style="margin-top: 10px">
<Card :padding="0">
<p slot="title">{{ item.title }}</p>
<Input v-model="current.output[item.key]" :rows="4" type="textarea"></Input>
</Card>
<Col span="6" v-for="(item,key) in resultColumns" :key="key" :style="`margin-top: ${key > 2 ? '10px' : '0'}`">
<input-block top="4px" type="default" :text="item.title" @on-default-right-bottom-click="()=>$copy(output[item.key])">
<autoHeightTextarea :height="key > 2 ? height2 : height1" :value="output[item.key]" :placeholder="item.title" />
</input-block>
</Col>
</Row>
</div>
</heightResize>
</template>
<script>
import varCamelCase from "./library/varCamelCase"
import heightResize from "./components/heightResize";
import autoHeightTextarea from "./components/autoHeightTextarea";
export default {
components: {
heightResize,
autoHeightTextarea
},
computed: {
resultColumns() {
return varCamelCase.resultKey.map((item) => {
......@@ -33,26 +33,29 @@ export default {
}
});
},
output() {
let result = varCamelCase.convent(this.current.input)
this.$saveToolData(this.current);
return result;
}
},
created() {
this.current = Object.assign(this.current, this.$getToolData("input"))
this.$initToolData('input')
},
methods: {
handle() {
if (!this.current.input) {
return;
}
this.current.output = varCamelCase.convent(this.current.input)
this.$saveToolData(this.current);
resize(height) {
this.height1 = Math.ceil(height/2);
this.height2 = height - this.height1 - 10;
}
},
data() {
return {
current: {
input: "",
output: [],
}
input: ""
},
height1: 100,
height2: 100
}
},
}
</script>
\ No newline at end of file
</script>
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册