5 Commits

Author SHA1 Message Date
ctwj
d481083140 chore: bump version to v1.0.5 2025-07-20 22:59:12 +08:00
ctwj
c76298a10b chore: bump version to v1.0.4 2025-07-20 22:57:20 +08:00
ctwj
2cb91072ba chore: bump version to v1.0.3 2025-07-20 22:51:45 +08:00
ctwj
b84193c9e0 chore: bump version to v1.0.2 2025-07-20 22:46:51 +08:00
ctwj
ff79f9e9f3 update: version 2025-07-20 22:27:20 +08:00
10 changed files with 52 additions and 90 deletions

View File

@@ -1 +1 @@
1.0.1
1.0.5

View File

@@ -95,6 +95,19 @@ update_version_in_files() {
echo -e " ✅ 更新 web/package.json"
fi
# 更新useVersion.ts中的默认版本
if [ -f "web/composables/useVersion.ts" ]; then
# 使用更简单的模式匹配,先获取当前版本号
current_use_version=$(grep -o "version: '[0-9]\+\.[0-9]\+\.[0-9]\+'" web/composables/useVersion.ts | head -1)
if [ -n "$current_use_version" ]; then
sed -i.bak "s/$current_use_version/version: '${new_version}'/" web/composables/useVersion.ts
rm -f web/composables/useVersion.ts.bak
echo -e " ✅ 更新 web/composables/useVersion.ts"
else
echo -e " ⚠️ 未找到useVersion.ts中的版本号"
fi
fi
# 更新Docker镜像标签
if [ -f "docker-compose.yml" ]; then
sed -i.bak "s/image:.*:.*/image: urldb:${new_version}/" docker-compose.yml

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"runtime"
"strings"
"time"
)
@@ -22,12 +23,21 @@ type VersionInfo struct {
// 编译时注入的版本信息
var (
Version = "1.0.0"
Version = getVersionFromFile()
BuildTime = time.Now().Format("2006-01-02 15:04:05")
GitCommit = "unknown"
GitBranch = "unknown"
)
// getVersionFromFile 从VERSION文件读取版本号
func getVersionFromFile() string {
data, err := os.ReadFile("VERSION")
if err != nil {
return "1.0.0" // 默认版本
}
return strings.TrimSpace(string(data))
}
// GetVersionInfo 获取版本信息
func GetVersionInfo() *VersionInfo {
buildTime, _ := time.Parse("2006-01-02 15:04:05", BuildTime)

View File

@@ -12,7 +12,7 @@
<script setup lang="ts">
// 使用版本信息组合式函数
const { versionInfo } = useVersion()
const { versionInfo, fetchVersionInfo } = useVersion()
// 获取系统配置
const { data: systemConfigData } = await useAsyncData('systemConfig',
@@ -20,4 +20,9 @@ const { data: systemConfigData } = await useAsyncData('systemConfig',
)
const systemConfig = computed(() => (systemConfigData.value as any)?.data || { copyright: '© 2025 网盘资源数据库 By 老九' })
// 组件挂载时获取版本信息
onMounted(() => {
fetchVersionInfo()
})
</script>

View File

@@ -109,7 +109,7 @@
<script setup lang="ts">
interface VersionInfo {
version: string
build_time: string
build_time: string | Date
git_commit: string
git_branch: string
go_version: string
@@ -182,13 +182,13 @@ const refreshVersion = () => {
}
// 格式化时间
const formatTime = (timeStr: string) => {
if (!timeStr) return 'N/A'
const formatTime = (timeInput: string | Date) => {
if (!timeInput) return 'N/A'
try {
const date = new Date(timeStr)
const date = timeInput instanceof Date ? timeInput : new Date(timeInput)
return date.toLocaleString('zh-CN')
} catch {
return timeStr
return String(timeInput)
}
}

View File

@@ -18,7 +18,7 @@ interface VersionResponse {
export const useVersion = () => {
const versionInfo = ref<VersionInfo>({
version: '1.0.0',
version: '1.0.3',
build_time: '',
git_commit: 'unknown',
git_branch: 'unknown',

View File

@@ -1,6 +1,6 @@
{
"name": "res-db-web",
"version": "1.0.0",
"version": "1.0.3",
"private": true,
"type": "module",
"scripts": {

View File

@@ -14,22 +14,6 @@
</div>
<div class="max-w-7xl mx-auto">
<!-- 头部 -->
<div class="bg-slate-800 dark:bg-gray-800 text-white dark:text-gray-100 rounded-lg shadow-lg p-4 sm:p-8 mb-4 sm:mb-8 text-center flex items-center">
<nav class="mt-4 flex flex-col sm:flex-row justify-center gap-2 sm:gap-4">
<NuxtLink
to="/admin"
class="w-full sm:w-auto px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-md transition-colors text-center flex items-center justify-center gap-2"
>
<i class="fas fa-arrow-left"></i> 返回
</NuxtLink>
</nav>
<div class="flex-1">
<h1 class="text-2xl sm:text-3xl font-bold">
<NuxtLink to="/" class="text-white hover:text-gray-200 dark:hover:text-gray-300 no-underline">网盘资源数据库</NuxtLink>
</h1>
</div>
</div>
<!-- 自动处理配置状态 -->
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-4 mb-6">

View File

@@ -15,70 +15,6 @@
<!-- 版本信息组件 -->
<VersionInfo />
<!-- 版本历史 -->
<div class="mt-8 bg-white dark:bg-gray-800 rounded-lg shadow-md p-6">
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">
<i class="fas fa-history mr-2 text-green-500"></i>
版本历史
</h3>
<div class="space-y-4">
<div v-for="(version, index) in versionHistory" :key="index"
class="border-l-4 border-blue-500 pl-4 py-2">
<div class="flex items-center justify-between">
<div>
<h4 class="font-medium text-gray-900 dark:text-white">
v{{ version.version }}
</h4>
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
{{ version.date }}
</p>
</div>
<span class="px-2 py-1 text-xs rounded-full"
:class="getVersionTypeClass(version.type)">
{{ version.type }}
</span>
</div>
<ul class="mt-2 space-y-1">
<li v-for="(change, changeIndex) in version.changes" :key="changeIndex"
class="text-sm text-gray-600 dark:text-gray-400 flex items-start">
<span class="mr-2 mt-1" :class="getChangeTypeClass(change.type)">
{{ getChangeTypeIcon(change.type) }}
</span>
{{ change.description }}
</li>
</ul>
</div>
</div>
</div>
<!-- 构建信息 -->
<div class="mt-8 bg-white dark:bg-gray-800 rounded-lg shadow-md p-6">
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">
<i class="fas fa-cogs mr-2 text-purple-500"></i>
构建信息
</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="p-3 bg-gray-50 dark:bg-gray-700 rounded">
<span class="text-sm text-gray-600 dark:text-gray-400">构建环境</span>
<p class="font-mono text-gray-900 dark:text-white">Go 1.23.0</p>
</div>
<div class="p-3 bg-gray-50 dark:bg-gray-700 rounded">
<span class="text-sm text-gray-600 dark:text-gray-400">前端框架</span>
<p class="font-mono text-gray-900 dark:text-white">Nuxt.js 3.8.0</p>
</div>
<div class="p-3 bg-gray-50 dark:bg-gray-700 rounded">
<span class="text-sm text-gray-600 dark:text-gray-400">数据库</span>
<p class="font-mono text-gray-900 dark:text-white">PostgreSQL 15+</p>
</div>
<div class="p-3 bg-gray-50 dark:bg-gray-700 rounded">
<span class="text-sm text-gray-600 dark:text-gray-400">部署方式</span>
<p class="font-mono text-gray-900 dark:text-white">Docker</p>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,14 @@
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig()
const apiBase = config.public.apiBase || 'http://localhost:8080/api'
try {
const response = await $fetch(`${apiBase}/version`)
return response
} catch (error: any) {
throw createError({
statusCode: error.statusCode || 500,
statusMessage: error.statusMessage || '获取版本信息失败'
})
}
})