Skip to content

Commit

Permalink
feat: update v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OBKoro1 committed Apr 17, 2022
1 parent 8675937 commit 0fa6fc1
Show file tree
Hide file tree
Showing 37 changed files with 723 additions and 1,916 deletions.
1 change: 1 addition & 0 deletions .env.productionChrome
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VUE_APP_MODE=productionChrome
1 change: 1 addition & 0 deletions .env.productionEdge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VUE_APP_MODE=productionEdge
1 change: 1 addition & 0 deletions .env.productionFireFox
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VUE_APP_MODE=productionFireFox
1 change: 1 addition & 0 deletions .env.productionReleaseChrome
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VUE_APP_MODE=productionReleaseChrome
1 change: 1 addition & 0 deletions .env.productionReleaseEdge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VUE_APP_MODE=productionReleaseEdge
1 change: 1 addition & 0 deletions .env.productionReleaseFireFox
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VUE_APP_MODE=productionReleaseFireFox
1 change: 0 additions & 1 deletion .env.serve

This file was deleted.

1 change: 1 addition & 0 deletions .env.serveChrome
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VUE_APP_MODE=serveChrome
1 change: 1 addition & 0 deletions .env.serveFireFox
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VUE_APP_MODE=serveFireFox
9 changes: 8 additions & 1 deletion CHANNGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
[release](https://github.com/OBKoro1/stop-mess-around/releases)卸载重新安装。
[chrome商店更新](https://chrome.google.com/webstore/detail/stop-mess-around/gbjbkekbbjbieijpebieifkmahlagncm/related?hl=zh-CN)

<!-- TODO: 更新语录,更新读书笔记中的语录 -->
<!-- TODO: 文档示例图片和issue.md图片替换 -->
<!-- TODO: 摸鱼时间逻辑修改 -->

### [V2.0.0]
* BREAKING CHANGE: 破坏性更新, 插件兼容谷歌`Manifest V3`版本(否则明年将无法更新插件版本)导致数据重置,因为不能同步储存数据,只能储存在本地。
* feat: 增加插件数据与反馈问题相关功能
* fix: 修复统计摸鱼时间相关逻辑
* fix: 修复element-ui无法获取`.tff`字体文件的报错。

### [V1.3.0]

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ PS:我以前都是用`Octotree`文件树来查看代码的,现在感觉可

如果觉得这个效率工具还不错, 对你有所帮助,就赞助支持一下我的工作吧。

十块八块不嫌多,三块五块不嫌少 ❤️

<img src="https://raw.githubusercontent.com/OBKoro1/koro1FileHeader/dev/images/pay.jpg" alt="赞助" width="500px" style="display: block;"/>

### 我的其他开源推荐
Expand Down
19 changes: 13 additions & 6 deletions deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Author : OBKoro1
* Date : 2021-06-18 11:08:23
* LastEditors : OBKoro1
* LastEditTime : 2022-02-04 14:26:36
* LastEditTime : 2022-04-17 14:52:09
* FilePath : /stop-mess-around/deploy.js
* Description : 同步package.json的配置到manifest.json中
* koroFileheader插件
Expand All @@ -12,6 +12,10 @@
const path = require('path')
const fs = require('fs')

const { argv } = process
const env = argv[2]
const navigator = argv[3]

run()

function run() {
Expand All @@ -24,8 +28,14 @@ function elementFont() {
const elementPath = path.resolve(__dirname, './node_modules/element-ui/lib/theme-chalk/', 'index.css')
let content = fs.readFileSync(elementPath).toString()
// 替换匹配到的每个变量
const reg = /\(fonts\/element-icons\./g
content = content.replace(reg, '(chrome-extension://__MSG_@@extension_id__/fonts/element-icons.')
const reg = /url\(.*?fonts\/element-icons\./g
// !!! 删除fonts/element-icons.ttf好像没有作用 还会在content网站中报错
// 源字符: el-upload-list__item.is-success:not(.focusing):focus{outline-width:0}@font-face{font-family:element-icons;src:url(fonts/element-icons.woff) format("woff"),url(fonts/element-icons.ttf) format("truetype");font-weight:400;font-display:"auto";font-style:normal}[class*=" el-icon-"],
// 源字符: src:url(fonts/element-icons.woff)
// 更改为: src:url(chrome-extension://__MSG_@@extension_id__/fonts/element-icons.woff)
let navigatorName = 'chrome-extension'
if (navigator === 'fireFox') navigatorName = 'moz-extension'
content = content.replace(reg, `url(${navigatorName}://__MSG_@@extension_id__/fonts/element-icons.`)
fs.writeFileSync(elementPath, content)
}

Expand All @@ -35,9 +45,6 @@ function changeVersion() {
let DESCRIPTION = '减少摸鱼的时间和频率的Chrome插件:提醒你正在摸鱼,摸鱼的时候知道自己在摸鱼,提高我们上班和学习的效率,节省时间用于学习提升自己或者享受生活'
let PLUGINNAME = 'stop-mess-around'

const { argv } = process
const env = argv[2]

if (env !== 'production') {
PLUGINNAME = 'stop-mess-around-file'
DESCRIPTION = `file: ${DESCRIPTION}`
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stop-mess-around",
"description": "减少摸鱼的时间和频率的Chrome插件:提醒你正在摸鱼,摸鱼的时候知道自己在摸鱼,提高我们上班和学习的效率,节省时间用于学习提升自己或者享受生活",
"version": "1.3.0",
"version": "2.0.0",
"publisher": "OBKoro1",
"homepage": "https://github.com/OBKoro1/stop-mess-around",
"license": "MIT",
Expand All @@ -19,9 +19,14 @@
"email": "[email protected]"
},
"scripts": {
"serve": "node deploy.js development && vue-cli-service build-watch --mode serve",
"build-plugin": "node deploy.js production && vue-cli-service build",
"build-release": "node deploy.js development && vue-cli-service build --mode development",
"serve": "node deploy.js development && vue-cli-service build-watch --mode serveReleaseChrome",
"build-plugin": "node deploy.js production && vue-cli-service build --mode productionChrome",
"build-release": "node deploy.js development && vue-cli-service build --mode productionReleaseChrome",
"serve:fireFox": "node deploy.js development fireFox && vue-cli-service build-watch --mode serveReleaseFireFOX",
"build-plugin:Edg": "node deploy.js development && vue-cli-service build --mode productionEdge",
"build-release:Edg": "node deploy.js production && vue-cli-service build --mode productionReleaseEdge",
"build-plugin:fireFox": "node deploy.js production fireFox && vue-cli-service build --mode productionFireFox",
"build-release:fireFox": "node deploy.js development fireFox && vue-cli-service build --mode productionReleaseFireFox",
"lint": "eslint --ext .js,.vue src --fix",
"prepare": "husky install",
"analyze": "npm run build --report"
Expand Down
4 changes: 2 additions & 2 deletions src/background/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* Author : OBKoro1
* Date : 2021-06-04 10:39:57
* LastEditors : OBKoro1
* LastEditTime : 2022-01-12 12:51:11
* LastEditTime : 2022-04-10 21:48:03
* FilePath : /stop-mess-around/src/background/index.js
* Description : background常驻页面
* koroFileheader插件
* Copyright (c) ${now_year} by OBKoro1, All Rights Reserved.
*/
import { IntervalTaskInstance } from './intervalTask'
import { ListenerEventInstance } from './listernerEvent'
import { ListenerEventInstance } from './listenerEvent'

main()

Expand Down
13 changes: 10 additions & 3 deletions src/background/intervalTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Author : OBKoro1
* Date : 2022-01-10 14:06:01
* LastEditors : OBKoro1
* LastEditTime : 2022-01-12 12:57:07
* LastEditTime : 2022-04-16 17:00:34
* FilePath : /stop-mess-around/src/background/intervalTask.js
* description : 后台定时任务
* koroFileheader VSCode插件
Expand All @@ -24,7 +24,9 @@ class IntervalTask {
}, 3000)
}

// 查看数组默认元素是否有更新
/**
* @description: 查看数组默认元素是否有更新
*/
async updateItemPrototype() {
let change = false
const newList = this.listArr.map((item) => {
Expand All @@ -42,7 +44,9 @@ class IntervalTask {
}
}

// 自动打开
/**
* @description: 自动打开
*/
async autoOpen() {
const options = {
setting: this.setting,
Expand All @@ -55,6 +59,9 @@ class IntervalTask {
this.statisticsTime = statisticsTime
}

/**
* @description: 创建新一天的摸鱼统计数据
*/
async statisticsNewDayCheck() {
const options = {
setting: this.setting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Author : OBKoro1
* Date : 2022-01-10 17:55:00
* LastEditors : OBKoro1
* LastEditTime : 2022-01-12 13:01:22
* FilePath : /stop-mess-around/src/background/listernerEvent.js
* LastEditTime : 2022-04-17 14:40:42
* FilePath : /stop-mess-around/src/background/listenerEvent.js
* description : 后台监听事件通信
* koroFileheader VSCode插件
* Copyright (c) 2022 by OBKoro1, All Rights Reserved.
Expand All @@ -19,29 +19,37 @@ class ListenerEvent {

addListener() {
// 第一次安装
chrome.runtime.onInstalled.addListener(() => {
utils.jumpUrl(NET.OPTIONSPAGE)
chrome.runtime.onInstalled.addListener((res) => {
if (res.reason === chrome.runtime.OnInstalledReason.INSTALL) {
utils.jumpUrl(NET.OPTIONSPAGE)
}
})
// 关键词回调
chrome.omnibox.onInputEntered.addListener(() => {
utils.jumpUrl(NET.OPTIONSPAGE)
})
// content通知 background 关闭页面
chrome.extension.onRequest.addListener(async (request, sender, sendResponse) => {
console.log('content 消息: ', request, sender)
// 不能写async 返回值必须是布尔值
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
console.log('content 消息: ', request, sender, sendResponse)
const { id } = sender.tab
if (request.message === 'close-tab') {
const { id } = sender.tab
chrome.tabs.remove(id)
}
// 单个tab休息一下
if (request.message === 'reset-tab') {
await this.restTab(request, sendResponse)
this.restTab(request, sendResponse)
return true // 异步返回值
}
})
}

async restTab(request, sendResponse) {
({ setting: this.setting, statisticsTime: this.statisticsTime, listArr: this.listArr } = await utils.getData())
const res = await utils.getData()
this.setting = res.setting
this.statisticsTime = res.statisticsTime
this.listArr = res.listArr

const options = {
item: request.item,
tableArr: this.listArr,
Expand All @@ -53,7 +61,7 @@ class ListenerEvent {
// 网站检测关闭 更新数组
const index = this.listArr.findIndex((ele) => ele.site === request.item.site)
if (index === -1) return
this.listArr.splice(index, 1, request.item)
this.listArr.splice(index, 1, item)
await utils.updateStorageData(this.listArr, NET.TABLELIST)
sendResponse(JSON.stringify(item))
}
Expand Down
7 changes: 4 additions & 3 deletions src/background/statisticsNewDay.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Author : OBKoro1
* Date : 2022-01-10 15:45:28
* LastEditors : OBKoro1
* LastEditTime : 2022-01-12 14:53:21
* LastEditTime : 2022-04-17 20:23:04
* FilePath : /stop-mess-around/src/background/statisticsNewDay.js
* description : 超过十二点的统计数据初始化与摸鱼统计数据返还修正
* koroFileheader VSCode插件
Expand All @@ -22,7 +22,7 @@ export class StatisticsNewDay {

// 模拟数据时 删掉一个
async mock() {
// TODO: 比当前日期大的数据都删掉
// !!!!!!! 比当前日期大的数据都删掉
this.statisticsTime.shift()
await utils.updateStorageData(this.statisticsTime, NET.statisticsTime)
}
Expand Down Expand Up @@ -81,7 +81,8 @@ export class StatisticsNewDay {
isChange = true
const { openTime } = utils.getItemCloseCheckTime(item, this.setting)
const minutes = utils.getMoreDiff(openTime, Date.now(), true)
// 修复昨天的数据 修正开启时间与关闭时间
if (minutes === 0) continue // 0代表当前时间 超过打开时间不记录
// 修复昨天的数据 修正开启时间与关闭时间
this.listArr[index].closeTime = Date.now()
this.listArr[index].restTime = minutes
// 修正昨天的网站摸鱼时间
Expand Down
16 changes: 12 additions & 4 deletions src/content/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Author : OBKoro1
* Date : 2021-06-15 13:51:30
* LastEditors : OBKoro1
* LastEditTime : 2022-03-13 15:52:12
* LastEditTime : 2022-04-17 20:29:33
* FilePath : /stop-mess-around/src/content/App.vue
* Description : content 插入到页面的数据
* koroFileheader插件
Expand Down Expand Up @@ -118,6 +118,7 @@ export default {
totalMessAround: 0,
totalSiteMessAround: 0,
},
interVal: null,
}
},
async mounted() {
Expand All @@ -128,9 +129,14 @@ export default {
console.log('stop-mess-around(防摸鱼)插件 插入')
}
// 检测url变更
setInterval(this.run, 6000)
this.interVal = setInterval(this.run, 6000)
},
methods: {
async getCurrentTab() {
const queryOptions = { active: true, currentWindow: true }
const res = await chrome.tabs.query(queryOptions)
return res[0]
},
// 倒计时结束或者停止摸鱼再运行一遍
openAgain() {
this.run()
Expand Down Expand Up @@ -160,6 +166,7 @@ export default {
this.matchHandle()
} catch (err) {
console.log('stop-mess-around(防摸鱼)扩展更新了,请刷新页面')
clearInterval(this.interVal)
}
},
Expand Down Expand Up @@ -211,10 +218,11 @@ export default {
// 确定休息
restConfirm() {
const self = this // 传到class中 影响this指向
chrome.extension.sendRequest({ message: 'reset-tab', item: this.item, value: this.restTime }, (response) => {
chrome.runtime.sendMessage({ message: 'reset-tab', item: this.item, value: this.restTime }, (response) => {
self.dialogVisible = false
self.item = JSON.parse(response)
self.showRest = false
return true
})
},
// 更新提示
Expand All @@ -232,7 +240,7 @@ export default {
window.location.href = this.item.jumpUrl
} else {
// 关闭
chrome.extension.sendRequest({ message: 'close-tab' })
chrome.runtime.sendMessage({ message: 'close-tab' })
}
}, time * 1000)
},
Expand Down
54 changes: 0 additions & 54 deletions src/content/lookCode.js

This file was deleted.

Loading

0 comments on commit 0fa6fc1

Please sign in to comment.