Skip to content

Commit e73305b

Browse files
committed
opt code
1 parent e77fced commit e73305b

9 files changed

Lines changed: 125 additions & 57 deletions

File tree

dist/build.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/build.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/option.js

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

src/App.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<el-tab-pane label="模拟请求" v-if="isFull" name="sim"><Sim /></el-tab-pane>
2323
<el-tab-pane label="JsonToGo" name="jsonToGo"><JsonToGo /></el-tab-pane>
2424
<el-tab-pane label="HtmlShow" name="HtmlShow"><HtmlShow /></el-tab-pane>
25-
<el-tab-pane label="Iptv" v-if="isFull" name="Iptv"><Iptv /></el-tab-pane>
25+
<el-tab-pane label="Iptv Checker" v-if="isFull" name="Iptv"><Iptv /></el-tab-pane>
2626
</el-tabs>
2727
</div>
2828
</template>
@@ -81,10 +81,6 @@ export default {
8181
width: 100%;
8282
}
8383
84-
h1, h2 {
85-
font-weight: normal;
86-
}
87-
8884
ul {
8985
list-style-type: none;
9086
padding: 0;

src/components/Cal.vue

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
<template>
22
<div class="cal-container">
3-
<div>
4-
<el-input @input="calResult" class="value1" v-model="value1" placeholder="请输入值1">
3+
<div class="cal-formulate">
4+
<el-input @input="calResult" size="mini" class="value1" v-model="value1" placeholder="请输入值1">
55
</el-input>
6-
<el-select @change="calResult" class="cal-type" v-model="cal_type" placeholder="请选择">
6+
<el-select @change="calResult" size="mini" class="cal-type"
7+
v-model="cal_type" placeholder="请选择">
78
<el-option
89
v-for="item in cal_options"
910
:key="item.value"
1011
:label="item.label"
1112
:value="item.value">
1213
</el-option>
1314
</el-select>
14-
<el-input @input="calResult" class="value2" v-model="value2" placeholder="请输入值2"></el-input>
15+
<el-input @input="calResult" size="mini" class="value2" v-model="value2" placeholder="请输入值2">
16+
</el-input>
1517
</div>
1618
<div>
17-
<el-input class="result" v-model="result" placeholder="请输入值2"></el-input>
19+
<el-input class="result" size="mini" v-model="result" placeholder="请输入值2">
20+
</el-input>
21+
<el-link @click="useResult">reuse result</el-link>
1822
</div>
1923
</div>
2024
</template>
@@ -65,19 +69,28 @@ export default {
6569
this.result = Number(this.value1) % Number(this.value2);
6670
}
6771
},
72+
useResult() {
73+
const { result } = this;
74+
this.value1 = result;
75+
this.value2 = '';
76+
this.result = '';
77+
},
6878
},
6979
};
7080
</script>
7181

7282
<style lang="sass" scoped>
7383
.cal-container
7484
display: flex;
75-
.value1
76-
width: 200px;
77-
margin-right: 10px
78-
.value2
79-
width: 200px;
80-
margin-right: 10px
81-
.cal-type
82-
width: 60px;
85+
.cal-formulate
86+
display: flex;
87+
.value1
88+
width: 200px;
89+
margin-right: 10px
90+
.value2
91+
width: 200px;
92+
margin-right: 10px
93+
.cal-type
94+
width: 60px;
95+
margin-right: 10px
8396
</style>

