Skip to content

Commit

Permalink
Merge pull request #9 from zhimin-dev/vite
Browse files Browse the repository at this point in the history
v2.04
  • Loading branch information
zmisgod authored Aug 17, 2023
2 parents 7c42f34 + 07e81cb commit 82a5f85
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 200 deletions.
51 changes: 0 additions & 51 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,54 +34,3 @@ chrome.alarms.onAlarm.addListener(() => {
const minute = date.getMinutes();
noticeAlert(hour, minute);
});

function request_proxy({ url, method, data }) {
const XHR = new XMLHttpRequest();
XHR.open(method, url);
XHR.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
XHR.send(data);
XHR.onreadystatechange = function () {
if (XHR.readyState === 4) {
console.log(XHR.responseText);
}
};
}

const wbSpiderConfig = {};

chrome.storage.onChanged.addListener((changes, namespace) => {
console.log("change ======");
for (const [key, { oldValue, newValue }] of Object.entries(changes)) {
console.log("change key", key, newValue);
if (key === "wbSpider" || key === "wbSpiderStart") {
if (key === "wbSpider") {
wbSpiderConfig.url = newValue;
} else if (key === "wbSpiderStart") {
wbSpiderConfig.start = newValue;
}
}
console.log(wbSpiderConfig);
}
});

chrome.runtime.onMessage.addListener((data, sender, sendResponse) => {
console.log(data, wbSpiderConfig);
if (wbSpiderConfig.url !== "" && wbSpiderConfig.start) {
fetch(wbSpiderConfig.url, {
method: "POST",
body: JSON.stringify(data),
headers: {
"Content-Type": "application/json;charset=UTF-8",
},
})
.then((resp) => {
console.log(resp);
sendResponse({ code: 200 });
})
.catch((err) => {
console.log(err);
sendResponse({ code: 500 });
});
}
sendResponse({ code: 200 });
});
5 changes: 2 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"name": "dev-tool",
"description": "a dev-tool for chrome extension",
"version": "2.0.3",
"version": "2.0.4",
"manifest_version": 3,
"permissions": [
"alarms",
"notifications",
"webRequest",
"storage",
"nativeMessaging",
"http://*/"
"nativeMessaging"
],
"background": {
"service_worker": "js/background.js"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dev-tool",
"version": "0.0.0",
"version": "2.0.4",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
6 changes: 2 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<el-tab-pane label="HtmlShow" v-if="isFull" name="HtmlShow"
><HtmlShow
/></el-tab-pane>
<el-tab-pane label="设置" name="setting"><Setting /></el-tab-pane>
</el-tabs>
</div>
</template>
Expand All @@ -51,8 +50,8 @@ import HtmlShow from "./components/Html.vue";
import Link from "./components/Link.vue";
import SqlToModel from "./components/SqlToModel.vue";
import Notice from "./components/Notice.vue";
import Setting from "./components/Setting.vue";
import JsonStuff from "./components/JsonStuff.vue";
const lastClickTabStorage = "last:click";
export default {
Expand Down Expand Up @@ -89,7 +88,6 @@ export default {
SqlToModel,
Notice,
JsonStuff,
Setting,
},
};
</script>
Expand All @@ -103,7 +101,7 @@ export default {
color: #2c3e50;
}
.fixedWidth {
width: 700px;
width: 800px;
}
.fullWidth {
width: 100%;
Expand Down
35 changes: 16 additions & 19 deletions src/components/Cal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@
placeholder="请输入值1"
>
</el-input>
<el-select
@change="calResult"
size="mini"
class="cal-type"
<el-radio-group
v-model="cal_type"
placeholder="请选择"
size="small"
style="width: 200px"
@input="calResult"
>
<el-option
v-for="item in cal_options"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
<el-radio-button
:label="value.label"
v-for="(value, index) in cal_options"
:key="index"
></el-radio-button>
</el-radio-group>
<el-input
@input="calResult"
size="mini"
Expand Down Expand Up @@ -53,7 +50,7 @@ export default {
result: "",
value1: "",
value2: "",
cal_type: 1,
cal_type: "/",
cal_options: [
{
label: "+",
Expand All @@ -80,15 +77,15 @@ export default {
},
methods: {
calResult() {
if (this.cal_type === 1) {
if (this.cal_type === "+") {
this.result = Number(this.value1) + Number(this.value2);
} else if (this.cal_type === 2) {
} else if (this.cal_type === "-") {
this.result = Number(this.value1) - Number(this.value2);
} else if (this.cal_type === 3) {
} else if (this.cal_type === "x") {
this.result = Number(this.value1) * Number(this.value2);
} else if (this.cal_type === 4) {
} else if (this.cal_type === "/") {
this.result = Number(this.value1) / Number(this.value2);
} else if (this.cal_type === 5) {
} else if (this.cal_type === "%") {
this.result = Number(this.value1) % Number(this.value2);
}
},
Expand Down
13 changes: 12 additions & 1 deletion src/components/JsonStuff.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<script>
import jsonFormate from "../utils/json-format";
import { jsonToGo } from "../utils/json-to-go";
import { structStrToJson } from "../utils/go/structToJson";
export default {
props: {
isFull: Boolean,
Expand All @@ -68,6 +68,10 @@ export default {
type: 3,
name: "json转table (输入json数组)",
},
// {
// type: 4,
// name: "go struct to json",
// },
],
};
},
Expand All @@ -83,9 +87,16 @@ export default {
} else if (mode === 3) {
this.nowMode = 3;
this.doJsonToTable();
} else if (mode === 4) {
this.nowMode = 4;
this.doGoStructToJson();
}
}
},
doGoStructToJson() {
const goObj = structStrToJson(this.userInputJson);
this.showJson = goObj.go;
},
doJsonFormat(type) {
let obj;
try {
Expand Down
121 changes: 0 additions & 121 deletions src/components/Setting.vue

This file was deleted.

Loading

0 comments on commit 82a5f85

Please sign in to comment.