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:
yukaidi
2026-05-29 10:29:44 +08:00
parent 4a0fe61d30
commit cfe8352d45
4 changed files with 60 additions and 11 deletions

View File

@@ -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>