Skip to content

Commit b71ac6d

Browse files
committed
change webpack to vite
1 parent 4625d08 commit b71ac6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3962
-9633
lines changed

.babelrc

-6
This file was deleted.

.editorconfig

-9
This file was deleted.

.eslintrc.cjs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-env node */
2+
require("@rushstack/eslint-patch/modern-module-resolution");
3+
4+
module.exports = {
5+
root: true,
6+
extends: [
7+
"plugin:vue/essential",
8+
"eslint:recommended",
9+
"@vue/eslint-config-prettier",
10+
],
11+
};

.eslintrc.js

-19
This file was deleted.

.github/workflows/ci.yml renamed to .github/workflows/action.yml

+15-21
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ jobs:
2323
# Steps represent a sequence of tasks that will be executed as part of the job
2424
steps:
2525
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v3
2727

2828
- name: Setup Node.js environment
29-
uses: actions/setup-node@v2.1.2
29+
uses: actions/setup-node@v3
3030
with:
31-
node-version: '15.14.0'
31+
node-version: '16'
3232

3333
- name: install modules
3434
run: npm install
@@ -40,27 +40,21 @@ jobs:
4040
run: |
4141
git config --global user.email starzmisgod@gmail.com
4242
git config --global user.name meow.zang
43-
mkdir result
44-
mv css/ result/css/
45-
mv dist/ result/dist/
46-
mv images/ result/images/
47-
mv js/ result/js/
48-
mv index.html result/
49-
mv manifest.json result/
50-
mv options.html result/
43+
mv assets/ dist/assets/
44+
mv js/ dist/js/
45+
mv manifest.json dist/
46+
mv popup.html dist/
5147
git rm -r --cached .
52-
mv result/* ../*
53-
rm -rf result
54-
touch .gitignore && echo >> "node_modules/*"
55-
git add .gitignore
56-
git add css/*
48+
mv dist/* ../*
49+
rm -rf dist
5750
git add js/*
58-
git add images/*
59-
git add dist/*
60-
git add *.json
61-
git add *.html
51+
git add assets/*
52+
git add manifest.json
53+
git add index.html
54+
git add popup.html
55+
git add icon.png
6256
git commit -m "auto build from github workflow"
63-
git remote set-url origin https://zmisgod:${{secrets.ACCESS_TOKEN}}@github.com/zhimin-dev/chrome-extension.git
57+
git remote set-url origin https://zmisgod:${{secrets.ACCESS_TOKEN}}@github.com/zhimin-dev/iptv-checker.git
6458
git remote -v
6559
git checkout -b production
6660
git push origin HEAD:production --force

.gitignore

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
111
.DS_Store
2-
node_modules/
3-
npm-debug.log
4-
yarn-error.log
12+
dist
13+
dist-ssr
14+
*.local
15+
16+
/cypress/videos/
17+
/cypress/screenshots/
518

619
# Editor directories and files
20+
.vscode
21+
!.vscode/extensions.json
722
.idea
823
*.suo
924
*.ntvs*
1025
*.njsproj
1126
*.sln
27+
*.sw?
28+
dist

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
- it has some useful functions you will use it frequently
77
- you can add your custom script to some websites
88

9-
## environment
10-
11-
This project need node <= `15.14.0`, we recommend you use `15.14.0` to develop
12-
139
## Add your custom script
1410

1511
1. find `src/script/content/`folder

css/fonts/element-icons.ttf

-54.6 KB
Binary file not shown.

css/fonts/element-icons.woff

-27.5 KB
Binary file not shown.

css/index.css

-1
This file was deleted.

dist/build.js

-30
This file was deleted.

dist/build.js.map

-1
This file was deleted.

index.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<meta charset="utf-8">
5-
<title>zhimin chrome-extension</title>
6-
<link rel="stylesheet" href="css/index.css"/></head>
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" />
7+
<title>dev-tool</title>
78
</head>
89
<body>
910
<div id="app"></div>
10-
<script src="dist/build.js"></script>
11+
<script type="module" src="/src/main.js"></script>
1112
</body>
1213
</html>

js/background.js

+23-18
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
// 发送闹钟提醒
22
function noticeAlert(hour, minute) {
3-
chrome.storage.local.get(['noticeList'], (result) => {
3+
chrome.storage.local.get(["noticeList"], (result) => {
44
const res = result.noticeList;
5-
if (res !== undefined && res !== null && res !== '') {
5+
if (res !== undefined && res !== null && res !== "") {
66
try {
77
const rows = JSON.parse(res);
88
for (let i = 0; i < rows.length; i += 1) {
9-
if (parseInt(rows[i].hour, 10) === hour || parseInt(rows[i].hour, 10) === -1) {
9+
if (
10+
parseInt(rows[i].hour, 10) === hour ||
11+
parseInt(rows[i].hour, 10) === -1
12+
) {
1013
if (parseInt(rows[i].minute, 10) === minute) {
1114
chrome.notifications.create(null, {
12-
type: 'basic',
13-
iconUrl: './../images/icon.png',
14-
title: '知敏工具提醒您',
15+
type: "basic",
16+
iconUrl: "./../icon.png",
17+
title: "dev-tool提醒您",
1518
message: rows[i].remark,
1619
});
1720
}
@@ -35,7 +38,7 @@ chrome.alarms.onAlarm.addListener(() => {
3538
function request_proxy({ url, method, data }) {
3639
const XHR = new XMLHttpRequest();
3740
XHR.open(method, url);
38-
XHR.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
41+
XHR.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
3942
XHR.send(data);
4043
XHR.onreadystatechange = function () {
4144
if (XHR.readyState === 4) {
@@ -47,13 +50,13 @@ function request_proxy({ url, method, data }) {
4750
const wbSpiderConfig = {};
4851

4952
chrome.storage.onChanged.addListener((changes, namespace) => {
50-
console.log('change ======');
53+
console.log("change ======");
5154
for (const [key, { oldValue, newValue }] of Object.entries(changes)) {
52-
console.log('change key', key, newValue);
53-
if (key === 'wbSpider' || key === 'wbSpiderStart') {
54-
if (key === 'wbSpider') {
55+
console.log("change key", key, newValue);
56+
if (key === "wbSpider" || key === "wbSpiderStart") {
57+
if (key === "wbSpider") {
5558
wbSpiderConfig.url = newValue;
56-
} else if (key === 'wbSpiderStart') {
59+
} else if (key === "wbSpiderStart") {
5760
wbSpiderConfig.start = newValue;
5861
}
5962
}
@@ -62,17 +65,19 @@ chrome.storage.onChanged.addListener((changes, namespace) => {
6265
});
6366

6467
chrome.runtime.onMessage.addListener((data, sender, sendResponse) => {
65-
if (wbSpiderConfig.url !== '' && wbSpiderConfig.start) {
68+
console.log(data, wbSpiderConfig);
69+
if (wbSpiderConfig.url !== "" && wbSpiderConfig.start) {
6670
fetch(wbSpiderConfig.url, {
67-
method: 'POST',
71+
method: "POST",
6872
body: JSON.stringify(data),
6973
headers: {
70-
'Content-Type': 'application/json;charset=UTF-8',
74+
"Content-Type": "application/json;charset=UTF-8",
7175
},
72-
}).then((resp) => {
73-
console.log(resp);
74-
sendResponse({ code: 200 });
7576
})
77+
.then((resp) => {
78+
console.log(resp);
79+
sendResponse({ code: 200 });
80+
})
7681
.catch((err) => {
7782
console.log(err);
7883
sendResponse({ code: 500 });

js/build_package.js

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
const fs = require('fs');
1+
const fs = require("fs");
22

33
const ContentJs = {
44
getAllContentJs() {
5-
const readPath = './src/script/content/';
6-
const writeFileName = './js/content_script.js';
5+
const readPath = "./src/script/content/";
6+
const writeFileName = "./js/content_script.js";
77
fs.readdir(readPath, (err, files) => {
88
if (err) {
99
console.log(err);
1010
} else {
1111
const saveFileName = [];
1212
files.forEach((filename) => {
13-
const exp = filename.split('.js');
13+
const exp = filename.split(".js");
1414
if (exp.length >= 2) {
1515
saveFileName.push(filename);
1616
}
@@ -19,29 +19,34 @@ const ContentJs = {
1919
const nowHost = window.location.host;`;
2020
fs.writeFileSync(writeFileName, firstLine);
2121
for (let i = 0; i < saveFileName.length; i += 1) {
22-
const expUrl = saveFileName[i].split('.js');
23-
fs.appendFileSync(writeFileName, `
22+
const expUrl = saveFileName[i].split(".js");
23+
fs.appendFileSync(
24+
writeFileName,
25+
`
2426
if(nowHost === '${expUrl[0]}'){
25-
`);
27+
`
28+
);
2629
const fileInfo = fs.readFileSync(readPath + saveFileName[i]);
2730
fs.appendFileSync(writeFileName, String(fileInfo));
28-
fs.appendFileSync(writeFileName, '}');
31+
fs.appendFileSync(writeFileName, "}");
2932
}
3033
}
3134
});
3235
},
3336
moveElementUiCss() {
34-
const cssPath = './node_modules/element-ui/lib/theme-chalk/index.css';
35-
const desCssPath = './css/index.css';
37+
const cssPath = "./node_modules/element-ui/lib/theme-chalk/index.css";
38+
const desCssPath = "./css/index.css";
3639
fs.copyFile(cssPath, desCssPath, (err) => {
3740
if (err) {
3841
console.log(`copyFile ${cssPath} error${err}`);
3942
}
4043
});
4144

4245
const fontPath = {
43-
'./node_modules/element-ui/lib/theme-chalk/fonts/element-icons.woff': './css/fonts/element-icons.woff',
44-
'./node_modules/element-ui/lib/theme-chalk/fonts/element-icons.ttf': './css/fonts/element-icons.ttf',
46+
"./node_modules/element-ui/lib/theme-chalk/fonts/element-icons.woff":
47+
"./css/fonts/element-icons.woff",
48+
"./node_modules/element-ui/lib/theme-chalk/fonts/element-icons.ttf":
49+
"./css/fonts/element-icons.ttf",
4550
};
4651
for (const i in fontPath) {
4752
fs.copyFile(i, fontPath[i], (err) => {
@@ -53,7 +58,6 @@ if(nowHost === '${expUrl[0]}'){
5358
},
5459
generate() {
5560
this.getAllContentJs();
56-
this.moveElementUiCss();
5761
},
5862
};
5963
ContentJs.generate();

0 commit comments

Comments
 (0)