From 9cef7e3370e7a665cb8a226f68e522d581e2d665 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 13 Apr 2024 18:08:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BD=93=E5=89=8D=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E7=89=88=E6=9C=AC=E6=89=80=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4=E7=89=88=E6=9C=AC=E3=80=81?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=97=B6=E9=97=B4=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 1 + build-config/renderer/webpack.config.dev.js | 7 +++ build-config/renderer/webpack.config.prod.js | 14 ++++++ package-lock.json | 44 +++++++++---------- package.json | 4 +- publish/changeLog.md | 1 + src/lang/en-us.json | 2 + src/lang/zh-cn.json | 2 + src/lang/zh-tw.json | 2 + src/renderer/types/app.d.ts | 4 ++ .../Setting/components/SettingUpdate.vue | 16 +++++-- 11 files changed, 70 insertions(+), 27 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad7ed8e9..e2685118 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,6 +78,7 @@ jobs: NPM_CACHE: '%APPDATA%\npm-cache' ELECTRON_CACHE: '%LOCALAPPDATA%\electron\Cache' ELECTRON_BUILDERCACHE: '%LOCALAPPDATA%\electron-builder\Cache' + BUILD_WIN_7: 'true' # needs: CheckCode steps: - name: Check out git repository diff --git a/build-config/renderer/webpack.config.dev.js b/build-config/renderer/webpack.config.dev.js index b563249b..9d90a5ec 100644 --- a/build-config/renderer/webpack.config.dev.js +++ b/build-config/renderer/webpack.config.dev.js @@ -5,6 +5,11 @@ const { merge } = require('webpack-merge') const baseConfig = require('./webpack.config.base') +const gitInfo = { + commit_id: '', + commit_date: '', +} + module.exports = merge(baseConfig, { mode: 'development', devtool: 'eval-source-map', @@ -18,6 +23,8 @@ module.exports = merge(baseConfig, { __VUE_OPTIONS_API__: 'true', __VUE_PROD_DEVTOOLS__: 'false', __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false', + COMMIT_ID: `"${gitInfo.commit_id}"`, + COMMIT_DATE: `"${gitInfo.commit_date}"`, staticPath: `"${path.join(__dirname, '../../src/static').replace(/\\/g, '\\\\')}"`, }), ], diff --git a/build-config/renderer/webpack.config.prod.js b/build-config/renderer/webpack.config.prod.js index f9e399ef..6e7995d9 100644 --- a/build-config/renderer/webpack.config.prod.js +++ b/build-config/renderer/webpack.config.prod.js @@ -1,4 +1,5 @@ const path = require('path') +const { execSync } = require('child_process') const webpack = require('webpack') const CssMinimizerPlugin = require('css-minimizer-webpack-plugin') const TerserPlugin = require('terser-webpack-plugin') @@ -12,6 +13,17 @@ const buildConfig = require('../webpack-build-config') // let whiteListedModules = ['vue', 'vue-router', 'vuex', 'vue-i18n'] +const gitInfo = { + commit_id: '', + commit_date: '', +} + +try { + if (!execSync('git status --porcelain').toString().trim() || process.env.BUILD_WIN_7) { + gitInfo.commit_id = execSync('git log -1 --pretty=format:"%H"').toString().trim() + gitInfo.commit_date = execSync('git log -1 --pretty=format:"%ad" --date=iso-strict').toString().trim() + } +} catch {} module.exports = merge(baseConfig, { mode: 'production', @@ -45,6 +57,8 @@ module.exports = merge(baseConfig, { __VUE_OPTIONS_API__: 'true', __VUE_PROD_DEVTOOLS__: 'false', __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false', + COMMIT_ID: `"${gitInfo.commit_id}"`, + COMMIT_DATE: `"${gitInfo.commit_date}"`, }), ], optimization: { diff --git a/package-lock.json b/package-lock.json index 0068effa..f8242375 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ "@types/tunnel": "^0.0.7", "@types/ws": "8.5.4", "@volar/vue-language-plugin-pug": "^1.6.5", - "@vue/language-plugin-pug": "^2.0.12", + "@vue/language-plugin-pug": "^2.0.13", "babel-loader": "^9.1.3", "browserslist": "^4.23.0", "chalk": "^4.1.2", @@ -62,7 +62,7 @@ "electron-builder": "^24.13.3", "electron-debug": "^3.2.0", "electron-devtools-installer": "^3.2.0", - "electron-to-chromium": "^1.4.733", + "electron-to-chromium": "^1.4.736", "electron-updater": "^6.1.8", "eslint": "^8.57.0", "eslint-config-standard": "^17.1.0", @@ -3536,19 +3536,19 @@ "integrity": "sha512-LgPscpE3Vs0x96PzSSB4IGVSZXZBZHpfxs+ZA1d+VEPwHdOXowy/Y2CsvCAIFrf+ssVU1pD1jidj505EpUnfbA==" }, "node_modules/@vue/language-plugin-pug": { - "version": "2.0.12", - "resolved": "https://registry.npmjs.org/@vue/language-plugin-pug/-/language-plugin-pug-2.0.12.tgz", - "integrity": "sha512-HiFztLIeH4uipd7t6SfNe3pmRpydzg6GY4kncTvskcyj7ST2ayanxlymD2N2ldH5EAyd1ekGsELHfgIMH7tboA==", + "version": "2.0.13", + "resolved": "https://registry.npmjs.org/@vue/language-plugin-pug/-/language-plugin-pug-2.0.13.tgz", + "integrity": "sha512-3XlW+V8lsa1v6BV75BinWa8YZEbEGurFOll6S+YOf+2HI2SfIZLdhwJZs/8sDVbMndaqPouCSSKYk+kea46QUA==", "dev": true, "dependencies": { - "@volar/source-map": "2.2.0-alpha.7", + "@volar/source-map": "2.2.0-alpha.8", "volar-service-pug": "0.0.38" } }, "node_modules/@vue/language-plugin-pug/node_modules/@volar/source-map": { - "version": "2.2.0-alpha.7", - "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.2.0-alpha.7.tgz", - "integrity": "sha512-iIZM2EovdEnr6mMwlsnt4ciix4xz7HSGHyUSviRaY5cii5PMXGHeUU9UDeb+xzLCx8kdk3L5J4z+ts50AhkYcg==", + "version": "2.2.0-alpha.8", + "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.2.0-alpha.8.tgz", + "integrity": "sha512-E1ZVmXFJ5DU4fWDcWHzi8OLqqReqIDwhXvIMhVdk6+VipfMVv4SkryXu7/rs4GA/GsebcRyJdaSkKBB3OAkIcA==", "dev": true, "dependencies": { "muggle-string": "^0.4.0" @@ -7256,9 +7256,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.733", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.733.tgz", - "integrity": "sha512-gUI9nhI2iBGF0OaYYLKOaOtliFMl+Bt1rY7VmEjwxOxqoYLub/D9xmduPEhbw2imE6gYkJKhIE5it+KE2ulVxQ==", + "version": "1.4.736", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.736.tgz", + "integrity": "sha512-Rer6wc3ynLelKNM4lOCg7/zPQj8tPOCB2hzD32PX9wd3hgRRi9MxEbmkFCokzcEhRVMiOVLjnL9ig9cefJ+6+Q==", "dev": true }, "node_modules/electron-updater": { @@ -20428,19 +20428,19 @@ "integrity": "sha512-LgPscpE3Vs0x96PzSSB4IGVSZXZBZHpfxs+ZA1d+VEPwHdOXowy/Y2CsvCAIFrf+ssVU1pD1jidj505EpUnfbA==" }, "@vue/language-plugin-pug": { - "version": "2.0.12", - "resolved": "https://registry.npmjs.org/@vue/language-plugin-pug/-/language-plugin-pug-2.0.12.tgz", - "integrity": "sha512-HiFztLIeH4uipd7t6SfNe3pmRpydzg6GY4kncTvskcyj7ST2ayanxlymD2N2ldH5EAyd1ekGsELHfgIMH7tboA==", + "version": "2.0.13", + "resolved": "https://registry.npmjs.org/@vue/language-plugin-pug/-/language-plugin-pug-2.0.13.tgz", + "integrity": "sha512-3XlW+V8lsa1v6BV75BinWa8YZEbEGurFOll6S+YOf+2HI2SfIZLdhwJZs/8sDVbMndaqPouCSSKYk+kea46QUA==", "dev": true, "requires": { - "@volar/source-map": "2.2.0-alpha.7", + "@volar/source-map": "2.2.0-alpha.8", "volar-service-pug": "0.0.38" }, "dependencies": { "@volar/source-map": { - "version": "2.2.0-alpha.7", - "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.2.0-alpha.7.tgz", - "integrity": "sha512-iIZM2EovdEnr6mMwlsnt4ciix4xz7HSGHyUSviRaY5cii5PMXGHeUU9UDeb+xzLCx8kdk3L5J4z+ts50AhkYcg==", + "version": "2.2.0-alpha.8", + "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.2.0-alpha.8.tgz", + "integrity": "sha512-E1ZVmXFJ5DU4fWDcWHzi8OLqqReqIDwhXvIMhVdk6+VipfMVv4SkryXu7/rs4GA/GsebcRyJdaSkKBB3OAkIcA==", "dev": true, "requires": { "muggle-string": "^0.4.0" @@ -23275,9 +23275,9 @@ } }, "electron-to-chromium": { - "version": "1.4.733", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.733.tgz", - "integrity": "sha512-gUI9nhI2iBGF0OaYYLKOaOtliFMl+Bt1rY7VmEjwxOxqoYLub/D9xmduPEhbw2imE6gYkJKhIE5it+KE2ulVxQ==", + "version": "1.4.736", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.736.tgz", + "integrity": "sha512-Rer6wc3ynLelKNM4lOCg7/zPQj8tPOCB2hzD32PX9wd3hgRRi9MxEbmkFCokzcEhRVMiOVLjnL9ig9cefJ+6+Q==", "dev": true }, "electron-updater": { diff --git a/package.json b/package.json index d0ce07ce..07614233 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,7 @@ "@types/tunnel": "^0.0.7", "@types/ws": "8.5.4", "@volar/vue-language-plugin-pug": "^1.6.5", - "@vue/language-plugin-pug": "^2.0.12", + "@vue/language-plugin-pug": "^2.0.13", "babel-loader": "^9.1.3", "browserslist": "^4.23.0", "chalk": "^4.1.2", @@ -137,7 +137,7 @@ "electron-builder": "^24.13.3", "electron-debug": "^3.2.0", "electron-devtools-installer": "^3.2.0", - "electron-to-chromium": "^1.4.733", + "electron-to-chromium": "^1.4.736", "electron-updater": "^6.1.8", "eslint": "^8.57.0", "eslint-config-standard": "^17.1.0", diff --git a/publish/changeLog.md b/publish/changeLog.md index b0c75ef8..9123d563 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -4,6 +4,7 @@ - 新增在线自定义源导入功能,允许通过http/https链接导入自定义源 - 新增HTTP开放API服务,默认关闭,该服务可以为第三方软件提供调用LX的能力,可用API看[说明文档](https://lyswhut.github.io/lx-music-doc/desktop/open-api)(#1824) - 托盘菜单新增播放、切歌、收藏控制 +- 添加当前软件版本所对应的代码提交版本、提交时间的显示,可到设置-版本更新查看 ### 优化 diff --git a/src/lang/en-us.json b/src/lang/en-us.json index 2b574cd2..99b64629 100644 --- a/src/lang/en-us.json +++ b/src/lang/en-us.json @@ -560,6 +560,8 @@ "setting__sync_tip": "For how to use it, please see the \"Sync function\" section of the FAQ", "setting__update": "Update", "setting__update_checking": "Checking for updates...", + "setting__update_commit_date": "Submission date:", + "setting__update_commit_id": "Code version:", "setting__update_current_label": "Current version: ", "setting__update_downloading": "Update is found and being downloaded...⏳", "setting__update_init": "Processing update...", diff --git a/src/lang/zh-cn.json b/src/lang/zh-cn.json index bf143890..7e94c4cf 100644 --- a/src/lang/zh-cn.json +++ b/src/lang/zh-cn.json @@ -560,6 +560,8 @@ "setting__sync_tip": "使用方式请看常见问题“同步功能”部分", "setting__update": "软件更新", "setting__update_checking": "检查更新中...", + "setting__update_commit_date": "提交日期:", + "setting__update_commit_id": "代码版本:", "setting__update_current_label": "当前版本:", "setting__update_downloading": "发现新版本并在努力下载中,请稍后...⏳", "setting__update_init": "处理更新中...", diff --git a/src/lang/zh-tw.json b/src/lang/zh-tw.json index 8f369946..40a4bf39 100644 --- a/src/lang/zh-tw.json +++ b/src/lang/zh-tw.json @@ -560,6 +560,8 @@ "setting__sync_tip": "使用方式請看常見問題「同步功能」部分", "setting__update": "軟體更新", "setting__update_checking": "檢查更新中...", + "setting__update_commit_date": "提交日期:", + "setting__update_commit_id": "程式碼版本:", "setting__update_current_label": "目前版本:", "setting__update_downloading": "發現新版本並在努力下載中,請稍後...⏳", "setting__update_init": "處理更新中...", diff --git a/src/renderer/types/app.d.ts b/src/renderer/types/app.d.ts index c6d7372a..c95fb9f5 100644 --- a/src/renderer/types/app.d.ts +++ b/src/renderer/types/app.d.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-var */ import { type AppEventTypes, type KeyEventTypes } from '@renderer/event' import { type MainTypes, type DownloadTypes } from '@renderer/worker/utils' import { type I18n } from '@renderer/plugins/i18n' @@ -93,6 +94,9 @@ declare global { lx_handled?: boolean } } + + var COMMIT_ID: string + var COMMIT_DATE: string } diff --git a/src/renderer/views/Setting/components/SettingUpdate.vue b/src/renderer/views/Setting/components/SettingUpdate.vue index 30f91b77..efea5712 100644 --- a/src/renderer/views/Setting/components/SettingUpdate.vue +++ b/src/renderer/views/Setting/components/SettingUpdate.vue @@ -6,9 +6,15 @@ dd .gap-top base-checkbox(id="setting__update_showChangeLog" :model-value="appSetting['common.showChangeLog']" :label="$t('setting__update_show_change_log')" @update:model-value="updateSetting({'common.showChangeLog': $event})") .gap-top - .p.small + .gap-top + .p.small(@click="handleOpenDevTools") {{ $t('setting__update_current_label') }}{{ versionInfo.version }} + .p.small(v-if="commit_id") + | {{ $t('setting__update_commit_id') }} + span.select {{ commit_id }} + .p.small(v-if="commit_date") {{ $t('setting__update_commit_date') }}{{ commit_date }} + + .p.small.gap-top | {{ $t('setting__update_latest_label') }}{{ versionInfo.newVersion && versionInfo.newVersion.version != '0.0.0' ? versionInfo.newVersion.version : $t('setting__update_unknown') }} - .p.small(@click="handleOpenDevTools") {{ $t('setting__update_current_label') }}{{ versionInfo.version }} .p.small(v-if="downloadProgress" style="line-height: 1.5;") | {{ $t('setting__update_downloading') }} br @@ -28,7 +34,7 @@ dd