From 3a098c04158a8a3f36234500ebf5ca03fd821fdc Mon Sep 17 00:00:00 2001 From: beats0 <2047155291@qq.com> Date: Wed, 10 Jun 2020 15:57:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=20-=20=E7=AA=97=E5=8F=A3=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E5=90=8C=E6=AD=A5=20=20-=20=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E7=89=88=E6=9C=AC=E5=8F=B7=E9=94=99?= =?UTF-8?q?=E8=AF=AFbug=20=20-=20=20=E7=89=88=E6=9C=AC=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 10 ++ README.md | 2 + README_DEV.md | 2 + .../Danmaku/DanmakuControl/DanmakuControl.tsx | 2 +- app/dao/ConfigDao.ts | 1 + app/menu.ts | 144 ++++-------------- app/package.json | 2 +- app/utils/common.ts | 30 +--- package.json | 3 +- yarn.lock | 5 + 10 files changed, 60 insertions(+), 141 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..01a2dbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +## v1.0.1 + +- 优化版本号检查 +- win 和 mac 顶部窗口菜单栏保持一致 +- 修复客户端版本号错误bug +- 文档优化 + +## v1.0.1-beta.0 + +- 完成初版功能 diff --git a/README.md b/README.md index 8328120..1a4775a 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ text-shadow: 1px 1px 2px #e91e63, 0 0 0.2em #e91e63; 然后填入到 `设置` > `自定义样式` 中,`Ctrl+R` 重载即可。 +4. 每次更新后请点击 `设置` 中的 `重置`,保持更新数据同步,但以前的部分会丢失。 + ### 已知 BUG - mac 在全屏模式下无法至于顶层 diff --git a/README_DEV.md b/README_DEV.md index 0f7d14f..76331ab 100644 --- a/README_DEV.md +++ b/README_DEV.md @@ -6,6 +6,8 @@ 安装尽量翻墙 +eslint配置不生效,JSX代码格式各种警告,实在搞不动了,有代码强迫症的把eslint 检查关了吧 = = + ## 命令 调试 dev diff --git a/app/components/Danmaku/DanmakuControl/DanmakuControl.tsx b/app/components/Danmaku/DanmakuControl/DanmakuControl.tsx index 30af7b8..93cc5d9 100644 --- a/app/components/Danmaku/DanmakuControl/DanmakuControl.tsx +++ b/app/components/Danmaku/DanmakuControl/DanmakuControl.tsx @@ -150,7 +150,7 @@ function DanmakuControl(props: Props) { updateConfig({ k, v }); }; - const newVersion = hasNewVersion(config.latestVersion, config.version); + const newVersion = hasNewVersion(config.version, config.latestVersion); return (
diff --git a/app/dao/ConfigDao.ts b/app/dao/ConfigDao.ts index 659a34b..b4eb866 100644 --- a/app/dao/ConfigDao.ts +++ b/app/dao/ConfigDao.ts @@ -94,6 +94,7 @@ export default class ConfigDao { const configData: configStateType = JSON.parse(configStr); configData.roomid = resentLiveData.roomid; configData.shortid = resentLiveData.shortid; + configData.version = pkg.version; return configData; } diff --git a/app/menu.ts b/app/menu.ts index 32552cb..aba3e3f 100644 --- a/app/menu.ts +++ b/app/menu.ts @@ -55,17 +55,17 @@ export default class MenuBuilder { buildDarwinTemplate() { const subMenuAbout: DarwinMenuItemConstructorOptions = { - label: 'Electron', + label: 'bilive-danmaku', submenu: [ { - label: 'About ElectronReact', + label: 'About bilive-danmaku', selector: 'orderFrontStandardAboutPanel:' }, { type: 'separator' }, { label: 'Services', submenu: [] }, { type: 'separator' }, { - label: 'Hide ElectronReact', + label: 'Hide bilive-danmaku', accelerator: 'Command+H', selector: 'hide:' }, @@ -85,22 +85,6 @@ export default class MenuBuilder { } ] }; - const subMenuEdit: DarwinMenuItemConstructorOptions = { - label: 'Edit', - submenu: [ - { label: 'Undo', accelerator: 'Command+Z', selector: 'undo:' }, - { label: 'Redo', accelerator: 'Shift+Command+Z', selector: 'redo:' }, - { type: 'separator' }, - { label: 'Cut', accelerator: 'Command+X', selector: 'cut:' }, - { label: 'Copy', accelerator: 'Command+C', selector: 'copy:' }, - { label: 'Paste', accelerator: 'Command+V', selector: 'paste:' }, - { - label: 'Select All', - accelerator: 'Command+A', - selector: 'selectAll:' - } - ] - }; const subMenuViewDev: MenuItemConstructorOptions = { label: 'View', submenu: [ @@ -127,18 +111,6 @@ export default class MenuBuilder { } ] }; - const subMenuViewProd: MenuItemConstructorOptions = { - label: 'View', - submenu: [ - { - label: 'Toggle Full Screen', - accelerator: 'Ctrl+Command+F', - click: () => { - this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); - } - } - ] - }; const subMenuWindow: DarwinMenuItemConstructorOptions = { label: 'Window', submenu: [ @@ -156,103 +128,53 @@ export default class MenuBuilder { label: 'Help', submenu: [ { - label: 'Learn More', + label: 'Source code', click() { - shell.openExternal('https://electronjs.org'); + shell.openExternal('https://github.com/Beats0/bilive-danmaku'); } }, { - label: 'Documentation', + label: 'Check update', click() { shell.openExternal( - 'https://github.com/electron/electron/tree/master/docs#readme' + 'https://github.com/Beats0/bilive-danmaku/releases' ); } - }, - { - label: 'Community Discussions', - click() { - shell.openExternal('https://www.electronjs.org/community'); - } - }, - { - label: 'Search Issues', - click() { - shell.openExternal('https://github.com/electron/electron/issues'); - } } ] }; - const subMenuView = - process.env.NODE_ENV === 'development' || - process.env.DEBUG_PROD === 'true' - ? subMenuViewDev - : subMenuViewProd; - - return [subMenuAbout, subMenuEdit, subMenuView, subMenuWindow, subMenuHelp]; + return [subMenuAbout, subMenuViewDev, subMenuWindow, subMenuHelp]; } buildDefaultTemplate() { const templateDefault = [ { - label: '&File', + label: '&View', submenu: [ { - label: '&Open', - accelerator: 'Ctrl+O' + label: '&Reload', + accelerator: 'Ctrl+R', + click: () => { + this.mainWindow.webContents.reload(); + } + }, + { + label: 'Toggle &Full Screen', + accelerator: 'F11', + click: () => { + this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); + } }, { - label: '&Close', - accelerator: 'Ctrl+W', + label: 'Toggle &Developer Tools', + accelerator: 'Alt+Ctrl+I', click: () => { - this.mainWindow.close(); + this.mainWindow.webContents.toggleDevTools(); } } ] }, - { - label: '&View', - submenu: - process.env.NODE_ENV === 'development' || - process.env.DEBUG_PROD === 'true' - ? [ - { - label: '&Reload', - accelerator: 'Ctrl+R', - click: () => { - this.mainWindow.webContents.reload(); - } - }, - { - label: 'Toggle &Full Screen', - accelerator: 'F11', - click: () => { - this.mainWindow.setFullScreen( - !this.mainWindow.isFullScreen() - ); - } - }, - { - label: 'Toggle &Developer Tools', - accelerator: 'Alt+Ctrl+I', - click: () => { - this.mainWindow.webContents.toggleDevTools(); - } - } - ] - : [ - { - label: 'Toggle &Full Screen', - accelerator: 'F11', - click: () => { - this.mainWindow.setFullScreen( - !this.mainWindow.isFullScreen() - ); - } - } - ] - }, { label: 'Help', submenu: [ @@ -279,23 +201,17 @@ export default class MenuBuilder { }, // END { - label: 'Documentation', + label: 'Source code', click() { - shell.openExternal( - 'https://github.com/electron/electron/tree/master/docs#readme' - ); + shell.openExternal('https://github.com/Beats0/bilive-danmaku'); } }, { - label: 'Community Discussions', + label: 'Check update', click() { - shell.openExternal('https://www.electronjs.org/community'); - } - }, - { - label: 'Search Issues', - click() { - shell.openExternal('https://github.com/electron/electron/issues'); + shell.openExternal( + 'https://github.com/Beats0/bilive-danmaku/releases' + ); } } ] diff --git a/app/package.json b/app/package.json index 41c3197..2a32369 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "bilive-danmaku", "productName": "bilive-danmaku", - "version": "1.0.0", + "version": "1.0.1", "description": "bilibili live danmaku client", "main": "./main.prod.js", "author": { diff --git a/app/utils/common.ts b/app/utils/common.ts index c6c72f0..a5ccb46 100644 --- a/app/utils/common.ts +++ b/app/utils/common.ts @@ -1,8 +1,9 @@ import { shell } from 'electron'; +import { lt } from 'semver'; function openLink(href: string) { shell.openExternal(href).catch(e => { - console.log(e); + console.warn(e); }); } @@ -81,34 +82,15 @@ function tranNumber(num: number, point = 2): string { } /** - * @param {string} serverVersion 服务器端版本. * @param {string} clientVersion 客户端版本 + * @param {string} serverVersion 服务器端版本. * @return {boolean} 判断是否能更新 */ const hasNewVersion = ( - serverVersion: string, - clientVersion: string + clientVersion: string, + serverVersion: string ): boolean => { - const arr1 = serverVersion.split('.'); - const arr2 = clientVersion.split('.'); - // 将两个版本号拆成数字 - const minL = Math.min(arr1.length, arr2.length); - let pos = 0; // 当前比较位 - let diff = 0; // 当前为位比较是否相等 - - // 逐个比较如果当前位相等则继续比较下一位 - while (pos < minL) { - diff = parseInt(arr1[pos], 10) - parseInt(arr2[pos], 10); - if (diff !== 0) { - break; - } - pos++; - } - - if (diff > 0) { - return true; - } - return false; + return lt(clientVersion, serverVersion); }; export { diff --git a/package.json b/package.json index 7f60fda..19d272f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bilive-danmaku", "productName": "bilive-danmaku", - "version": "1.0.0", + "version": "1.0.1", "ElectronReactVersion": "1.1.0", "description": "bilibili live danmaku client", "scripts": { @@ -285,6 +285,7 @@ "react-spring": "^8.0.27", "redux": "^4.0.5", "redux-thunk": "^2.3.0", + "semver": "^7.3.2", "source-map-support": "^0.5.16", "styled-components": "^5.1.0" }, diff --git a/yarn.lock b/yarn.lock index 9a4a517..37e4eaf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13447,6 +13447,11 @@ semver@^7.1.3: resolved "https://registry.yarnpkg.com/semver/-/semver-7.1.3.tgz#e4345ce73071c53f336445cfc19efb1c311df2a6" integrity sha512-ekM0zfiA9SCBlsKa2X1hxyxiI4L3B6EbVJkkdgQXnSEEaHlGdvyodMruTiulSRWMMB4NeIuYNMC9rTKTz97GxA== +semver@^7.3.2: + version "7.3.2" + resolved "https://registry.npm.taobao.org/semver/download/semver-7.3.2.tgz?cache=0&sync_timestamp=1586886301819&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsemver%2Fdownload%2Fsemver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" + integrity sha1-YElisFK4HtB4aq6EOJ/7pw/9OTg= + semver@~5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"