src/components/Iptv.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ export default {
151151
throw new Error('first line is not m3u');
152152
}
153153
this.nowCheckCount += 1;
154-
}).catch((err) => {
155-
console.log(err);
154+
}).catch(() => {
156155
this.list[i].status = 2;
157156
this.nowCheckCount += 1;
158157
});
@@ -206,7 +205,7 @@ export default {
206205
let value = '';
207206
while ((m = regex.exec(str)) !== null) {
208207
if (m.index === regex.lastIndex) {
209-
regex.lastIndex++;
208+
regex.lastIndex += 1;
210209
}
211210
m.forEach((match, groupIndex) => {
212211
if (groupIndex === 1) {
@@ -223,7 +222,6 @@ export default {
223222
const contextExp = content.split('\n');
224223
if (contextExp.length > 0) {
225224
const firstLine = contextExp[0];
226-
console.log(firstLine);
227225
if (firstLine.replace('#EXTM3U', '') === firstLine) {
228226
return false;
229227
}

src/components/Json.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
v-model="orJson"
99
></el-input>
1010
</div>
11-
<div class="show-json">
11+
<div class="show-json" v-if="showJson !== ''">
1212
<el-input
1313
type="textarea"
14-
v-if="orJson !== ''"
1514
placeholder="显示的json"
1615
v-model="showJson"
1716
:autosize="true"

src/components/Link.vue

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@
1010
@click="saveLinkFun" v-if="nowType === 1">保存</el-button>
1111
<el-button icon="el-icon-edit" size="mini"
1212
v-if="linkList.length > 0 && nowType === 0"
13-
@click="editLinkFun">编辑</el-button>
13+
@click="editLinkFun">添加/编辑</el-button>
1414
</div>
1515
<div style="margin-left: 20px;" v-if="linkList.length > 0 && nowType === 0">
16+
<el-button icon="el-icon-s-operation" size="mini"
17+
@click="importJsonFun">导入链接</el-button>
1618
<el-button icon="el-icon-s-operation" size="mini"
1719
@click="exportJsonFun">导出链接</el-button>
1820
</div>
21+
</div>
22+
<div class="list-link" v-if="mode == 0">
23+
<div class="list-link-item" v-for="(value, index) in linkList" :key="index">
24+
<a :href="value.url" target="__blank">
25+
{{value.title}}
26+
<i class="el-icon-s-promotion"></i>
27+
</a>
28+
</div>
1929
</div>
2030
<el-table
31+
v-if="mode == 1"
2132
:data="linkList"
2233
style="width: 100%">
2334
<el-table-column
@@ -52,12 +63,14 @@
5263
</template>
5364
</el-table-column>
5465
</el-table>
55-
<el-input
56-
type="textarea"
57-
:rows="2"
58-
v-if="showExport"
59-
v-model="exportJson">
60-
</el-input>
66+
<div v-if="showExport || showImport" class="import-area">
67+
<el-input
68+
type="textarea"
69+
autosize="true"
70+
v-model="exportJson">
71+
</el-input>
72+
<el-button size="mini" v-if="showImport" @click="doImport">点击导入</el-button>
73+
</div>
6174
</div>
6275
</template>
6376
<script>
@@ -66,9 +79,11 @@ export default {
6679
return {
6780
linkList: [{ url: 'https://regex101.com/', title: '正则' }, { url: 'http://github.com/zhimin-dev/chrome-extension', title: '本插件Github' }],
6881
showExport: false,
82+
showImport: false,
6983
exportJson: '',
7084
nowType: 0,
7185
showDelete: false,
86+
mode: 0, // 0 链接 1 显示表格
7287
};
7388
},
7489
created() {
@@ -84,8 +99,33 @@ export default {
8499
methods: {
85100
saveLink() {
86101
localStorage.setItem('linkUrl', JSON.stringify(this.linkList));
102+
this.mode = 0;
103+
},
104+
doImport() {
105+
const row = this.exportJson;
106+
try {
107+
const list = JSON.parse(row);
108+
for (let i = 0; i < list.length; i += 1) {
109+
if (list[i].url !== undefined && list[i].title !== undefined) {
110+
this.linkList.push(this.setObj(list[i].title, list[i].url, true));
111+
}
112+
}
113+
this.saveLink();
114+
this.exportJson = '';
115+
} catch (e) {
116+
console.log(e);
117+
}
118+
},
119+
importJsonFun() {
120+
this.showExport = false;
121+
if (!this.showImport) {
122+
this.showImport = true;
123+
} else {
124+
this.showImport = false;
125+
}
87126
},
88127
exportJsonFun() {
128+
this.showImport = false;
89129
if (!this.showExport) {
90130
this.showExport = true;
91131
this.exportJson = JSON.stringify(this.linkList);
@@ -94,15 +134,19 @@ export default {
94134
}
95135
},
96136
getEmptyObj() {
137+
return this.setObj('', '', true);
138+
},
139+
setObj(title, url, canEdit) {
97140
return {
98-
title: '',
99-
url: '',
100-
canEdit: true,
141+
title,
142+
url,
143+
canEdit,
101144
};
102145
},
103146
addLinkFun() {
104147
this.nowType = 1;
105148
this.linkList.push(this.getEmptyObj());
149+
this.mode = 1;
106150
},
107151
saveLinkFun() {
108152
this.showDelete = false;
@@ -123,9 +167,11 @@ export default {
123167
for (let i = 0; i < this.linkList.length; i += 1) {
124168
this.linkList[i].canEdit = true;
125169
}
170+
this.mode = 1;
126171
},
127172
deleteRowFun(index) {
128173
this.linkList.splice(index, 1);
174+
this.mode = 1;
129175
},
130176
cancelLinkFun() {
131177
if (this.nowType === 1 && !this.showDelete) {
@@ -136,7 +182,21 @@ export default {
136182
this.linkList[i].canEdit = false;
137183
}
138184
this.showDelete = false;
185+
this.mode = 0;
139186
},
140187
},
141188
};
142189
</script>
190+
<style lang="sass" scope>
191+
.list-link
192+
display: flex
193+
flex-wrap: wrap;
194+
.list-link-item
195+
margin-right: 15px
196+
padding: 10px
197+
a
198+
color: #000
199+
text-decoration: none
200+
.import-area
201+
display: flex;
202+
</style>

src/script/content/annom.com.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
function parseTime(testTime) {
2+
const a = testTime.split(' ');
3+
const result = {
4+
y: 0, m: 0, d: 0, h: 0, mi: 0, s: 0,
5+
};
6+
if (a.length >= 2) {
7+
const ymd = a[0].split('-');
8+
result.y = Number(ymd[0]);
9+
result.m = Number(ymd[1]);
10+
result.d = Number(ymd[2]);
11+
const hms = a[1].split(':');
12+
result.h = Number(hms[0]);
13+
result.mi = Number(hms[1]);
14+
result.s = Number(hms[2]);
15+
}
16+
return result;
17+
}
18+
119
setInterval(() => {
220
const list = document.getElementsByClassName('content');
321
if (list.length === 3) {
@@ -14,7 +32,8 @@ setInterval(() => {
1432
const timeValueS = timeValue.split(' ');
1533
if (timeValueS.length === 3 && timeValueS[2] === 'PST') {
1634
const re = parseTime(timeValue);
17-
const stamp = new Date(re.y, re.m - 1, re.d, re.h, re.mi, re.s).getTime() / 1000 + 16 * 3600;
35+
const stamp = new Date(re.y, re.m - 1, re.d, re.h, re.mi, re.s).getTime()
36+
/ 1000 + 16 * 3600;
1837
j[i].innerText = new Date(stamp * 1000).toLocaleString();
1938
}
2039
}
@@ -23,20 +42,3 @@ setInterval(() => {
2342
}
2443
}
2544
}, 1000);
26-
function parseTime(testTime) {
27-
const a = testTime.split(' ');
28-
const result = {
29-
y: 0, m: 0, d: 0, h: 0, mi: 0, s: 0,
30-
};
31-
if (a.length >= 2) {
32-
const ymd = a[0].split('-');
33-
result.y = Number(ymd[0]);
34-
result.m = Number(ymd[1]);
35-
result.d = Number(ymd[2]);
36-
const hms = a[1].split(':');
37-
result.h = Number(hms[0]);
38-
result.mi = Number(hms[1]);
39-
result.s = Number(hms[2]);
40-
}
41-
return result;
42-
}

0 commit comments

Comments
 (0)