Skip to content

Commit

Permalink
添加url decode 拆分功能
Browse files Browse the repository at this point in the history
  • Loading branch information
bigintpro committed Nov 29, 2021
1 parent 433239d commit b3adde8
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 25 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ json formater,安全的json格式化工具
## 已开发功能
+ json格式化
+ url编码和解码
+ url编码和解码新增智能切割


## 待开发功能
+ xml格式解析
+ int最大值(数据类型最大值)
+ ascii 码转换


![界面1](./snapshots/p2.jpg)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsonman",
"version": "1.0.4",
"version": "1.0.5",
"author": "zhudesheng <[email protected]>",
"description": "free,security app for json format",
"license": "MIT",
Expand Down Expand Up @@ -64,6 +64,7 @@
},
"dependencies": {
"axios": "^0.18.0",
"electron-find": "^1.0.7",
"element-ui": "^2.15.6",
"vue": "^2.5.16",
"vue-electron": "^1.0.6",
Expand Down
31 changes: 16 additions & 15 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {app, BrowserWindow, Menu, MenuItem} from 'electron'
import {app, BrowserWindow, Menu, globalShortcut} from 'electron'
import '../renderer/store'

/**
Expand Down Expand Up @@ -40,13 +40,13 @@ function createWindow() {
label: 'Feature',
submenu: [
{
label: 'home',
label: 'json print',
click: () => {
mainWindow.webContents.send('href', 'json-print');
}
},
{
label: 'decode',
label: 'url decode | encode',
click: () => {
mainWindow.webContents.send('href', 'url-print');
}
Expand All @@ -65,20 +65,20 @@ function createWindow() {
mainWindow.on('closed', () => {
mainWindow = null
})
}

mainWindow.on('focus', () => {
globalShortcut.register('CommandOrControl+F', function () {
if (mainWindow && mainWindow.webContents) {
mainWindow.webContents.send('on-find', '')
}
})
})
mainWindow.on('blur', () => {
globalShortcut.unregister('CommandOrControl+F')
})

// const menu = new Menu()
// menu.append(new MenuItem({
// label: 'Electron',
// submenu: [{
// role: 'help',
// accelerator: process.platform === 'darwin' ? 'Alt+Cmd+I' : 'Alt+Shift+I',
// click: () => { console.log('Electron rocks!') }
// }]
// }))
//
// Menu.setApplicationMenu(menu)

}


app.on('ready', createWindow)
Expand All @@ -87,6 +87,7 @@ app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
globalShortcut.unregister('CommandOrControl+F')
})

app.on('activate', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ body {
padding: 0;
width: 100%;
/*height: 600px;*/
height: calc(98vh);
height: calc(100vh);
overflow-y: hidden;
}
#app {
Expand Down
64 changes: 56 additions & 8 deletions src/renderer/components/UrlPrint/UrlPrint.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<template>
<div class="container">

<div class="d1">
<el-input class="url_input" type="textarea" resize="none" autofocus="true" max="100%" min="100%"
<el-input style="margin: 0px;padding: 0px;border-width: 0px;" class="url_input" type="textarea" resize="none" autofocus="true" max="100%" min="100%"
placeholder="欢迎使用jsonman 请在此输入url字符串" v-model="textarea1">
</el-input>
</div>
Expand All @@ -11,13 +10,30 @@
<el-button type="primary" @click="encode">encode</el-button>
</div>
<div class="d2">
<div class="url_output" v-html="textarea2" style=""></div>
<div style="margin: 0px;border-width: 0px; width: 100%;height: 100%" class="url_output" v-html="textarea2"></div>
</div>
<div class="b2">
<el-button type="info" size="mini" @click="format('&')">& format</el-button>
</div>
</div>

</template>

<script>
import {splitStrPrint} from '../../service/strparse'
import {remote, ipcRenderer} from 'electron'
import {FindInPage} from 'electron-find'
let findInPage = new FindInPage(remote.getCurrentWebContents(), {
preload: true,
offsetTop: 6,
offsetRight: 10
})
ipcRenderer.on('on-find', (e, args) => {
findInPage.openFindWindow()
})
export default {
name: "UrlPrint",
Expand All @@ -29,6 +45,9 @@ export default {
}
},
methods: {
format: function (separator) {
this.textarea2 = splitStrPrint(separator, this.textarea2, '<br>');
},
decode: function () {
if (!this.textarea1) {
this.textarea2 = "";
Expand Down Expand Up @@ -69,27 +88,41 @@ export default {
display: block;
width: 96%;
height: 40%;
border-width: 0px;
}
.d1 {
background-color: #e7edeb;
margin: 1%;
margin: 1% 1% 4px 1%;
padding: 1%;
}
.d2 {
background-color: #e7edeb;
margin: 1%;
margin: 0% 1% 4px 1%;
padding: 1%;
}
.b1 {
width: 202px;
height: 2.5rem;
height: 5%;
margin: 0 auto;
}
.b2 {
width: 202px;
height: 2%;
margin: 0 auto;
}
.b1,.b2{
border-width: 0px;
padding: 0px;
}
.url_input {
width: 100%;
Expand All @@ -102,10 +135,12 @@ export default {
font-size: 14px;
text-align: left;
background-color: white;
width: 100%;
width: 98%;
height: 100%;
resize: none;
overflow: scroll;
overflow-wrap: break-word;
overflow: auto;
padding: 0.5rem;
}
Expand All @@ -116,5 +151,18 @@ export default {
width: 100%;
height: 100%;
min-height: 100%;
margin: 0px;
padding: 0px;
}
.url_output {
overflow-wrap: break-word;
line-height: 1.5rem;
}
.d1 div,.d2 div{
padding: 0;
margin: 0;
border-width: 0;
}
</style>
36 changes: 36 additions & 0 deletions src/renderer/service/strparse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
*
* @param separator 切割字符串
* @param str 待切割字符串
* @param insertBefore 匹配项前面插入字符串
* @returns {string|*}
*/
export function splitStrPrint(separator, str, insertBefore) {

if (!separator) {
return str;
}
if (!str) {
return '';
}
if (!insertBefore) {
insertBefore = '';
}


let splits = str.split(separator);
if (splits.length === 0) {
return '';
}
let result = '';

result = splits[0];

for (let i = 1; i < splits.length; i++) {
result = result.concat(insertBefore);
result = result.concat(separator);
result = result.concat(splits[i]);
}
return result;
}

0 comments on commit b3adde8

Please sign in to comment.