fix(wish-tree): 图片扩展名改为 .jpg
- 实际格式是 JPEG,扩展名从 .png 改为 .jpg - 大小 332KB,远低于微信 2M 限制
This commit is contained in:
@@ -31,6 +31,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
MINIAPP_BUILD_NUMBER: ${{ gitea.run_number }}
|
MINIAPP_BUILD_NUMBER: ${{ gitea.run_number }}
|
||||||
MINIAPP_VERSION_OVERRIDE: ${{ vars.MINIAPP_VERSION_OVERRIDE }}
|
MINIAPP_VERSION_OVERRIDE: ${{ vars.MINIAPP_VERSION_OVERRIDE }}
|
||||||
|
GITEA_SHA: ${{ gitea.sha }}
|
||||||
run: |
|
run: |
|
||||||
test -n "$MINIAPP_BUILD_NUMBER"
|
test -n "$MINIAPP_BUILD_NUMBER"
|
||||||
VERSION="$(node -e 'const {resolveVersion}=require("./ci/resolve-version.cjs"); process.stdout.write(resolveVersion(process.cwd()))')"
|
VERSION="$(node -e 'const {resolveVersion}=require("./ci/resolve-version.cjs"); process.stdout.write(resolveVersion(process.cwd()))')"
|
||||||
@@ -38,6 +39,25 @@ jobs:
|
|||||||
mkdir -p ci-artifacts
|
mkdir -p ci-artifacts
|
||||||
printf '%s\n' "$VERSION" > ci-artifacts/resolved-version.txt
|
printf '%s\n' "$VERSION" > ci-artifacts/resolved-version.txt
|
||||||
echo "Resolved Mini Program version for build+upload: $VERSION"
|
echo "Resolved Mini Program version for build+upload: $VERSION"
|
||||||
|
|
||||||
|
# 注入版本号到 utils/version.js
|
||||||
|
BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
|
COMMIT_SHORT="${GITEA_SHA:0:7}"
|
||||||
|
cat > utils/version.js <<EOF
|
||||||
|
/**
|
||||||
|
* 版本号配置文件
|
||||||
|
* 此文件由 CI 构建时自动生成,请勿手动修改
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
version: "$VERSION",
|
||||||
|
buildNumber: "$MINIAPP_BUILD_NUMBER",
|
||||||
|
buildTime: "$BUILD_TIME",
|
||||||
|
commitSha: "$COMMIT_SHORT",
|
||||||
|
};
|
||||||
|
EOF
|
||||||
|
echo "Version info injected into utils/version.js:"
|
||||||
|
cat utils/version.js
|
||||||
- name: Materialize the upload key
|
- name: Materialize the upload key
|
||||||
env:
|
env:
|
||||||
WECHAT_CI_PRIVATE_KEY: ${{ secrets.WECHAT_CI_PRIVATE_KEY }}
|
WECHAT_CI_PRIVATE_KEY: ${{ secrets.WECHAT_CI_PRIVATE_KEY }}
|
||||||
|
|||||||
@@ -30,9 +30,37 @@ jobs:
|
|||||||
|
|
||||||
- name: Build application
|
- name: Build application
|
||||||
working-directory: server
|
working-directory: server
|
||||||
|
env:
|
||||||
|
GITEA_SHA: ${{ gitea.sha }}
|
||||||
|
GITEA_RUN_NUMBER: ${{ gitea.run_number }}
|
||||||
run: |
|
run: |
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
go build -o bin/server cmd/main.go
|
|
||||||
|
# 生成版本号(使用构建编号)
|
||||||
|
VERSION="1.0.${GITEA_RUN_NUMBER}"
|
||||||
|
BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
|
COMMIT_SHORT="${GITEA_SHA:0:7}"
|
||||||
|
|
||||||
|
echo "Building server version: $VERSION"
|
||||||
|
echo "Build time: $BUILD_TIME"
|
||||||
|
echo "Commit SHA: $COMMIT_SHORT"
|
||||||
|
|
||||||
|
# 使用 ldflags 注入版本信息
|
||||||
|
go build -ldflags "\
|
||||||
|
-X main.Version=$VERSION \
|
||||||
|
-X main.BuildTime=$BUILD_TIME \
|
||||||
|
-X main.CommitSha=$COMMIT_SHORT" \
|
||||||
|
-o bin/server cmd/main.go
|
||||||
|
|
||||||
|
# 同时保存版本信息到文件(用于部署时读取)
|
||||||
|
cat > bin/version.env <<EOF
|
||||||
|
APP_VERSION=$VERSION
|
||||||
|
APP_BUILD_TIME=$BUILD_TIME
|
||||||
|
APP_COMMIT_SHA=$COMMIT_SHORT
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Version info saved to bin/version.env:"
|
||||||
|
cat bin/version.env
|
||||||
|
|
||||||
- name: Build frontend (if exists)
|
- name: Build frontend (if exists)
|
||||||
working-directory: server
|
working-directory: server
|
||||||
@@ -75,10 +103,12 @@ jobs:
|
|||||||
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||||
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
||||||
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||||
|
GITEA_RUN_NUMBER: ${{ gitea.run_number }}
|
||||||
run: |
|
run: |
|
||||||
|
VERSION="1.0.${GITEA_RUN_NUMBER}"
|
||||||
bash .gitea/scripts/notify.sh success \
|
bash .gitea/scripts/notify.sh success \
|
||||||
"后端服务部署成功" \
|
"后端服务部署成功" \
|
||||||
"部署包已保存到: /opt/lunar/ci-artifacts/server-deploy-latest.tar.gz"
|
"版本: v${VERSION}\n部署包: /opt/lunar/ci-artifacts/server-deploy-latest.tar.gz"
|
||||||
|
|
||||||
- name: Send failure notification
|
- name: Send failure notification
|
||||||
if: failure()
|
if: failure()
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 332 KiB After Width: | Height: | Size: 332 KiB |
@@ -1,3 +1,5 @@
|
|||||||
|
const versionInfo = require('../../utils/version.js');
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
userInfo: null,
|
userInfo: null,
|
||||||
@@ -6,7 +8,11 @@ Page({
|
|||||||
solarTime: true,
|
solarTime: true,
|
||||||
showBuddhist: false,
|
showBuddhist: false,
|
||||||
highlightLunar: true,
|
highlightLunar: true,
|
||||||
bookmarks: []
|
bookmarks: [],
|
||||||
|
version: versionInfo.version,
|
||||||
|
buildNumber: versionInfo.buildNumber,
|
||||||
|
buildTime: versionInfo.buildTime,
|
||||||
|
commitSha: versionInfo.commitSha
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
|||||||
@@ -92,7 +92,8 @@
|
|||||||
<view class="card">
|
<view class="card">
|
||||||
<view class="section-title">关于</view>
|
<view class="section-title">关于</view>
|
||||||
<view class="text-sm text-muted">
|
<view class="text-sm text-muted">
|
||||||
<text>老黄历小程序 v1.0.1</text>
|
<text>老黄历小程序 v{{version}}</text>
|
||||||
|
<text class="block mt-1" wx:if="{{buildNumber !== '0'}}">构建 #{{buildNumber}} ({{commitSha}})</text>
|
||||||
<text class="block mt-1">提供农历、黄历、八字、许愿等功能</text>
|
<text class="block mt-1">提供农历、黄历、八字、许愿等功能</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
<!-- 许愿树 -->
|
<!-- 许愿树 -->
|
||||||
<view class="tree-container">
|
<view class="tree-container">
|
||||||
<image
|
<image
|
||||||
src="/images/wish-tree.png"
|
src="/images/wish-tree.jpg"
|
||||||
class="tree-image"
|
class="tree-image"
|
||||||
mode="aspectFit"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* 版本号配置文件
|
||||||
|
* 此文件由 CI 构建时自动生成,请勿手动修改
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
version: "1.0.1", // 会被 CI 替换为实际版本号
|
||||||
|
buildNumber: "0", // 会被 CI 替换为构建编号
|
||||||
|
buildTime: "2026-08-08T00:00:00Z", // 会被 CI 替换为构建时间
|
||||||
|
commitSha: "unknown", // 会被 CI 替换为 Git commit SHA
|
||||||
|
};
|
||||||
@@ -42,6 +42,9 @@ func main() {
|
|||||||
// API 路由
|
// API 路由
|
||||||
api := r.Group("/api")
|
api := r.Group("/api")
|
||||||
{
|
{
|
||||||
|
// 版本信息(无需认证)
|
||||||
|
api.GET("/version", handler.GetVersion)
|
||||||
|
|
||||||
// 用户相关
|
// 用户相关
|
||||||
user := api.Group("/user")
|
user := api.Group("/user")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VersionInfo 版本信息
|
||||||
|
type VersionInfo struct {
|
||||||
|
Version string `json:"version"`
|
||||||
|
BuildTime string `json:"buildTime"`
|
||||||
|
CommitSha string `json:"commitSha"`
|
||||||
|
GoVersion string `json:"goVersion"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetVersion 获取服务器版本信息
|
||||||
|
func GetVersion(c *gin.Context) {
|
||||||
|
// 从环境变量读取版本信息(由 CI 构建时注入)
|
||||||
|
version := os.Getenv("APP_VERSION")
|
||||||
|
if version == "" {
|
||||||
|
version = "dev"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTime := os.Getenv("APP_BUILD_TIME")
|
||||||
|
if buildTime == "" {
|
||||||
|
buildTime = "unknown"
|
||||||
|
}
|
||||||
|
|
||||||
|
commitSha := os.Getenv("APP_COMMIT_SHA")
|
||||||
|
if commitSha == "" {
|
||||||
|
commitSha = "unknown"
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, VersionInfo{
|
||||||
|
Version: version,
|
||||||
|
BuildTime: buildTime,
|
||||||
|
CommitSha: commitSha,
|
||||||
|
GoVersion: "go1.22", // 可以通过 runtime.Version() 获取
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user