mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-10 15:37:28 +00:00
refactor: GitHub URL 改为构建时自动从 git remote origin 识别
前端:vue.config.js 通过 DefinePlugin 注入 VUE_APP_GITHUB_REPO_URL, Home.vue/Playground.vue 中硬编码的 GitHub URL 全部改为动态变量。 后端:parser/pom.xml 添加 gmavenplus-plugin 在 initialize 阶段从 git remote origin 解析 github.owner/github.repo,SCM 字段引用 property。
This commit is contained in:
@@ -35,9 +35,9 @@
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://github.com/yukaidi1220/netdisk-fast-download.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com:yukaidi1220/netdisk-fast-download.git</developerConnection>
|
||||
<url>https://github.com/yukaidi1220/netdisk-fast-download</url>
|
||||
<connection>scm:git:https://github.com/${github.owner}/${github.repo}.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com:${github.owner}/${github.repo}.git</developerConnection>
|
||||
<url>https://github.com/${github.owner}/${github.repo}</url>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
@@ -124,6 +124,34 @@
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<!-- 从 git remote origin 自动识别 GitHub 仓库地址 -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.gmavenplus</groupId>
|
||||
<artifactId>gmavenplus-plugin</artifactId>
|
||||
<version>4.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>initialize</phase>
|
||||
<goals><goal>execute</goal></goals>
|
||||
<configuration>
|
||||
<scripts>
|
||||
<script>
|
||||
def url = 'git remote get-url origin'.execute().text.trim()
|
||||
def m = url =~ /github\.com[:/]([^/]+)\/([^/.]+?)(?:\.git)?$/
|
||||
if (m.find()) {
|
||||
project.properties.setProperty('github.owner', m.group(1))
|
||||
project.properties.setProperty('github.repo', m.group(2))
|
||||
} else {
|
||||
project.properties.setProperty('github.owner', 'qaiu')
|
||||
project.properties.setProperty('github.repo', 'netdisk-fast-download')
|
||||
}
|
||||
</script>
|
||||
</scripts>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- 编译 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
</el-dialog> -->
|
||||
<!-- 顶部反馈栏(小号、灰色、无红边框) -->
|
||||
<div class="feedback-bar">
|
||||
<a href="https://github.com/yukaidi1220/netdisk-fast-download/issues" target="_blank" rel="noopener" class="feedback-link mini">
|
||||
<a :href="githubRepoUrl + '/issues'" target="_blank" rel="noopener" class="feedback-link mini">
|
||||
<i class="fas fa-bug feedback-icon"></i>
|
||||
反馈
|
||||
</a>
|
||||
<a href="https://github.com/yukaidi1220/netdisk-fast-download" target="_blank" rel="noopener" class="feedback-link mini">
|
||||
<a :href="githubRepoUrl" target="_blank" rel="noopener" class="feedback-link mini">
|
||||
<i class="fab fa-github feedback-icon"></i>
|
||||
源码
|
||||
</a>
|
||||
@@ -75,7 +75,7 @@
|
||||
<div class="project-intro">
|
||||
<div class="intro-title">NFD网盘直链解析0.3.0</div>
|
||||
<div class="intro-desc">
|
||||
<div>支持网盘:蓝奏云、蓝奏云优享、小飞机盘、123云盘、iCloud、移动云空间、联想乐云、QQ闪传等 <el-link style="color:#606cf5" href="https://github.com/yukaidi1220/netdisk-fast-download?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云盘、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>
|
||||
</div>
|
||||
</div>
|
||||
@@ -714,6 +714,9 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
githubRepoUrl() {
|
||||
return process.env.VUE_APP_GITHUB_REPO_URL
|
||||
},
|
||||
// 检查是否配置了认证信息(针对当前链接的网盘类型)
|
||||
hasAuthConfig() {
|
||||
const panType = this.getCurrentPanType()
|
||||
@@ -1436,7 +1439,7 @@ export default {
|
||||
错误信息:${JSON.stringify(this.errorDetail, null, 2)}`;
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
this.$message.success('已复制分享信息和错误详情');
|
||||
window.open('https://github.com/yukaidi1220/netdisk-fast-download/issues/new', '_blank', 'noopener,noreferrer');
|
||||
window.open(`${this.githubRepoUrl}/issues/new`, '_blank', 'noopener,noreferrer');
|
||||
}).catch(() => {
|
||||
this.$message.error('复制失败');
|
||||
});
|
||||
|
||||
@@ -653,22 +653,22 @@
|
||||
<p>更多详细信息,请参考 GitHub 仓库文档:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://github.com/yukaidi1220/netdisk-fast-download/blob/main/parser/doc/JAVASCRIPT_PARSER_GUIDE.md" target="_blank" rel="noopener noreferrer">
|
||||
<a :href="githubRepoUrl + '/blob/main/parser/doc/JAVASCRIPT_PARSER_GUIDE.md'" target="_blank" rel="noopener noreferrer">
|
||||
JavaScript 解析器开发指南
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/yukaidi1220/netdisk-fast-download/blob/main/parser/doc/CUSTOM_PARSER_GUIDE.md" target="_blank" rel="noopener noreferrer">
|
||||
<a :href="githubRepoUrl + '/blob/main/parser/doc/CUSTOM_PARSER_GUIDE.md'" target="_blank" rel="noopener noreferrer">
|
||||
自定义解析器扩展指南
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/yukaidi1220/netdisk-fast-download/blob/main/parser/doc/CUSTOM_PARSER_QUICKSTART.md" target="_blank" rel="noopener noreferrer">
|
||||
<a :href="githubRepoUrl + '/blob/main/parser/doc/CUSTOM_PARSER_QUICKSTART.md'" target="_blank" rel="noopener noreferrer">
|
||||
快速开始教程
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/yukaidi1220/netdisk-fast-download/blob/main/parser/README.md" target="_blank" rel="noopener noreferrer">
|
||||
<a :href="githubRepoUrl + '/blob/main/parser/README.md'" target="_blank" rel="noopener noreferrer">
|
||||
解析器模块文档
|
||||
</a>
|
||||
</li>
|
||||
@@ -858,6 +858,7 @@ export default {
|
||||
},
|
||||
setup() {
|
||||
const router = useRouter();
|
||||
const githubRepoUrl = process.env.VUE_APP_GITHUB_REPO_URL;
|
||||
|
||||
// 语言常量
|
||||
const LANGUAGE = {
|
||||
@@ -2268,6 +2269,7 @@ curl "${baseUrl}/json/parser?url=${encodeURIComponent(exampleUrl)}"</pre>
|
||||
});
|
||||
|
||||
return {
|
||||
githubRepoUrl,
|
||||
LANGUAGE,
|
||||
editorRef,
|
||||
jsCode,
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
|
||||
const path = require("path");
|
||||
const { execSync } = require("child_process");
|
||||
const webpack = require("webpack");
|
||||
|
||||
function resolve(dir) {
|
||||
return path.join(__dirname, dir)
|
||||
}
|
||||
|
||||
// 从 git remote origin 自动识别 GitHub 仓库地址
|
||||
function getGitHubRepoUrl() {
|
||||
try {
|
||||
const remoteUrl = execSync('git remote get-url origin', { encoding: 'utf-8', cwd: path.resolve(__dirname, '..') }).trim();
|
||||
const match = remoteUrl.match(/github\.com[:/]([^/]+\/[^/.]+?)(?:\.git)?$/);
|
||||
if (match) return `https://github.com/${match[1]}`;
|
||||
} catch (e) {}
|
||||
return 'https://github.com/qaiu/netdisk-fast-download';
|
||||
}
|
||||
const GITHUB_REPO_URL = getGitHubRepoUrl();
|
||||
|
||||
const CompressionPlugin = require('compression-webpack-plugin');
|
||||
const FileManagerPlugin = require('filemanager-webpack-plugin');
|
||||
const MonacoEditorPlugin = require('monaco-editor-webpack-plugin');
|
||||
@@ -55,6 +68,9 @@ module.exports = {
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.VUE_APP_GITHUB_REPO_URL': JSON.stringify(GITHUB_REPO_URL)
|
||||
}),
|
||||
new MonacoEditorPlugin({
|
||||
languages: ['javascript', 'typescript', 'json'],
|
||||
features: ['coreCommands', 'find', 'format', 'suggest', 'quickCommand'],
|
||||
|
||||
Reference in New Issue
Block a user