From 0fa6fc1323faee4b640edba92bc9ba7b34d7e3ff Mon Sep 17 00:00:00 2001 From: OBKoro1 <1677593011@qq.com> Date: Sun, 17 Apr 2022 21:09:51 +0800 Subject: [PATCH] feat: update v2.0 --- .env.productionChrome | 1 + .env.productionEdge | 1 + .env.productionFireFox | 1 + .env.productionReleaseChrome | 1 + .env.productionReleaseEdge | 1 + .env.productionReleaseFireFox | 1 + .env.serve | 1 - .env.serveChrome | 1 + .env.serveFireFox | 1 + CHANNGELOG.md | 9 +- README.md | 2 + deploy.js | 19 +- package.json | 13 +- src/background/index.js | 4 +- src/background/intervalTask.js | 13 +- .../{listernerEvent.js => listenerEvent.js} | 28 +- src/background/statisticsNewDay.js | 7 +- src/content/App.vue | 16 +- src/content/lookCode.js | 54 - src/manifest.production.json | 24 +- src/manifest.template.json | 22 +- src/options/App/App.vue | 10 +- src/options/App/Header.vue | 10 +- src/options/App/settingPage/BatchItem.vue | 90 +- .../App/settingPage/ReplacePluginData.vue | 259 +++ src/options/App/settingPage/SetPage.vue | 26 +- src/options/App/settingPage/Setting.vue | 99 +- src/options/App/settingPage/serve.js | 1514 ----------------- src/options/App/settingPage/serve.vue | 83 - src/popup/App/popup.vue | 21 +- src/utils/allAction.js | 47 +- src/utils/closeCheck.js | 30 +- src/utils/index.js | 84 +- src/utils/net.js | 44 +- src/utils/openCheck.js | 19 +- static/development.md | 75 + vue.config.js | 8 +- 37 files changed, 723 insertions(+), 1916 deletions(-) create mode 100644 .env.productionChrome create mode 100644 .env.productionEdge create mode 100644 .env.productionFireFox create mode 100644 .env.productionReleaseChrome create mode 100644 .env.productionReleaseEdge create mode 100644 .env.productionReleaseFireFox delete mode 100644 .env.serve create mode 100644 .env.serveChrome create mode 100644 .env.serveFireFox rename src/background/{listernerEvent.js => listenerEvent.js} (64%) delete mode 100644 src/content/lookCode.js create mode 100644 src/options/App/settingPage/ReplacePluginData.vue delete mode 100644 src/options/App/settingPage/serve.js delete mode 100644 src/options/App/settingPage/serve.vue create mode 100644 static/development.md diff --git a/.env.productionChrome b/.env.productionChrome new file mode 100644 index 0000000..41d472b --- /dev/null +++ b/.env.productionChrome @@ -0,0 +1 @@ +VUE_APP_MODE=productionChrome diff --git a/.env.productionEdge b/.env.productionEdge new file mode 100644 index 0000000..daeb1bd --- /dev/null +++ b/.env.productionEdge @@ -0,0 +1 @@ +VUE_APP_MODE=productionEdge diff --git a/.env.productionFireFox b/.env.productionFireFox new file mode 100644 index 0000000..c2caf6d --- /dev/null +++ b/.env.productionFireFox @@ -0,0 +1 @@ +VUE_APP_MODE=productionFireFox diff --git a/.env.productionReleaseChrome b/.env.productionReleaseChrome new file mode 100644 index 0000000..0782afa --- /dev/null +++ b/.env.productionReleaseChrome @@ -0,0 +1 @@ +VUE_APP_MODE=productionReleaseChrome diff --git a/.env.productionReleaseEdge b/.env.productionReleaseEdge new file mode 100644 index 0000000..887809d --- /dev/null +++ b/.env.productionReleaseEdge @@ -0,0 +1 @@ +VUE_APP_MODE=productionReleaseEdge diff --git a/.env.productionReleaseFireFox b/.env.productionReleaseFireFox new file mode 100644 index 0000000..d2a2807 --- /dev/null +++ b/.env.productionReleaseFireFox @@ -0,0 +1 @@ +VUE_APP_MODE=productionReleaseFireFox diff --git a/.env.serve b/.env.serve deleted file mode 100644 index eb15a63..0000000 --- a/.env.serve +++ /dev/null @@ -1 +0,0 @@ -VUE_APP_MODE=serve diff --git a/.env.serveChrome b/.env.serveChrome new file mode 100644 index 0000000..330ef90 --- /dev/null +++ b/.env.serveChrome @@ -0,0 +1 @@ +VUE_APP_MODE=serveChrome diff --git a/.env.serveFireFox b/.env.serveFireFox new file mode 100644 index 0000000..1f15e12 --- /dev/null +++ b/.env.serveFireFox @@ -0,0 +1 @@ +VUE_APP_MODE=serveFireFox diff --git a/CHANNGELOG.md b/CHANNGELOG.md index a35c3f6..bcb014b 100644 --- a/CHANNGELOG.md +++ b/CHANNGELOG.md @@ -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) - + + + +### [V2.0.0] +* BREAKING CHANGE: 破坏性更新, 插件兼容谷歌`Manifest V3`版本(否则明年将无法更新插件版本)导致数据重置,因为不能同步储存数据,只能储存在本地。 +* feat: 增加插件数据与反馈问题相关功能 +* fix: 修复统计摸鱼时间相关逻辑 +* fix: 修复element-ui无法获取`.tff`字体文件的报错。 ### [V1.3.0] diff --git a/README.md b/README.md index 59e73ab..33c6cd6 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,8 @@ PS:我以前都是用`Octotree`文件树来查看代码的,现在感觉可 如果觉得这个效率工具还不错, 对你有所帮助,就赞助支持一下我的工作吧。 +十块八块不嫌多,三块五块不嫌少 ❤️ + 赞助 ### 我的其他开源推荐 diff --git a/deploy.js b/deploy.js index d7fab36..b7a9fa4 100644 --- a/deploy.js +++ b/deploy.js @@ -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插件 @@ -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() { @@ -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) } @@ -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}` diff --git a/package.json b/package.json index b4a4228..cd06567 100644 --- a/package.json +++ b/package.json @@ -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", @@ -19,9 +19,14 @@ "email": "obkoro1@foxmail.com" }, "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" diff --git a/src/background/index.js b/src/background/index.js index 33b129e..ea74b91 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -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() diff --git a/src/background/intervalTask.js b/src/background/intervalTask.js index 0cc7067..538da59 100644 --- a/src/background/intervalTask.js +++ b/src/background/intervalTask.js @@ -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插件 @@ -24,7 +24,9 @@ class IntervalTask { }, 3000) } - // 查看数组默认元素是否有更新 + /** + * @description: 查看数组默认元素是否有更新 + */ async updateItemPrototype() { let change = false const newList = this.listArr.map((item) => { @@ -42,7 +44,9 @@ class IntervalTask { } } - // 自动打开 + /** + * @description: 自动打开 + */ async autoOpen() { const options = { setting: this.setting, @@ -55,6 +59,9 @@ class IntervalTask { this.statisticsTime = statisticsTime } + /** + * @description: 创建新一天的摸鱼统计数据 + */ async statisticsNewDayCheck() { const options = { setting: this.setting, diff --git a/src/background/listernerEvent.js b/src/background/listenerEvent.js similarity index 64% rename from src/background/listernerEvent.js rename to src/background/listenerEvent.js index ce4be5d..09c2234 100644 --- a/src/background/listernerEvent.js +++ b/src/background/listenerEvent.js @@ -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. @@ -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, @@ -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)) } diff --git a/src/background/statisticsNewDay.js b/src/background/statisticsNewDay.js index a689984..a29dfb6 100644 --- a/src/background/statisticsNewDay.js +++ b/src/background/statisticsNewDay.js @@ -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插件 @@ -22,7 +22,7 @@ export class StatisticsNewDay { // 模拟数据时 删掉一个 async mock() { - // TODO: 比当前日期大的数据都删掉 + // !!!!!!! 比当前日期大的数据都删掉 this.statisticsTime.shift() await utils.updateStorageData(this.statisticsTime, NET.statisticsTime) } @@ -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 // 修正昨天的网站摸鱼时间 diff --git a/src/content/App.vue b/src/content/App.vue index 6a5548c..bbed9c4 100644 --- a/src/content/App.vue +++ b/src/content/App.vue @@ -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插件 @@ -118,6 +118,7 @@ export default { totalMessAround: 0, totalSiteMessAround: 0, }, + interVal: null, } }, async mounted() { @@ -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() @@ -160,6 +166,7 @@ export default { this.matchHandle() } catch (err) { console.log('stop-mess-around(防摸鱼)扩展更新了,请刷新页面') + clearInterval(this.interVal) } }, @@ -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 }) }, // 更新提示 @@ -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) }, diff --git a/src/content/lookCode.js b/src/content/lookCode.js deleted file mode 100644 index e7e0b39..0000000 --- a/src/content/lookCode.js +++ /dev/null @@ -1,54 +0,0 @@ -matchTest() -function matchTest() { - const matchArr = [ - 'https://github.com/OBKoro1/stop-mess-around', - 'https://github.com/OBKoro1/stop-mess-around/actions', - 'https://github.com/OBKoro1/stop-mess-around/wiki', - 'https://github.com/OBKoro1/stop-mess-around/blob/dev/src/content/App.vue', - 'https://github.com/OBKoro1/stop-mess-around/tree/master/src', - ] - for (const item of matchArr.values()) { - const reg = /^(https:\/\/github\.com\/([^/]+)\/([^/]+))\/?.*/ - const res = reg.exec(item) - if (res) { - const [, repoUrl, repoAuthor, repoName] = res - let newRepoUrl = repoUrl - // 是否为查看文件 或者 文件树 - const reg2 = /^(https:\/\/github\.com\/([^/]+)\/([^/]+))\/([^/]+)\/([^/]+)\/?.*/ - const res2 = reg2.exec(item) - const treeOrBlob = res2[4] - if (treeOrBlob && (treeOrBlob === 'blob' || treeOrBlob === 'tree')) { - newRepoUrl = matchBranch() // 修改为具体地址 - } - console.log('item', repoUrl, repoAuthor, repoName) - console.log('item', res2) - return newRepoUrl - } - } - // 匹配分支和具体的文件 - function matchBranch(repoUrl) { - const id = 'code-tab' - const constClassName = 'selected' - const githubCodeButton = document.querySelector(`#${id}`) - if (!githubCodeButton) return repoUrl - const hasClassName = hasClass(githubCodeButton, constClassName) - if (hasClassName) { - return window.location.href - } - return repoUrl - } - function hasClass(dom, className) { - if ('classList' in dom && typeof dom.classList.contains === 'function') { - return (elem) => elem.classList.contains(className) - } - return (elem) => { - const classes = elem.className.split(/\s+/) - for (const ele of classes.values()) { - if (ele === className) { - return true - } - } - return false - } - } -} diff --git a/src/manifest.production.json b/src/manifest.production.json index 91ad5e4..077e5ba 100644 --- a/src/manifest.production.json +++ b/src/manifest.production.json @@ -1,16 +1,16 @@ { - "manifest_version": 2, + "manifest_version": 3, "name": "stop-mess-around", - "version": "1.3.0", + "version": "2.0.0", "description": "减少摸鱼的时间和频率的Chrome插件:提醒你正在摸鱼,摸鱼的时候知道自己在摸鱼,提高我们上班和学习的效率,节省时间用于学习提升自己或者享受生活", "options_page": "options.html", "short_name": "StopMessAround", "author": "obkoro1@foxmail.com", "homepage_url": "https://github.com/OBKoro1/stop-mess-around", "background": { - "scripts": ["js/background.js"] + "service_worker": "background.js" }, - "browser_action": { + "action": { "default_icon": "img/48.png", "default_title": "减少摸鱼的时间和频率的Chrome插件:提醒你正在摸鱼,摸鱼的时候知道自己在摸鱼,提高我们上班和学习的效率,节省时间用于学习提升自己或者享受生活", "default_popup": "popup.html" @@ -20,18 +20,26 @@ "48": "img/48.png", "128": "img/48.png" }, - "permissions": ["tabs", "storage", "http://*/*", "https://*/*"], - "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", + "host_permissions": [""], + "permissions": ["tabs", "storage"], + "content_security_policy": { + "extension_pages": "script-src 'self'; object-src 'self';" + }, "content_scripts": [ { "matches": [""], "css": ["css/content.css"], - "js": ["js/content.js"], + "js": ["content.js"], "run_at": "document_end" } ], "omnibox": { "keyword": "stopmessaround" }, "offline_enabled": true, - "web_accessible_resources": ["fonts/*.*"], + "web_accessible_resources": [ + { + "resources": ["fonts/element-icons.tff", "fonts/element-icons.woff"], + "matches": ["", "https://juejin.cn/*"] + } + ], "default_locale": "zh_CN" } diff --git a/src/manifest.template.json b/src/manifest.template.json index 1029148..49ae568 100644 --- a/src/manifest.template.json +++ b/src/manifest.template.json @@ -1,5 +1,5 @@ { - "manifest_version": 2, + "manifest_version": 3, "name": "{{PLUGINNAME}}", "version": "{{VERSION}}", "description": "{{DESCRIPTION}}", @@ -8,9 +8,9 @@ "author": "obkoro1@foxmail.com", "homepage_url": "https://github.com/OBKoro1/stop-mess-around", "background": { - "scripts": ["js/background.js"] + "service_worker": "background.js" }, - "browser_action": { + "action": { "default_icon": "img/48.png", "default_title": "{{DESCRIPTION}}", "default_popup": "popup.html" @@ -20,18 +20,26 @@ "48": "img/48.png", "128": "img/48.png" }, - "permissions": ["tabs", "storage", "http://*/*", "https://*/*"], - "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", + "host_permissions": [""], + "permissions": ["tabs", "storage"], + "content_security_policy": { + "extension_pages": "script-src 'self'; object-src 'self';" + }, "content_scripts": [ { "matches": [""], "css": ["css/content.css"], - "js": ["js/content.js"], + "js": ["content.js"], "run_at": "document_end" } ], "omnibox": { "keyword": "stopmessaround" }, "offline_enabled": true, - "web_accessible_resources": ["fonts/*.*"], + "web_accessible_resources": [ + { + "resources": ["fonts/element-icons.tff", "fonts/element-icons.woff"], + "matches": ["", "https://juejin.cn/*"] + } + ], "default_locale": "zh_CN" } diff --git a/src/options/App/App.vue b/src/options/App/App.vue index 7fe8747..2bcfc33 100644 --- a/src/options/App/App.vue +++ b/src/options/App/App.vue @@ -61,14 +61,14 @@ export default { clearInterval(this.interval) }, methods: { - // 清楚数据 - clearSetting(type) { + // 清除数据 + async clearSetting(type) { if (type === 'clearList') { - this.utils.updateStorageData([], this.NET.TABLELIST) + await this.utils.updateStorageData([], this.NET.TABLELIST) } else if (type === 'clearSetting') { - this.utils.updateStorageData({}, this.NET.GLOBALSETTING) + await this.utils.updateStorageData({}, this.NET.GLOBALSETTING) } else if (type === 'statisticsTime') { - this.utils.updateStorageData([], this.NET.statisticsTime) + await this.utils.updateStorageData([], this.NET.statisticsTime) } this.initData() }, diff --git a/src/options/App/Header.vue b/src/options/App/Header.vue index d734f24..969df4e 100644 --- a/src/options/App/Header.vue +++ b/src/options/App/Header.vue @@ -15,7 +15,7 @@ v-if="development" class="cursor-pointer header-btns" @click="utils.jumpUrl(NET.CHROMESTORE)" - >本地安装,无法自动更新,跳转Chrome商店安装 + >本地安装,无法自动更新,跳转应用商店安装 如果觉得这个效率工具还不错,对你有所帮助,就赞助支持一下吧。 +
+ 十块八块不嫌多,三块五块不嫌少 ❤️ +
{ this.sponsorshipShow() diff --git a/src/options/App/settingPage/BatchItem.vue b/src/options/App/settingPage/BatchItem.vue index 1c498fb..5c2fef4 100644 --- a/src/options/App/settingPage/BatchItem.vue +++ b/src/options/App/settingPage/BatchItem.vue @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2021-05-28 16:02:26 * LastEditors : OBKoro1 - * LastEditTime : 2021-10-29 18:13:19 + * LastEditTime : 2022-04-17 17:22:20 * FilePath : /stop-mess-around/src/options/App/settingPage/BatchItem.vue * Description : 摸鱼列表 批量添加 * koroFileheader插件 @@ -19,39 +19,53 @@ > {{ '摸鱼网站列表添加' }} -
- +
- - - - - +
+
+ - - - + + + + + + + + +
{ + this.$emit('showCopyDataFn') + }) + }, close() { this.$emit('close', 'showBatchItem', false) }, @@ -139,7 +166,6 @@ export default { this.tableArr = this.getTableData() return arr.filter((item) => { const find = this.tableArr.find((ele) => item.site === ele.site) - console.log('find', find) return find === undefined }) }, diff --git a/src/options/App/settingPage/ReplacePluginData.vue b/src/options/App/settingPage/ReplacePluginData.vue new file mode 100644 index 0000000..fb6aa30 --- /dev/null +++ b/src/options/App/settingPage/ReplacePluginData.vue @@ -0,0 +1,259 @@ + + + + + + diff --git a/src/options/App/settingPage/SetPage.vue b/src/options/App/settingPage/SetPage.vue index 8eb5521..4b79c03 100644 --- a/src/options/App/settingPage/SetPage.vue +++ b/src/options/App/settingPage/SetPage.vue @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2021-05-25 14:24:51 * LastEditors : OBKoro1 - * LastEditTime : 2022-04-09 15:05:48 + * LastEditTime : 2022-04-17 20:36:53 * FilePath : /stop-mess-around/src/options/App/settingPage/SetPage.vue * Description : 设置按钮列表 * koroFileheader插件 @@ -64,12 +64,11 @@ - serve调试 + 插件数据和反馈问题相关 @@ -96,8 +97,9 @@ :show-statistics="showStatistics" @close="checkoutFn" /> - + @@ -109,7 +111,7 @@ import CreateItem from './CreateItem.vue' import Setting from './Setting.vue' import BatchItem from './BatchItem.vue' import RandomTip from './RandomTip.vue' -import ServeDebugger from './serve.vue' +import ReplacePluginData from './ReplacePluginData.vue' import RestStatistics from '../../../components/rest-statistics.vue' export default { @@ -121,7 +123,7 @@ export default { BatchItem, RandomTip, RestStatistics, - ServeDebugger, + ReplacePluginData, }, props: { open: { @@ -137,8 +139,7 @@ export default { showBatchItem: false, showTip: false, showStatistics: false, - showServeDialog: false, - serve: false, // 本地开发 + showPluginDataDialog: false, } }, computed: { @@ -147,9 +148,6 @@ export default { }, }, async mounted() { - if (process.env.VUE_APP_MODE === 'serve') { - this.serve = true - } // 没有数据 默认打开摸鱼网站列表 const { listArr } = await this.utils.getData() if (listArr.length === 0) { @@ -158,7 +156,6 @@ export default { }, methods: { search(val) { - console.log('search') this.$emit('searchChange', val) }, // 开关弹窗 @@ -202,5 +199,6 @@ export default { .search-input { width: 200px; margin-right: 15px; + margin-bottom: 15px; } diff --git a/src/options/App/settingPage/Setting.vue b/src/options/App/settingPage/Setting.vue index 2559ce0..6bb5583 100644 --- a/src/options/App/settingPage/Setting.vue +++ b/src/options/App/settingPage/Setting.vue @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2021-05-25 22:45:36 * LastEditors : OBKoro1 - * LastEditTime : 2022-03-13 18:01:04 + * LastEditTime : 2022-04-17 17:19:37 * FilePath : /stop-mess-around/src/options/App/settingPage/Setting.vue * Description : 全局设置 * koroFileheader插件 @@ -210,77 +210,22 @@ /> - - - - {{ '重置插件数据' }} - - - - - 清空摸鱼列表 - - - - - 重置设置 - - - - - 重置摸鱼统计 - - - - {{ '反馈问题' }} + {{ '插件数据与反馈' }} - 复制插件数据 - - - 跳转反馈问题 + 跳转插件数据与反馈问题相关 @@ -382,42 +327,18 @@ export default { }, }, methods: { - // 复制插件配置 去反馈问题 - async copyPluginData() { - const obj = await this.utils.getData() - const text = JSON.stringify(obj, null, 2) - if (navigator.clipboard) { - // clipboard api 复制 - navigator.clipboard.writeText(text) - } else { - const textarea = document.createElement('textarea') - document.body.appendChild(textarea) - // 隐藏此输入框 - textarea.style.position = 'fixed' - textarea.style.clip = 'rect(0 0 0 0)' - textarea.style.top = '10px' - // 赋值 - textarea.value = text - // 选中 - textarea.select() - // 复制 - document.execCommand('copy', true) - // 移除输入框 - document.body.removeChild(textarea) - } + jumpCopyPluginData() { + this.close() + this.$nextTick(() => { + this.$emit('showCopyDataFn') + }) }, close() { this.$emit('close', 'showSetting', false) }, resetFields(done) { - this.$refs.ruleForm.resetFields() done() }, - // 清空设置 - clearSetting(type) { - this.close() - this.initData(type) - }, confirmFn() { this.$refs.ruleForm.validate((valid) => { if (valid) { diff --git a/src/options/App/settingPage/serve.js b/src/options/App/settingPage/serve.js deleted file mode 100644 index bfa390f..0000000 --- a/src/options/App/settingPage/serve.js +++ /dev/null @@ -1,1514 +0,0 @@ -// 原先数据 -export const origin = { - setting: { - log: false, - open: true, - time: 2, - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - checkoutStudy: 30, - sponsorshipTime: 1649484772806, - defaultList: [ - { - site: 'https://www.douyu.com/', - labelName: '斗鱼直播', - }, - { - site: 'https://www.huya.com/', - labelName: '虎牙直播', - }, - { - site: 'https://juejin.cn/pins', - labelName: '掘金沸点', - }, - { - site: 'https://www.zhihu.com/', - labelName: '知乎首页', - matchRule: 'strict', - }, - { - site: 'https://www.zhihu.com/hot', - labelName: '知乎热榜', - }, - { - site: 'https://www.bilibili.com/', - labelName: 'B站', - }, - { - site: 'https://weibo.com/', - labelName: '微博', - }, - { - site: 'https://www.v2ex.com/', - labelName: 'V2ex论坛', - }, - { - site: 'https://live.qq.com/', - labelName: '企鹅直播', - }, - { - site: 'http://www.taobao.com/', - labelName: '淘宝网', - }, - { - site: 'https://www.jd.com/', - labelName: '京东', - }, - { - site: 'https://www.hupu.com/', - labelName: '虎扑', - }, - { - site: 'https://top.baidu.com/', - labelName: '百度热搜', - }, - { - site: 'https://v.douyu.com/', - labelName: '斗鱼录播', - }, - { - site: 'https://v.huya.com/', - labelName: '虎牙录播', - }, - ], - titleArr: [ - '停止下意识的摸鱼', - '别浪费时间了', - '积累的力量', - '日拱一卒,功不唐捐', - '愚公移山的坚持', - '笨鸟先飞的觉悟', - '聚焦目标', - '千里之行,始于足下', - '天道酬勤', - '不经历风雨,怎能见彩虹?', - '不经一番寒彻骨,怎得梅花扑鼻香?', - '玉不琢,不成器', - '日积月累', - '没有所谓的天才', - ], - confirmArr: [ - '冲他妈的', - '冲冲冲', - '卷起来', - '卷他妈的', - '再卷一会儿', - '接着卷', - '继续卷', - '自强不息', - '日积月累', - '聚沙成塔', - '日拱一卒', - '科学的投入', - '适当的休息', - ], - matchRule: 'start', - tipArr: [ - '刻意练习的四要素,定义明确的目标,极度的专注,有效的反馈,在拉伸区练习。', - '最好是形成一个知识体系,需要自己沉淀出思维框架,可以逐步提高快速的学习与解决问题的能力', - '识别高收益,长半衰期的知识。不断加深自己的核心竞争力和不可替代性。', - '专注的力量非常重要, 选择合适的目标,有所为,有所不为.\n巴菲特的双目标清单: \n巴菲特让朋友圈出职业生涯最重要的20个目标,然后又让他圈出最重要的五个目标。然后告诉他要全力去做五个目标,像躲避瘟疫一样去躲避另外的十五个目标。', - '番茄工作法,累了就适当休息,管理好你的精力。', - '有时候你需要适当休息, 试试番茄工作法,太过用力容易导致自我损伤,如果你太过强迫自己去做某件事,就会不断内耗很难长久的坚持下去。', - '如果想要在某个领域做的出色,就必须对它有强烈的兴趣', - '模仿最优秀人的人生哲学,你也会更容易接近成功', - '不要让闲扯淡的人,打扰到做正事的人。', - '多做重要而不紧急的事情, 合理规划时间成为一个从容的人。', - '一个人时间用在哪儿,成就就在哪儿。', - '用进废退: 只有练习才能精进,对于技能树的点击要有所取舍', - '目标要定在月亮之上,\n即使失败,\n也可以落在众星之间。', - '目标感非常重要,理清你做事情的方法和路径,为了什么东西去努力。', - '人们总会高估自己短期的能力,而低估自己长期的能力。', - '或许每个优秀的人,都有一段沉默的时光。\n在这段时光里付出了很多努力,却得不到想要的结果。\n我们把它叫做扎根。', - '自古以来学有建树的人,都离不开一个“苦”字。', - '日拱一卒,功不唐捐。', - '我从来不认为半小时是微不足道的一段时间 - 达尔文', - '留下来的经典书籍都是最优秀的人的智慧结晶,想想自己何德何能能与世界最聪明最优秀的人聊天学习,读书就是让你可以轻易的与他们聊天学习,这就是所谓的站在巨人的肩膀上.', - '读书能让人以最低的成本,去培养眼界和格局。', - '习惯的力量,好的习惯事半功倍,坏的习惯纠正起来非常难', - '一身行囊离开的时候,除了一些积蓄,\n就是你的经历,你的态度,你的身体,还有,你的技术。', - '人在生活中可能会遭到沉重的打击,每一次不幸都是吸取教训的良机。', - '成功只有一种,按照自己的方式,去度过人生', - '人生是一场马拉松, 一个人一辈子,只要做好一件事就可以了', - '每天都做那件有意义的事,做的天数多了,人生就有意义了。', - '不怕苦,苦半辈子;\n怕苦,苦一辈子。', - '失败只有一种,那就是放弃努力, 半途而废。', - '种一棵树最好的时间是在十年前, \n其次就是现在了。', - '能不能实现目标,取决于你有多想实现它', - '心流状态:心流是一种将大脑毫不费力的集中起来的状态,这种状态下可以使人忘却时间的概念, 这是一种极度专注的状态。', - '不吃读书的苦,你就要吃生活的苦,读书是为了让你少吃苦。', - '你总觉得还有时间,这就是问题所在。', - '各行各业最优秀的人才每一个都拥有持续阅读,持续学习的习惯,这才是成功的秘诀。', - '获得某件你想要的东西,最可靠的方法是让自己配得上他。', - '生活由许许多多小的选择组成,\n每个选择都倾向于舒服的,\n最终将一事无成。', - '25~35岁,是每个人最宝贵的时光,应该用在刀刃上。', - '坚持做自己懒得做但正确的事情,\n就能得到别人想得到却得不到的东西。', - '要想翻过一堵墙,最好的办法是先把帽子扔过去。', - '学历代表过去、能力代表现在、学习力代表未来。', - '三延四拖,你就是时间的小偷。', - '胜利者往往是以坚持最后五分钟的时间中得来成功 - 牛顿', - '明日复明日,明日何其多。\n日日传明日,万事成蹉跎。\n世人皆被明日累,明日无穷老将至。\n晨昏滚滚水东流,今古悠悠日西坠。\n百年明日能几何,请君听我明日歌。', - '百金买骏马,\n千金买美人,\n万金买高爵,\n何处买青春?\n', - '花有重开日,人无再少年。', - '泰山不让土壤,故能成其大;\n江海不择细流,故能就其深。', - '九层之台,起于累士。', - '不问收获,但问耕耘,天道酬勤!', - '忙于采集的蜜蜂,无暇在人前高谈阔论。', - '一寸光阴一寸金,寸金难买寸光阴。', - '勤奋的人是时间的主人,懒惰的人是时间的奴隶。', - '黑发不知勤学早,白首方悔读书迟。', - '形成天才的决定因素应该是勤奋。', - '少壮不努力,老大徒伤悲。', - '勤奋和智慧是双胞胎,懒惰和愚蠢是亲兄弟。', - '天行健,君子以自强不息。', - '玉不琢,不成器;\n木不雕,不成材;\n人不学,不知理。', - '不经一番寒彻骨,怎得梅花扑鼻香?', - '笨鸟先飞的觉悟, 愚公移山的坚持。', - '不积跬步,无以至千里;不积小流,无以成江海。', - '合抱之木,生于毫末;\n百丈之台,起于累土;\n千里之行,始于足下。', - '再长的路,一步步也能走完。\n再短的路,不迈开双脚也无法到达。', - '宝剑锋从磨砺出 梅花香自苦寒来', - '日日行,不怕千万里;常常做,不怕千万事。', - '路漫漫其修道远,吾将上下而求索。', - '质变都来自于量变的积累', - '书山有路勤为径,学海无涯苦作舟。', - '世上无难事,只要肯登攀。', - '勤能补拙是良训,一分耕耘一分才。', - '不经历风雨,怎能见彩虹?', - '业精于勤而荒于嬉,行成于思而毁于随。', - ], - addSite: '', - todayGlobalTouchFish: 0, - defaultNum: { - defaultList: 15, - titleArr: 14, - confirmArr: 13, - tipArr: 72, - }, - showRightTip: 'open', - lookCode: 'github1s.com', - restTime: 0, - globalSiteTouchFish: false, - closeTime: 0, - }, - statisticsTime: [ - { - time: 0, - restSite: [], - date: '2022-04-09', - }, - ], - listArr: [ - { - site: 'https://www.jd.com/', - labelName: '京东', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.huya.com/', - labelName: '虎牙直播', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.hupu.com/', - labelName: '虎扑', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.douyu.com/', - labelName: '斗鱼直播', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://juejin.cn/pins', - labelName: '掘金沸点', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://live.qq.com/', - labelName: '企鹅直播', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.v2ex.com/', - labelName: 'V2ex论坛', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://v.huya.com/', - labelName: '虎牙录播', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://top.baidu.com/', - labelName: '百度热搜', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.zhihu.com/', - labelName: '知乎首页', - matchRule: 'strict', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.bilibili.com/', - labelName: 'B站', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'http://www.taobao.com/', - labelName: '淘宝网', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.zhihu.com/hot', - labelName: '知乎热榜', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://weibo.com/', - labelName: '微博', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://v.douyu.com/', - labelName: '斗鱼录播', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - ], -} - -// 错误数据 -export const errData = { - setting: { - log: false, - open: true, - time: 5, - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - checkoutStudy: 30, - closeTime: 0, - sponsorshipTime: 1649320673652, - defaultList: [ - { - site: 'https://www.douyu.com/', - labelName: '斗鱼直播', - }, - { - site: 'https://www.huya.com/', - labelName: '虎牙直播', - }, - { - site: 'https://juejin.cn/pins', - labelName: '掘金沸点', - }, - { - site: 'https://www.zhihu.com/', - labelName: '知乎首页', - matchRule: 'strict', - }, - { - site: 'https://www.zhihu.com/hot', - labelName: '知乎热榜', - }, - { - site: 'https://www.bilibili.com/', - labelName: 'B站', - }, - { - site: 'https://weibo.com/', - labelName: '微博', - }, - { - site: 'https://www.v2ex.com/', - labelName: 'V2ex论坛', - }, - { - site: 'https://live.qq.com/', - labelName: '企鹅直播', - }, - { - site: 'http://www.taobao.com/', - labelName: '淘宝网', - }, - { - site: 'https://www.jd.com/', - labelName: '京东', - }, - { - site: 'https://www.hupu.com/', - labelName: '虎扑', - }, - { - site: 'https://top.baidu.com/', - labelName: '百度热搜', - }, - { - site: 'https://v.douyu.com/', - labelName: '斗鱼录播', - }, - { - site: 'https://v.huya.com/', - labelName: '虎牙录播', - }, - ], - titleArr: [ - '停止下意识的摸鱼', - '别浪费时间了', - '积累的力量', - '日拱一卒,功不唐捐', - '愚公移山的坚持', - '笨鸟先飞的觉悟', - '聚焦目标', - '千里之行,始于足下', - '天道酬勤', - '不经历风雨,怎能见彩虹?', - '不经一番寒彻骨,怎得梅花扑鼻香?', - '玉不琢,不成器', - '日积月累', - '没有所谓的天才', - ], - confirmArr: [ - '冲他妈的', - '冲冲冲', - '卷起来', - '卷他妈的', - '再卷一会儿', - '接着卷', - '继续卷', - '自强不息', - '日积月累', - '聚沙成塔', - '日拱一卒', - '科学的投入', - '适当的休息', - ], - matchRule: 'start', - tipArr: [ - '种一棵树最好的时间是在十年前, 其次就是现在了。', - '日拱一卒,功不唐捐。', - '人们总会高估自己短期的能力,而低估自己长期的能力。', - '笨鸟先飞的觉悟, 愚公移山的坚持。', - '早起的鸟儿有虫吃。', - '好好学习,天天向上。', - '不积跬步,无以至千里;不积小流,无以成江海。——《荀子》', - '合抱之木,生于毫末;百丈之台,起于累土;千里之行,始于足下。——《老子》', - '再长的路,一步步也能走完,再短的路,不迈开双脚也无法到达。', - '宝剑锋从磨砺出 梅花香自苦寒来', - '日日行,不怕千万里;常常做,不怕千万事。', - '路漫漫其修道远,吾将上下而求索 - 屈原', - '累了,就出去活动一下身体,或者闭眼休息一下,回来接着干。', - '质变都来自于量变的积累', - '书山有路勤为径,学海无涯苦作舟。', - '世上无难事,只要肯登攀。', - '勤能补拙是良训,一分耕耘一分才。', - '不经历风雨,怎能见彩虹?', - '业精于勤而荒于嬉,行成于思而毁于随。——韩愈', - '自古以来学有建树的人,都离不开一个“苦”字。', - '勤奋的人是时间的主人,懒惰的人是时间的奴隶。', - '黑发不知勤学早,白首方悔读书迟。——颜真卿', - '形成天才的决定因素应该是勤奋。——郭沫若', - '少壮不努力,老大徒伤悲。', - '勤奋和智慧是双胞胎,懒惰和愚蠢是亲兄弟。', - '天行健,君子以自强不息。', - '玉不琢,不成器;木不雕,不成材;人不学,不知理。', - '不经一番寒彻骨,怎得梅花扑鼻香?', - '一寸光阴一寸金,寸金难买寸光阴。', - '忙于采集的蜜蜂,无暇在人前高谈阔论。', - '九层之台,起于累士。', - '泰山不让土壤,故能成其大;江海不择细流,故能就其深。 李斯', - '不问收获,但问耕耘,天道酬勤!', - '花有重开日,人无再少年 - 关汉卿', - '百金买骏马,千金买美人,万金买高爵,何处买青春?- 屈原', - '胜利者往往是以坚持最后五分钟的时间中得来成功 - 牛顿', - '我从来不认为半小时是微不足道的一段时间 - 达尔文', - '三延四拖,你就是时间的小偷。', - '明日复明日,明日何其多。日日传明日,万事成蹉跎。世人皆被明日累,明日无穷老将至。晨昏滚滚水东流,今古悠悠日西坠。百年明日能几何,请君听我明日歌。- 文嘉', - '多做重要而不紧急的事情, 合理规划时间成为一个从容的人。', - '不怕苦,苦半辈子;怕苦,苦一辈子。 - 李敖', - '失败只有一种,那就是放弃努力, 半途而废。', - '目标定在月亮之上,即使失败,也可以落在众星之间。', - '学历代表过去、能力代表现在、学习力代表未来。', - '坚持做自己懒得做但正确的事情,就能得到别人想得到却得不到的东西。', - '一个人时间用在哪儿,成就就在哪儿。', - '要想翻过一堵墙,最好的办法是先把帽子扔过去。', - '一身行囊离开的时候,除了一些积蓄,就是你的经历,你的态度,你的身体,还有,你的技术。', - '25~35岁,是每个人最宝贵的时光,应该用在刀刃上。', - '每天都做那件有意义的事,做的天数多了,人生就有意义了。', - '识别高收益,长半衰期的知识。', - '生活由许许多多小的选择组成,每个选择都倾向于舒服的,最终将一事无成。', - '黑发不知勤学早,白首方悔读书迟。', - '形成天才的决定因素应该是勤奋。', - '少壮不努力,老大徒伤悲。', - '勤奋和智慧是双胞胎,懒惰和愚蠢是亲兄弟。', - '天行健,君子以自强不息。', - '玉不琢,不成器;\n木不雕,不成材;\n人不学,不知理。', - '不经一番寒彻骨,怎得梅花扑鼻香?', - '笨鸟先飞的觉悟, 愚公移山的坚持。', - '不积跬步,无以至千里;不积小流,无以成江海。', - '合抱之木,生于毫末;\n百丈之台,起于累土;\n千里之行,始于足下。', - '再长的路,一步步也能走完。\n再短的路,不迈开双脚也无法到达。', - '宝剑锋从磨砺出 梅花香自苦寒来', - '日日行,不怕千万里;常常做,不怕千万事。', - '路漫漫其修道远,吾将上下而求索。', - '质变都来自于量变的积累', - '书山有路勤为径,学海无涯苦作舟。', - '世上无难事,只要肯登攀。', - '勤能补拙是良训,一分耕耘一分才。', - '不经历风雨,怎能见彩虹?', - '业精于勤而荒于嬉,行成于思而毁于随。', - ], - addSite: '', - defaultNum: { - defaultList: 15, - titleArr: 14, - confirmArr: 13, - tipArr: 72, - }, - todayGlobalTouchFish: 1649063118291, - showRightTip: 'open', - lookCode: 'github1s.com', - restTime: 0, - globalSiteTouchFish: false, - }, - statisticsTime: [ - { - time: -463191, - restSite: [], - date: '2022-03-31', - }, - { - time: 5, - restSite: [ - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '知乎热榜', - site: 'https://www.zhihu.com/hot', - }, - ], - date: '2022-03-30', - }, - { - time: 50, - restSite: [ - { - time: 45, - restBtnClick: [ - { - time: 45, - count: 1, - }, - ], - labelName: 'B站', - site: 'https://www.bilibili.com/', - }, - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '知乎热榜', - site: 'https://www.zhihu.com/hot', - }, - ], - date: '2022-03-29', - }, - { - time: 15, - restSite: [ - { - time: 15, - restBtnClick: [ - { - time: 15, - count: 1, - }, - ], - labelName: '知乎热榜', - site: 'https://www.zhihu.com/hot', - }, - ], - date: '2022-03-28', - }, - { - time: 0, - restSite: [], - date: '2022-03-27', - }, - { - time: 65, - restSite: [ - { - time: 65, - restBtnClick: [ - { - time: 5, - count: 1, - }, - { - time: 60, - count: 1, - }, - ], - labelName: '虎牙直播', - site: 'https://www.huya.com/', - }, - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '虎牙录播', - site: 'https://v.huya.com/', - }, - ], - date: '2022-03-26', - }, - { - time: 0, - restSite: [], - date: '2022-03-25', - }, - { - time: 0, - restSite: [], - date: '2022-03-24', - }, - { - time: 6, - restSite: [ - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '虎牙直播', - site: 'https://www.huya.com/', - }, - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '虎牙录播', - site: 'https://v.huya.com/', - }, - ], - date: '2022-03-23', - }, - { - time: 0, - restSite: [], - date: '2022-03-22', - }, - { - time: 30, - restSite: [ - { - time: 20, - restBtnClick: [ - { - time: 20, - count: 1, - }, - ], - labelName: '知乎热榜', - site: 'https://www.zhihu.com/hot', - }, - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '知乎首页', - site: 'https://www.zhihu.com/', - }, - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: 'B站', - site: 'https://www.bilibili.com/', - }, - ], - date: '2022-03-21', - }, - { - time: 0, - restSite: [], - date: '2022-03-20', - }, - { - time: 150, - restSite: [ - { - time: 145, - restBtnClick: [ - { - time: 25, - count: 1, - }, - { - time: 120, - count: 1, - }, - ], - labelName: '虎牙录播', - site: 'https://v.huya.com/', - }, - { - time: 10, - restBtnClick: [ - { - time: 5, - count: 2, - }, - ], - labelName: '虎牙直播', - site: 'https://www.huya.com/', - }, - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '知乎首页', - site: 'https://www.zhihu.com/', - }, - ], - date: '2022-03-19', - }, - { - time: 0, - restSite: [], - date: '2022-03-18', - }, - { - time: 25, - restSite: [ - { - time: 25, - restBtnClick: [ - { - time: 25, - count: 1, - }, - ], - labelName: '知乎首页', - site: 'https://www.zhihu.com/', - }, - { - time: 25, - restBtnClick: [ - { - time: 25, - count: 1, - }, - ], - labelName: '知乎热榜', - site: 'https://www.zhihu.com/hot', - }, - ], - date: '2022-03-17', - }, - { - time: 0, - restSite: [], - date: '2022-03-16', - }, - { - time: 10, - restSite: [ - { - time: 10, - restBtnClick: [ - { - time: 5, - count: 2, - }, - ], - labelName: '虎牙直播', - site: 'https://www.huya.com/', - }, - ], - date: '2022-03-12', - }, - { - time: 0, - restSite: [], - date: '2022-03-11', - }, - { - time: 0, - restSite: [], - date: '2022-03-10', - }, - { - time: 0, - restSite: [], - date: '2022-03-09', - }, - { - time: 10, - restSite: [ - { - time: 10, - restBtnClick: [ - { - time: 5, - count: 2, - }, - ], - labelName: '掘金沸点', - site: 'https://juejin.cn/pins', - }, - ], - date: '2022-03-08', - }, - { - time: 1, - restSite: [ - { - time: 1, - restBtnClick: [ - { - time: 10, - count: 1, - }, - ], - labelName: '知乎首页', - site: 'https://www.zhihu.com/', - }, - ], - date: '2022-03-07', - }, - { - time: 5, - restSite: [ - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '虎牙直播', - site: 'https://www.huya.com/', - }, - ], - date: '2022-03-06', - }, - { - time: 0, - restSite: [], - date: '2022-03-05', - }, - { - time: 5, - restSite: [ - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '知乎首页', - site: 'https://www.zhihu.com/', - }, - ], - date: '2022-03-04', - }, - { - time: 0, - restSite: [], - date: '2022-03-03', - }, - { - time: 0, - restSite: [], - date: '2022-03-02', - }, - { - time: 0, - restSite: [], - date: '2022-03-01', - }, - { - time: 5, - restSite: [ - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '知乎首页', - site: 'https://www.zhihu.com/', - }, - ], - date: '2022-02-28', - }, - { - time: 11, - restSite: [ - { - time: 11, - restBtnClick: [ - { - time: 5, - count: 2, - }, - ], - labelName: '虎牙直播', - site: 'https://www.huya.com/', - }, - ], - date: '2022-02-27', - }, - { - time: 0, - restSite: [], - date: '2022-02-26', - }, - { - time: 0, - restSite: [], - date: '2022-02-25', - }, - { - time: 0, - restSite: [], - date: '2022-02-23', - }, - { - time: 0, - restSite: [], - date: '2022-02-22', - }, - { - time: 0, - restSite: [], - date: '2022-02-21', - }, - { - time: 5, - restSite: [ - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '知乎首页', - site: 'https://www.zhihu.com/', - }, - ], - date: '2022-02-20', - }, - { - time: 0, - restSite: [], - date: '2022-02-19', - }, - { - time: 0, - restSite: [], - date: '2022-02-18', - }, - { - time: 0, - restSite: [], - date: '2022-02-17', - }, - { - time: 0, - restSite: [], - date: '2022-02-16', - }, - { - time: 0, - restSite: [], - date: '2022-02-15', - }, - { - time: 0, - restSite: [], - date: '2022-02-11', - }, - { - time: 5, - restSite: [ - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '知乎首页', - site: 'https://www.zhihu.com/', - }, - ], - date: '2022-02-10', - }, - { - time: 0, - restSite: [], - date: '2022-02-09', - }, - { - time: 0, - restSite: [], - date: '2022-02-08', - }, - { - time: 0, - restSite: [], - date: '2022-02-07', - }, - { - time: 0, - restSite: [], - date: '2022-02-06', - }, - { - time: 0, - restSite: [], - date: '2022-02-05', - }, - { - time: 0, - restSite: [], - date: '2022-02-04', - }, - { - time: 0, - restSite: [], - date: '2022-02-03', - }, - { - time: 0, - restSite: [], - date: '2022-02-02', - }, - { - time: 0, - restSite: [], - date: '2022-02-01', - }, - { - time: 0, - restSite: [], - date: '2022-01-31', - }, - { - time: 15, - restSite: [ - { - time: 15, - restBtnClick: [ - { - time: 15, - count: 1, - }, - ], - labelName: 'B站', - site: 'https://www.bilibili.com/', - }, - ], - date: '2022-01-30', - }, - { - time: 0, - restSite: [], - date: '2022-01-29', - }, - { - time: 0, - restSite: [], - date: '2022-01-28', - }, - { - time: 10, - restSite: [ - { - time: 10, - restBtnClick: [ - { - time: 5, - count: 2, - }, - ], - labelName: '虎牙直播', - site: 'https://www.huya.com/', - }, - ], - date: '2022-01-27', - }, - { - time: 0, - restSite: [], - date: '2022-01-26', - }, - { - time: 0, - restSite: [], - date: '2022-01-25', - }, - { - time: 35, - restSite: [ - { - time: 35, - restBtnClick: [ - { - time: 5, - count: 1, - }, - { - time: 15, - count: 2, - }, - ], - labelName: '虎牙直播', - site: 'https://www.huya.com/', - }, - ], - date: '2022-01-24', - }, - { - time: 5, - restSite: [ - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '掘金沸点', - site: 'https://juejin.cn/pins', - }, - ], - date: '2022-01-23', - }, - { - time: 0, - restSite: [], - date: '2022-01-22', - }, - { - time: 5, - restSite: [ - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '虎牙直播', - site: 'https://www.huya.com/', - }, - ], - date: '2022-01-21', - }, - { - time: 0, - restSite: [], - date: '2022-01-20', - }, - { - time: 15, - restSite: [ - { - time: 15, - restBtnClick: [ - { - time: 15, - count: 1, - }, - ], - labelName: 'V2ex论坛', - site: 'https://www.v2ex.com/', - }, - ], - date: '2022-01-19', - }, - { - time: 49, - restSite: [ - { - time: 30, - restBtnClick: [ - { - time: 5, - count: 3, - }, - { - time: 15, - count: 1, - }, - ], - labelName: '掘金沸点', - site: 'https://juejin.cn/pins', - }, - { - time: 15, - restBtnClick: [ - { - time: 5, - count: 1, - }, - { - time: 10, - count: 1, - }, - ], - labelName: 'V2ex论坛', - site: 'https://www.v2ex.com/', - }, - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '知乎热榜', - site: 'https://www.zhihu.com/hot', - }, - ], - date: '2022-01-18', - }, - { - time: 20, - restSite: [ - { - time: 15, - restBtnClick: [ - { - time: 15, - count: 1, - }, - ], - labelName: 'V2ex论坛', - site: 'https://www.v2ex.com/', - }, - { - time: 5, - restBtnClick: [ - { - time: 5, - count: 1, - }, - ], - labelName: '知乎热榜', - site: 'https://www.zhihu.com/hot', - }, - ], - date: '2022-01-17', - }, - ], - listArr: [ - { - site: 'https://www.zhihu.com/hot', - labelName: '知乎热榜', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: false, - closeTime: 1648693131622, - checkoutStudy: 10, - globalSiteTouchFish: false, - restTime: 20, - }, - { - site: 'https://weibo.com/', - labelName: '微博', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.douyu.com/', - labelName: '斗鱼直播', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: false, - closeTime: 1649062818291, - checkoutStudy: 45, - globalSiteTouchFish: false, - restTime: 5, - }, - { - site: 'http://www.taobao.com/', - labelName: '淘宝网', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.bilibili.com/', - labelName: 'B站', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.zhihu.com/', - labelName: '知乎首页', - matchRule: 'strict', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - checkoutStudy: 15, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://top.baidu.com/', - labelName: '百度热搜', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.huya.com/', - labelName: '虎牙直播', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: false, - closeTime: 1648809357686, - globalSiteTouchFish: false, - restTime: 5, - }, - { - site: 'https://live.qq.com/', - labelName: '企鹅直播', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.v2ex.com/', - labelName: 'V2ex论坛', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - checkoutStudy: 15, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.jd.com/', - labelName: '京东', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - checkoutStudy: 120, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://juejin.cn/pins', - labelName: '掘金沸点', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - checkoutStudy: 20, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://www.hupu.com/', - labelName: '虎扑', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: true, - closeTime: 0, - globalSiteTouchFish: false, - restTime: 0, - }, - { - site: 'https://v.douyu.com/', - labelName: '斗鱼录播', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: false, - closeTime: 1649063243695, - globalSiteTouchFish: false, - restTime: 5, - }, - { - site: 'https://v.huya.com/', - labelName: '虎牙录播', - matchRule: 'start', - jump: false, - jumpUrl: 'https://leetcode-cn.com/problemset/all/', - open: false, - closeTime: 1648809478385, - globalSiteTouchFish: false, - restTime: 15, - }, - ], -} diff --git a/src/options/App/settingPage/serve.vue b/src/options/App/settingPage/serve.vue deleted file mode 100644 index e22c543..0000000 --- a/src/options/App/settingPage/serve.vue +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - diff --git a/src/popup/App/popup.vue b/src/popup/App/popup.vue index 15750e3..c0b4e8d 100644 --- a/src/popup/App/popup.vue +++ b/src/popup/App/popup.vue @@ -144,19 +144,24 @@ export default { this.settingUpdate(this.Setting) this.utils.jumpUrl(this.NET.OPTIONSPAGE) }, + async getCurrentTab() { + const queryOptions = { active: true, currentWindow: true } + const res = await chrome.tabs.query(queryOptions) + return res[0] + }, // 初始化 async initData() { this.Setting = await this.utils.getChromeStorage(this.NET.GLOBALSETTING) || defaultSetting this.tableData = await this.utils.getChromeStorage(this.NET.TABLELIST) || [] // 先获取当前页面的tabID - chrome.tabs.getSelected(null, (tab) => { - this.tab = tab - const isMatch = this.utils.checkUrl(this.tableData, tab.url) - if (isMatch) { - this.item = isMatch.item - this.index = isMatch.index - } - }) + + this.tab = await this.getCurrentTab() + console.log('tab', this.tab) + const isMatch = this.utils.checkUrl(this.tableData, this.tab.url) + if (isMatch) { + this.item = isMatch.item + this.index = isMatch.index + } }, // 一键开启/关闭 async checkoutAll() { diff --git a/src/utils/allAction.js b/src/utils/allAction.js index 6788d3d..9aa35a9 100644 --- a/src/utils/allAction.js +++ b/src/utils/allAction.js @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2022-01-07 16:43:58 * LastEditors : OBKoro1 - * LastEditTime : 2022-01-12 14:14:19 + * LastEditTime : 2022-04-09 20:50:46 * FilePath : /stop-mess-around/src/utils/allAction.js * description : 一键开启、一键关闭 * koroFileheader VSCode插件 @@ -29,6 +29,7 @@ class AllAction { return { tableArr: this.tableArr, statisticsTime: this.statisticsTime, setting: this.setting } } + // 关闭网站检测 摸鱼休息 async AllCloseCheck() { const options = { item: null, @@ -49,20 +50,48 @@ class AllAction { } // 打开全局摸鱼检测 设置今日摸鱼时间 - setGlobalSiteTouchFish() { - let bigEndTime = 0 - for (const item of this.tableArr.values()) { - item.restTime = 0 // 全局关闭 使用默认开启设置 不是休息 + async setGlobalSiteTouchFish() { + let bigEndTime = 0 // 获取全局摸鱼状态checkoutStudy 的最远时间 + let restTime = 0 // 当前网站已经在摸鱼状态了 收集休息时间 + for (const [index, item] of this.tableArr.entries()) { + const copyItem = JSON.parse(JSON.stringify(item)) + item.restTime = 0 + if (restTime < (item.restTime || 0)) restTime = item.restTime const { openTime } = utils.getItemCloseCheckTime(item, this.setting) - if (bigEndTime < openTime) bigEndTime = openTime + if (bigEndTime < openTime) bigEndTime = openTime // 最远摸鱼时间 + if (!item.open) continue + // 已经关闭摸鱼检测的 将其开启,返回网站摸鱼统计 + const options = { + setting: this.setting, + tableArr: this.tableArr, + statisticsTime: this.statisticsTime, + item: copyItem, + } + // eslint-disable-next-line no-await-in-loop + const { item: newItem } = await utils.openCheck(options) + this.tableArr[index] = newItem } - this.setting.todayGlobalTouchFish = bigEndTime - const minutes = utils.getMoreDiff(bigEndTime, Date.now(), true) + let minutes = 0 const nowDay = this.statisticsTime[0] - nowDay.time += minutes + if (bigEndTime < restTime) { + // 判断当前摸鱼状态是否比全局时间长 如果长的话 需要返回 + minutes = utils.getMoreDiff(restTime, bigEndTime, true) + nowDay.time -= minutes + } else if (restTime !== 0) { + // 之前摸鱼网站有值 但是不到全局的时间 补一些时间 + const restDate = Date.now() + restTime * 60 * 1000 + minutes = utils.getMoreDiff(bigEndTime, restDate, true) + nowDay.time += minutes + } else { + // 之前没有网站开始摸鱼 没值 直接增加全局时间 + minutes = utils.getMoreDiff(bigEndTime, Date.now(), true) + nowDay.time += minutes + } + this.setting.todayGlobalTouchFish = bigEndTime // 全局最远摸鱼时间是全局的时间 this.statisticsTime[0] = nowDay } + // 打开检测 弹窗提醒 async AllOpenCheck() { const options = { item: null, diff --git a/src/utils/closeCheck.js b/src/utils/closeCheck.js index 24d9057..76e6d1c 100644 --- a/src/utils/closeCheck.js +++ b/src/utils/closeCheck.js @@ -2,9 +2,9 @@ * Author : OBKoro1 * Date : 2022-01-07 16:43:58 * LastEditors : OBKoro1 - * LastEditTime : 2022-01-12 14:14:26 + * LastEditTime : 2022-04-09 20:50:50 * FilePath : /stop-mess-around/src/utils/closeCheck.js - * description : 关闭网站检测 + * description : 关闭网站检测,摸鱼休息 * koroFileheader VSCode插件 * Copyright (c) 2022 by OBKoro1, All Rights Reserved. */ @@ -15,7 +15,7 @@ import NET from './net' class CloseCheck { /** - * @description: 关闭网站检测 + * @description: 关闭网站检测,摸鱼休息 * @param options * @options.item 需要修改的数据 * @options.statisticsTime 统计摸鱼时长 @@ -30,14 +30,15 @@ class CloseCheck { const { item, statisticsTime, setting, restTime, globalSiteTouchFish = false, } = options + this.statisticsTime = statisticsTime this.setting = setting this.item = item - item.open = false - item.closeTime = Date.now() - item.restTime = restTime - if (globalSiteTouchFish) item.globalSiteTouchFish = true // 是否开启全局摸鱼 + this.item.open = false + this.item.closeTime = Date.now() + this.item.restTime = restTime + if (globalSiteTouchFish) this.item.globalSiteTouchFish = true // 是否开启全局摸鱼 await this.statisticsSite(statisticsTime) - return { item, statisticsTime } + return { item: this.item, statisticsTime: this.statisticsTime } } /** @@ -48,25 +49,25 @@ class CloseCheck { * @param diffGlobal [number] 本次网站时长与今日全局摸鱼时间差 * @return [type] */ - async statisticsSite(statisticsTime) { + async statisticsSite() { // 全局摸鱼不统计数据 在全局的地方统计 if (this.item.globalSiteTouchFish) return - if (!statisticsTime) statisticsTime = (await utils.getChromeStorage(NET.statisticsTime)) + if (!this.statisticsTime) this.statisticsTime = (await utils.getChromeStorage(NET.statisticsTime)) // 获取一个item打开检测的时间戳和休息的分钟数 const { openTime, restTimeValue } = utils.getItemCloseCheckTime(this.item, this.setting) - const nowDay = statisticsTime[0] - this.statisticsSiteData(nowDay, restTimeValue) + let nowDay = this.statisticsTime[0] + nowDay = this.statisticsSiteData(nowDay, restTimeValue) // 获取网站的摸鱼时间与今日全局摸鱼时间差 const diffGlobal = await this.getTodayTouchTimeDiff(this.setting, openTime, restTimeValue) // 统计总时间 nowDay.time += diffGlobal // 网站摸鱼时长排序 - statisticsTime = statisticsTime.map((ele) => { + this.statisticsTime = this.statisticsTime.map((ele) => { ele.restSite.sort((a, b) => b.time - a.time) return ele }) - await utils.updateStorageData(statisticsTime, NET.statisticsTime) + await utils.updateStorageData(this.statisticsTime, NET.statisticsTime) } statisticsSiteData(nowDay, restTime) { @@ -97,6 +98,7 @@ class CloseCheck { site: this.item.site, // 网址 id }) } + return nowDay } // 获取今日全局摸鱼与网站的摸鱼时间差 diff --git a/src/utils/index.js b/src/utils/index.js index c099b60..576f78a 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -3,7 +3,7 @@ * Author : OBKoro1 * Date : 2021-05-17 16:17:59 * LastEditors : OBKoro1 - * LastEditTime : 2022-04-09 14:52:29 + * LastEditTime : 2022-04-16 20:12:46 * FilePath : /stop-mess-around/src/utils/index.js * Description : 全局方法 * Copyright (c) 2021 by OBKoro1, All Rights Reserved. @@ -31,9 +31,13 @@ class GlobalFunction { } } -// 设置 更新旧的字段 +/** + * @description: 设置 更新旧的字段 + * @param {type} setting + * @param {type} utils + * @return {type} + */ function updateOldSetting(setting, utils) { - console.log('update updateOldSetting') if (typeof setting.showRightTip === 'boolean') { setting.showRightTip = setting.showRightTip ? 'open' : 'closeRestTimeStatistics' utils.updateStorageData(setting, NET.GLOBALSETTING) @@ -41,19 +45,33 @@ function updateOldSetting(setting, utils) { } export const utils = { - // 本地直接跳转 - replaceUrl(url) { - window.open(url, 'target') - }, - // 打开新页面 + /** + * @description: 打开新页面 + * @param {type} url + */ jumpUrl(url) { - window.open(url, '_blank') + chrome.tabs.create({ + url, + }) }, + /** + * @description: 关闭网站检测,摸鱼休息 + * @param {type} + * @return {type} + */ closeCheck: CloseCheckInstanceRun, + /** + * @description: 开启网站检测,弹窗提示 + * @param {type} + * @return {type} + */ openCheck: OpenCheckInstanceRun, openCheckAll: AllActionInstanceRun, closeCheckAll: AllActionInstanceRun, - // 获取数据 + /** + * @description: 获取插件数据 + * @return {object} { setting, statisticsTime, listArr } + */ async getData() { const setting = await utils.getChromeStorage(NET.GLOBALSETTING) || defaultSetting const statisticsTime = (await utils.getChromeStorage(NET.statisticsTime)) || [] @@ -61,7 +79,13 @@ export const utils = { updateOldSetting(setting, utils) return { setting, statisticsTime, listArr } }, - // 获取两个时间戳的差值 + /** + * @description: 获取两个时间戳的差值 + * @param {type} lastTime + * @param {type} startTime + * @param {type} getSeconds 一秒算不算一分钟 + * @return {type} minutes + */ getMoreDiff(lastTime, startTime, getSeconds = false) { const duration = dayjs.duration(lastTime - startTime) const hours = duration.hours() @@ -72,9 +96,16 @@ export const utils = { if (seconds > 0) minutes += 1 } if (hours > 0) minutes += hours * 60 + // 兜底 当突然关闭等情况 导致lastTime和startTime数值不对 diff为0 + if (minutes < 0) minutes = 0 return minutes }, - // 获取一个item打开检测的时间戳和休息的分钟数 + /** + * @description: 获取一个item打开检测 弹窗提醒的时间戳和休息的分钟数 + * @param {type} item + * @param {type} Setting + * @return {type} { openTime, restTimeValue } + */ getItemCloseCheckTime(item, Setting) { let value // 休息的分钟数 if (item.restTime) { @@ -85,12 +116,10 @@ export const utils = { const openTime = (item.closeTime || Date.now()) + value * 60 * 1000 return { openTime, restTimeValue: value } }, - // 获取不同语言的方法 /** - * @description + * @description 获取不同语言的方法 * @param * name 获取chrome的language数据 * @param * zh 还没同步到language 临时使用汉字 - * @return {*} */ getLanguageMessage(name, zh) { if (zh) { @@ -99,11 +128,11 @@ export const utils = { return chrome.i18n.getMessage(name) }, /** - * @description 检测当前网站地址是否匹配到列表 - * @param * tableArr 摸鱼网站列表 - * @param * url 检测的地址 - * @return {*} - */ + * @description 检测当前网站地址是否匹配到列表 + * @param * tableArr 摸鱼网站列表 + * @param * url 检测的地址 + * @return {*} { item, index: i } | false + */ checkUrl(tableArr, url) { let isMatch = false const len = tableArr.length @@ -132,11 +161,11 @@ export const utils = { /** * @description 获取storage数据 * @param * key - * @return {value} */ getChromeStorage(key) { + // let navigator = NavigatorOptions() return new Promise((resolve) => { - chrome.storage.sync.get(key, (res) => { + chrome.storage.local.get([key], (res) => { let result = res[key] // 取到值 则还原给数组/对象 抛出去 否则就抛出去undefined if (result !== undefined) { @@ -146,12 +175,15 @@ export const utils = { }) }) }, - // 更新数据 + /** + * @description: 更新数据 + * @param {type} val + * @param {type} key + */ updateStorageData(val, key) { return new Promise((resolve) => { - const str = window.JSON.stringify(val) - chrome.storage.sync.set({ [key]: str }, () => { - console.log(`${key} update`) + const str = JSON.stringify(val) + chrome.storage.local.set({ [key]: str }, () => { resolve() }) }) diff --git a/src/utils/net.js b/src/utils/net.js index a69da7d..8754894 100644 --- a/src/utils/net.js +++ b/src/utils/net.js @@ -2,17 +2,52 @@ * Author : OBKoro1 * Date : 2021-05-21 14:56:38 * LastEditors : OBKoro1 - * LastEditTime : 2022-03-13 15:42:58 + * LastEditTime : 2022-04-17 17:53:46 * FilePath : /stop-mess-around/src/utils/net.js * Description : 全局常量 * Copyright (c) 2021 by OBKoro1, All Rights Reserved. */ + +function getNavigatorOptions() { + // 转小写 + const mode = process.env.VUE_APP_MODE.toLowerCase() + if (mode.indexOf('firefox') >= 0) { + // TODO: id获取 getUrl + // 打开火狐options的id + const FIREFOX_UUID = '17ce4bd7-60f8-432c-9848-a61dd819bc06' + // 本地调试火狐的id + const FIREFOX_SERVER_UUID = '0ffdf229-783f-4b8b-b583-8cf7788f7180' + const id = process.env.VUE_APP_MODE === 'serve' ? FIREFOX_SERVER_UUID : FIREFOX_UUID + return { + name: 'Firefox', + id, // serve + extensionName: 'moz-extension', + downloadUrl: 'https://addons.mozilla.org/zh-CN/firefox/addon/stop-mess-around1/', + } + } + + const chromeOptions = { + name: 'Chrome', + id: chrome.runtime.id, // serve + extensionName: 'chrome-extension', + downloadUrl: 'https://chrome.google.com/webstore/detail/stop-mess-around/gbjbkekbbjbieijpebieifkmahlagncm/related?hl=zh-CN', + } + if (mode.indexOf('edge') >= 0) { + chromeOptions.name = 'Edge' + chromeOptions.downloadUrl = 'https://microsoftedge.microsoft.com/addons/detail/stopmessaround/mdiafefnlaaefmfgjbeejpppkdhghmaj' + } + // 包含edge + return chromeOptions +} + +const NavigatorOptions = getNavigatorOptions() || {} + const NET = { // 项目地址 GITHUBREPO: 'https://github.com/OBKoro1/stop-mess-around', GITHUB_REPO_ISSUES: 'https://github.com/OBKoro1/stop-mess-around/issues', // 使用文档 - DOCS: 'https://github.com/OBKoro1/stop-mess-around/wiki/%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B%E4%BB%A5%E5%8F%8A%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E', + DOCS: 'https://github.com/OBKoro1/stop-mess-around/wiki/%E5%8A%9F%E8%83%BD%E7%A4%BA%E4%BE%8B%E4%BB%A5%E5%8F%8A%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E', // 更新日志 RELEASES: 'https://github.com/OBKoro1/stop-mess-around/blob/master/CHANNGELOG.md', // github 地址 @@ -20,14 +55,15 @@ const NET = { // 我的github地址 MYSITE: 'http://obkoro1.com/web_accumulate/about.html', // 插件配置面板页面 - OPTIONSPAGE: `chrome-extension://${chrome.runtime.id}/options.html`, + OPTIONSPAGE: `${NavigatorOptions.extensionName}://${NavigatorOptions.id}/options.html`, // MYSITE: 'https://github.com/OBKoro1', // 谷歌应用市场 - CHROMESTORE: 'https://chrome.google.com/webstore/detail/stop-mess-around/gbjbkekbbjbieijpebieifkmahlagncm/related?hl=zh-CN', + CHROMESTORE: NavigatorOptions.downloadUrl, // storage TABLELIST: 'tableList', statisticsTime: 'statisticsTime', // 统计摸鱼时长 GLOBALSETTING: 'globalSetting', + NAVIGATOR_OPTIONS: NavigatorOptions, } export default NET diff --git a/src/utils/openCheck.js b/src/utils/openCheck.js index 81704f7..be5dc8e 100644 --- a/src/utils/openCheck.js +++ b/src/utils/openCheck.js @@ -2,9 +2,9 @@ * Author : OBKoro1 * Date : 2022-01-07 16:43:58 * LastEditors : OBKoro1 - * LastEditTime : 2022-01-12 14:15:26 + * LastEditTime : 2022-04-09 20:36:33 * FilePath : /stop-mess-around/src/utils/openCheck.js - * description : 开启网站检测 + * description : 开启网站检测,弹窗提示 * koroFileheader VSCode插件 * Copyright (c) 2022 by OBKoro1, All Rights Reserved. */ @@ -14,11 +14,6 @@ import { utils } from './index' import NET from './net' class OpenCheck { - /** - * @description: 打开检测 - * @param options [type] - * @return [type] - */ async run(options) { const { item, tableArr, statisticsTime, setting, globalSiteTouchFish, getMoreDiffVal = false, @@ -73,7 +68,7 @@ class OpenCheck { async isLastOpenItem(openTime) { if (this.openTime < this.setting.todayGlobalTouchFish) return // 小于最远的摸鱼时间 let lastTime = 0 - let allOpen = true + let allOpen = true // 是否所有网站都开启检测 弹窗提醒 for (const item of this.tableArr.values()) { if (this.item.site === item.site) continue if (!item.open) { // 还有其他开启的摸鱼检测吗 @@ -87,8 +82,12 @@ class OpenCheck { } // 最远一个 需要返回今日摸鱼剩余 并且不是全部关闭 (全部关闭再外面返回今日摸鱼时间) if (lastTime < openTime && !this.globalSiteTouchFish) { - if (allOpen) lastTime = Date.now() // 所有的都关闭 初始化为当前时间 - this.setting.todayGlobalTouchFish = lastTime // 更新最远时间 + if (allOpen) { + lastTime = Date.now() // 所有网站都开启检测 初始化为当前时间 + this.setting.todayGlobalTouchFish = 0 // 修改最远摸鱼时间 + } else { + this.setting.todayGlobalTouchFish = lastTime // 更新最远时间 + } const minutes = utils.getMoreDiff(openTime, lastTime, this.getMoreDiff) await this.returnTodayTouchFishTime(minutes) await utils.updateStorageData(this.setting, NET.GLOBALSETTING) diff --git a/static/development.md b/static/development.md new file mode 100644 index 0000000..0f72b3a --- /dev/null +++ b/static/development.md @@ -0,0 +1,75 @@ +# 开发相关 + + + + + + + +## 统计相关逻辑 + +* 有道云笔记 + +## 环境变量 + +* NODE_ENV --mode 环境 传递 +* VUE_APP_MODE .env.版本 传递 +* argv: node deploy.js 参数1 参数2 + +### 开发 +* 写代码 + * 清空issue + * 清空todo + * 可选更新架构和工程 + * 可选更新名人名言 +* 提交代码 +* 写changelog +* 写文档,写功能描述。 + +## 打包 + +* 打包各浏览器的应用商店版本 + * 是否修改文档描述 + * 是否修改图片演示 +* 打包各浏览器的release版本,通过actions上传到release中。 + +## tag + +* 打tag + +### 上传到应用商店。 + +* 谷歌 +* edge +* 火狐 \ No newline at end of file diff --git a/vue.config.js b/vue.config.js index b5efeb9..fceaf48 100644 --- a/vue.config.js +++ b/vue.config.js @@ -26,7 +26,8 @@ const plugins = [ ] // 开发环境将热加载文件复制到dist文件夹 -if (process.env.NODE_ENV !== 'production') { +const mode = process.env.NODE_ENV.toLowerCase() +if (mode.indexOf('serve') >= 0) { plugins.push( CopyWebpackPlugin([{ from: path.resolve('src/utils/hot-reload.js'), @@ -48,17 +49,20 @@ module.exports = { // // 生产环境是否生成 sourceMap 文件 productionSourceMap: false, configureWebpack: { + devtool: 'inline-source-map', entry: { content: './src/content/index.js', background: './src/background/index.js', }, output: { - filename: 'js/[name].js', + filename: '[name].js', }, plugins, }, css: { extract: { + // https://www.cnblogs.com/mmzuo-798/p/14333897.html + // MiniCssExtractPlugin.loader 更改css引用地址 filename: 'css/[name].css', // chunkFilename: 'css/[name].css' },