Skip to content

Commit f8dcbf5

Browse files
committed
ready for v2.0.1
1 parent d9883a2 commit f8dcbf5

8 files changed

Lines changed: 75 additions & 16 deletions

File tree

js/popup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
chrome.runtime.openOptionsPage();
1+
sessionStorage.setItem("isOption", "0");

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dev-tool",
33
"description": "a dev-tool for chrome extension",
4-
"version": "2.0.0",
4+
"version": "2.0.1",
55
"manifest_version": 3,
66
"permissions": [
77
"alarms",
@@ -32,5 +32,5 @@
3232
"default_title": "dev-tool",
3333
"default_popup": "popup.html"
3434
},
35-
"homepage_url": "https://github.com/zhimin-dev"
35+
"homepage_url": "https://github.com/zhimin-dev/dev-tool"
3636
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"build": "vite build",
77
"preview": "vite preview --port 4173",
88
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
9-
"build-local": "node js/build_package.js && vite build && mkdir -p dist/js && cp -r js/ dist/js/ && cp manifest.json dist/manifest.json && cp popup.html dist/popup.html"
9+
"build-local": "node js/build_package.js && vite build && mkdir -p dist/js && cp -r js/ dist/js/ && cp manifest.json dist/manifest.json"
1010
},
1111
"dependencies": {
1212
"axios": "^0.21.0",

popup.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<meta charset="utf-8">
4+
<meta charset="UTF-8" />
5+
<link rel="shortcut icon" href="icon.png" type="image/png" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
57
<title>dev-tool</title>
68
</head>
79
<body>
10+
<div id="app"></div>
811
<script src="js/popup.js"></script>
12+
<script type="module" src="/src/main.js"></script>
913
</body>
1014
</html>

src/App.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div id="app" :class="{ fixedWidth: true }">
3-
<el-tabs v-model="nowType">
3+
<el-tabs v-model="nowType" @tab-click="changeTab">
44
<el-tab-pane label="常用" name="normal">
55
<div class="normal-container">
66
<div class="normal-item">
@@ -53,6 +53,7 @@ import SqlToModel from "./components/SqlToModel.vue";
5353
import Notice from "./components/Notice.vue";
5454
import Setting from "./components/Setting.vue";
5555
import JsonStuff from "./components/JsonStuff.vue";
56+
const lastClickTabStorage = "last:click";
5657
5758
export default {
5859
name: "app",
@@ -62,7 +63,22 @@ export default {
6263
isFull: true,
6364
};
6465
},
65-
created() {},
66+
created() {
67+
let item = localStorage.getItem(lastClickTabStorage);
68+
if (item !== "" && item !== null) {
69+
this.nowType = item;
70+
}
71+
72+
item = sessionStorage.getItem("isOption");
73+
if (item === "0") {
74+
this.isFull = false;
75+
}
76+
},
77+
methods: {
78+
changeTab() {
79+
localStorage.setItem(lastClickTabStorage, this.nowType);
80+
},
81+
},
6682
components: {
6783
Time,
6884
Decode,

src/components/Link.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
</div>
8989
</template>
9090
<script>
91+
import manifest from "./../../manifest.json";
9192
export default {
9293
props: {
9394
hideMenuBar: String,
@@ -97,8 +98,8 @@ export default {
9798
linkList: [
9899
{ url: "https://regex101.com/", title: "正则" },
99100
{
100-
url: "http://github.com/zhimin-dev/chrome-extension",
101-
title: "本插件Github",
101+
url: manifest.homepage_url,
102+
title: "本插件Github@v" + manifest.version,
102103
},
103104
],
104105
showExport: false,

src/components/Time.vue

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
v-model="nowTime"
1212
size="mini"
1313
class="now-time"
14-
placeholder="当前时间"
14+
placeholder="当前时间戳"
1515
></el-input>
1616
<div class="now-time">
1717
<el-button size="mini" @click="this.unixtimestampToTimeStr"
@@ -26,19 +26,23 @@
2626
size="mini"
2727
class="now-time"
2828
placeholder="当前时间"
29+
@change="changeShowTime"
2930
></el-input>
3031
</div>
3132
</div>
3233
</template>
3334
<script>
35+
const lastTimStr = "time:last:showTime";
36+
const copyFromClipboard = "time:copy:clipboard";
37+
3438
export default {
3539
data() {
3640
return {
3741
mTime: {
3842
str: "",
3943
unixtime: 0,
4044
},
41-
nowTime: 0,
45+
nowTime: "",
4246
showTime: "",
4347
year: 2020,
4448
month: 1,
@@ -50,21 +54,48 @@ export default {
5054
};
5155
},
5256
created() {
53-
const thisTime = new Date().getTime();
54-
this.nowTime = Math.round(thisTime / 1000);
55-
this.showTime = this.getTimestamp(new Date(thisTime));
57+
setInterval(() => {
58+
navigator.clipboard
59+
.readText()
60+
.then((res) => {
61+
if (!this.checkClipboardExist(res)) {
62+
if (parseInt(res) == res) {
63+
this.nowTime = res;
64+
this.unixtimestampToTimeStr();
65+
this.$message("从剪贴板获取时间戳");
66+
}
67+
localStorage.setItem(copyFromClipboard, res);
68+
}
69+
})
70+
.catch((e) => {
71+
console.log(e);
72+
});
73+
}, 1000);
74+
75+
let item = localStorage.getItem(lastTimStr);
76+
if (item !== null && item !== "") {
77+
this.showTime = item;
78+
}
5679
setInterval(() => {
5780
const now = new Date();
5881
this.mTime.unixtime = Math.round(now.getTime() / 1000);
5982
this.mTime.str = this.getTimestamp(now);
6083
}, 500);
6184
},
6285
methods: {
86+
checkClipboardExist(res) {
87+
let item = localStorage.getItem(copyFromClipboard);
88+
if (item === "" || item === null) {
89+
return false;
90+
}
91+
return res === item;
92+
},
6393
copyNowUnixtime() {
6494
this.nowTime = this.mTime.unixtime;
6595
},
6696
copyTimeStr() {
6797
this.showTime = this.mTime.str;
98+
this.changeShowTime();
6899
},
69100
getTimestamp(timestamp) {
70101
return `${timestamp.getFullYear()}-${
@@ -93,6 +124,9 @@ export default {
93124
this.$message.error("解析失败");
94125
}
95126
},
127+
changeShowTime() {
128+
localStorage.setItem(lastTimStr, this.showTime);
129+
},
96130
unixtimestampToTimeStr() {
97131
let unixNumber;
98132
if (`${this.nowTime}`.length === 10) {
@@ -101,6 +135,7 @@ export default {
101135
unixNumber = parseInt(this.nowTime, 10);
102136
}
103137
this.showTime = this.getTimestamp(new Date(unixNumber));
138+
this.changeShowTime();
104139
},
105140
},
106141
};

vite.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import { fileURLToPath, URL } from "node:url";
2-
31
import { defineConfig } from "vite";
42
import vue2 from "@vitejs/plugin-vue2";
53

64
// https://vitejs.dev/config/
75
export default defineConfig({
86
plugins: [vue2()],
7+
build: {
8+
rollupOptions: {
9+
input: ["index.html", "popup.html"],
10+
},
11+
},
912
});

0 commit comments

Comments
 (0)