mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-10 23:47:29 +00:00
refactor: 统一版本号管理,消除硬编码
项目版本(pom.xml revision)和parser版本(parserVersion)统一为单一来源, 前端构建时自动同步,发版只需改根pom.xml的两个属性。
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"dev": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build && node scripts/compress-vs.js",
|
||||
"build:no-compress": "vue-cli-service build",
|
||||
"build": "node scripts/sync-version.js && vue-cli-service build && node scripts/compress-vs.js",
|
||||
"build:no-compress": "node scripts/sync-version.js && vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
23
web-front/scripts/sync-version.js
Normal file
23
web-front/scripts/sync-version.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const pomPath = path.resolve(__dirname, '../../pom.xml');
|
||||
const pkgPath = path.resolve(__dirname, '../package.json');
|
||||
|
||||
const pomContent = fs.readFileSync(pomPath, 'utf-8');
|
||||
const match = pomContent.match(/<revision>([^<]+)<\/revision>/);
|
||||
if (!match) {
|
||||
console.error('sync-version: <revision> not found in root pom.xml');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const version = match[1];
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
||||
if (pkg.version === version) {
|
||||
console.log(`sync-version: package.json already at ${version}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
pkg.version = version;
|
||||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
||||
console.log(`sync-version: package.json ${pkg.version} -> ${version}`);
|
||||
@@ -73,7 +73,7 @@
|
||||
</div>
|
||||
<!-- 项目简介移到卡片内 -->
|
||||
<div class="project-intro">
|
||||
<div class="intro-title">NFD网盘直链解析0.3.0</div>
|
||||
<div class="intro-title">NFD网盘直链解析 {{ projectVersion }}</div>
|
||||
<div class="intro-desc">
|
||||
<div>支持网盘:蓝奏云、蓝奏云优享、小飞机盘、123云盘、iCloud、移动云空间、联想乐云、QQ闪传等 <el-link style="color:#606cf5" :href="githubRepoUrl + '?tab=readme-ov-file#%E7%BD%91%E7%9B%98%E6%94%AF%E6%8C%81%E6%83%85%E5%86%B5'" target="_blank"> >> </el-link></div>
|
||||
<div>文件夹解析支持:蓝奏云、蓝奏云优享、小飞机盘、123云盘</div>
|
||||
@@ -717,6 +717,9 @@ export default {
|
||||
githubRepoUrl() {
|
||||
return process.env.VUE_APP_GITHUB_REPO_URL
|
||||
},
|
||||
projectVersion() {
|
||||
return process.env.VUE_APP_VERSION || '0.0.0'
|
||||
},
|
||||
// 检查是否配置了认证信息(针对当前链接的网盘类型)
|
||||
hasAuthConfig() {
|
||||
const panType = this.getCurrentPanType()
|
||||
|
||||
@@ -16,6 +16,17 @@ function getGitHubRepoUrl() {
|
||||
} catch (e) {}
|
||||
return 'https://github.com/qaiu/netdisk-fast-download';
|
||||
}
|
||||
// 从根 pom.xml 读取项目版本号(单一版本来源)
|
||||
function getProjectVersion() {
|
||||
try {
|
||||
const pomContent = require('fs').readFileSync(path.resolve(__dirname, '../pom.xml'), 'utf-8');
|
||||
const match = pomContent.match(/<revision>([^<]+)<\/revision>/);
|
||||
if (match) return match[1];
|
||||
} catch (e) {}
|
||||
return require('./package.json').version;
|
||||
}
|
||||
const PROJECT_VERSION = getProjectVersion();
|
||||
|
||||
const GITHUB_REPO_URL = getGitHubRepoUrl();
|
||||
|
||||
const CompressionPlugin = require('compression-webpack-plugin');
|
||||
@@ -69,7 +80,8 @@ module.exports = {
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.VUE_APP_GITHUB_REPO_URL': JSON.stringify(GITHUB_REPO_URL)
|
||||
'process.env.VUE_APP_GITHUB_REPO_URL': JSON.stringify(GITHUB_REPO_URL),
|
||||
'process.env.VUE_APP_VERSION': JSON.stringify(PROJECT_VERSION)
|
||||
}),
|
||||
new MonacoEditorPlugin({
|
||||
languages: ['javascript', 'typescript', 'json'],
|
||||
|
||||
Reference in New Issue
Block a user