完善后台的图标库引用逻辑和在线图标库的引用

This commit is contained in:
2026-08-05 05:47:26 +08:00
parent ac740c24fd
commit e3aed70d6c
31 changed files with 3934 additions and 1678 deletions
+161 -189
View File
@@ -1,189 +1,161 @@
.PHONY: generate build build-linux build-windows build-darwin clean run dist frontend backend
# 生成Ent代码
generate:
cd internal/ent && go generate ./...
# 构建前端
frontend:
npm install
npm run build
# 构建后端(Linux
backend-linux:
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/home-vue-go main.go
chmod +x dist/home-vue-go
# 构建后端(Windows
backend-windows:
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/home-vue-go.exe main.go
# 构建后端(macOS
backend-darwin:
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/home-vue-go main.go
chmod +x dist/home-vue-go
# 构建后端(当前平台)
backend:
CGO_ENABLED=1 go build -ldflags="-s -w" -o dist/home-vue-go main.go
chmod +x dist/home-vue-go 2>/dev/null || true
# 完整构建到dist目录(Linux)- 单一可执行文件
build-linux: clean generate
@echo "========================================"
@echo "构建 Linux 版本"
@echo "========================================"
ifeq ($(OS),Windows_NT)
@if not exist dist mkdir dist
@call npm install && call npm run build
@if not exist dist\index.html (echo 错误: 前端构建失败 && exit 1)
@echo [提示] 在Windows上交叉编译Linux版本需要gcc工具链
@echo [提示] 如果遇到错误,推荐使用WSL或在Linux系统上直接构建
@echo [开始编译]...
@set CGO_ENABLED=1
@set GOOS=linux
@set GOARCH=amd64
@go build -ldflags="-s -w" -o dist\home-vue-go main.go
@if errorlevel 1 (
@echo.
@echo [错误] 交叉编译失败
@echo [原因] 在Windows上交叉编译Linux版本需要Linux的gcc工具链
@echo.
@echo [解决方案1] 使用WSL(推荐):
@echo wsl
@echo cd /mnt/d/Desktop/Home-Vue-go
@echo make build-linux
@echo.
@echo [解决方案2] 在Linux服务器上直接构建:
@echo git clone ^<your-repo^>
@echo cd Home-Vue-go
@echo make build-linux
@echo.
@echo [解决方案3] 安装gcc工具链(复杂):
@echo - 使用MSYS2: pacman -S mingw-w64-x86_64-gcc
@echo - 或使用TDM-GCC
@exit /b 1
)
@if exist dist\static rmdir /s /q dist\static 2>nul
@if exist dist\index.html del /f /q dist\index.html 2>nul
@if exist dist\favicon.ico del /f /q dist\favicon.ico 2>nul
@echo.
@echo 构建完成!单一可执行文件: dist\home-vue-go
@echo 后端API: http://localhost:1551
@echo 前端界面: http://localhost:1552
@echo 1Panel配置: 只需配置1551和1552端口,运行命令: ./home-vue-go
else
@mkdir -p dist
@npm install && npm run build
@if [ ! -f "dist/index.html" ]; then echo "错误: 前端构建失败"; exit 1; fi
@CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/home-vue-go main.go
@chmod +x dist/home-vue-go
@rm -rf dist/static dist/index.html dist/favicon.ico 2>/dev/null || true
@echo ""
@echo "构建完成!单一可执行文件: dist/home-vue-go"
@echo "后端API: http://localhost:1551"
@echo "前端界面: http://localhost:1552"
@echo "1Panel配置: 只需配置1551和1552端口,运行命令: ./home-vue-go"
endif
# 完整构建到dist目录(Windows)- 单一可执行文件
build-windows: clean generate
@echo ========================================
@echo 构建 Windows 版本
@echo ========================================
@if not exist dist mkdir dist
@npm install && npm run build
@if not exist dist\index.html (echo 错误: 前端构建失败 && exit 1)
@set CGO_ENABLED=1 && go build -ldflags="-s -w" -o dist\home-vue-go.exe main.go
@if exist dist\static rmdir /s /q dist\static
@if exist dist\index.html del /f /q dist\index.html
@if exist dist\favicon.ico del /f /q dist\favicon.ico
@echo.
@echo 构建完成!单一可执行文件: dist\home-vue-go.exe
@echo 后端API: http://localhost:1551
@echo 前端界面: http://localhost:1552
@echo 1Panel配置: 只需配置1551和1552端口,运行命令: ./home-vue-go.exe
# 完整构建到dist目录(macOS)- 单一可执行文件
build-darwin: clean generate
@echo "========================================"
@echo "构建 macOS 版本"
@echo "========================================"
ifeq ($(OS),Windows_NT)
@if not exist dist mkdir dist
@call npm install && call npm run build
@if not exist dist\index.html (echo 错误: 前端构建失败 && exit 1)
@set CGO_ENABLED=1 && set GOOS=darwin && set GOARCH=amd64 && go build -ldflags="-s -w" -o dist\home-vue-go main.go
@if exist dist\static rmdir /s /q dist\static 2>nul
@if exist dist\index.html del /f /q dist\index.html 2>nul
@if exist dist\favicon.ico del /f /q dist\favicon.ico 2>nul
@echo.
@echo 构建完成!单一可执行文件: dist\home-vue-go
@echo 后端API: http://localhost:1551
@echo 前端界面: http://localhost:1552
else
@mkdir -p dist
@npm install && npm run build
@if [ ! -f "dist/index.html" ]; then echo "错误: 前端构建失败"; exit 1; fi
@CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/home-vue-go main.go
@chmod +x dist/home-vue-go
@rm -rf dist/static dist/index.html dist/favicon.ico 2>/dev/null || true
@echo ""
@echo "构建完成!单一可执行文件: dist/home-vue-go"
@echo "后端API: http://localhost:1551"
@echo "前端界面: http://localhost:1552"
endif
# 完整构建到dist目录(当前平台)- 单一可执行文件
build: clean generate
@echo "========================================"
@echo "构建当前平台版本"
@echo "========================================"
ifeq ($(OS),Windows_NT)
@if not exist dist mkdir dist
@call npm install && call npm run build
@if not exist dist\index.html (echo 错误: 前端构建失败 && exit 1)
@set CGO_ENABLED=1 && go build -ldflags="-s -w" -o dist\home-vue-go.exe main.go
@if exist dist\static rmdir /s /q dist\static 2>nul
@if exist dist\index.html del /f /q dist\index.html 2>nul
@if exist dist\favicon.ico del /f /q dist\favicon.ico 2>nul
@echo.
@echo 构建完成!单一可执行文件: dist\home-vue-go.exe
@echo 后端API: http://localhost:1551
@echo 前端界面: http://localhost:1552
@echo 1Panel配置: 只需配置1551和1552端口,运行命令: ./home-vue-go.exe
else
@mkdir -p dist
@npm install && npm run build
@if [ ! -f "dist/index.html" ]; then echo "错误: 前端构建失败"; exit 1; fi
@CGO_ENABLED=1 go build -ldflags="-s -w" -o dist/home-vue-go main.go
@chmod +x dist/home-vue-go 2>/dev/null || true
@rm -rf dist/static dist/index.html dist/favicon.ico 2>/dev/null || true
@echo ""
@echo "构建完成!单一可执行文件: dist/home-vue-go"
@echo "后端API: http://localhost:1551"
@echo "前端界面: http://localhost:1552"
@echo "1Panel配置: 只需配置1551和1552端口,运行命令: ./home-vue-go"
endif
# 打包到dist目录(推荐使用)
dist: build
# 运行开发服务器
run:
go run main.go
# 清理
clean:
@echo "清理构建文件..."
ifeq ($(OS),Windows_NT)
@if exist home-vue-go.exe del /f /q home-vue-go.exe 2>nul
@if exist home-vue-go del /f /q home-vue-go 2>nul
@if exist dist rmdir /s /q dist 2>nul
@if exist node_modules rmdir /s /q node_modules 2>nul
else
@rm -f home-vue-go home-vue-go.exe 2>/dev/null || true
@rm -rf dist 2>/dev/null || true
@rm -rf node_modules 2>/dev/null || true
endif
@echo "清理完成"
.PHONY: generate frontend backend backend-linux backend-windows backend-darwin \
build build-linux build-windows build-darwin clean clean-all dist run
.NOTPARALLEL:
GO ?= go
NPM ?= npm
GOPROXY ?= https://goproxy.cn,direct
DIST_DIR := dist
BINARY_NAME := home-vue-go
WINDOWS_TEMP := $(BINARY_NAME)-windows-amd64.exe
LINUX_TEMP := $(BINARY_NAME)-linux-amd64
DARWIN_TEMP := $(BINARY_NAME)-darwin-amd64
ifeq ($(OS),Windows_NT)
NPM_CMD := npm.cmd
else
NPM_CMD := $(NPM)
endif
# Generated Ent sources are committed. Run this target only after schema changes.
generate:
@echo [generate] Updating Ent sources...
ifeq ($(OS),Windows_NT)
@cd internal\ent && set "GOPROXY=$(GOPROXY)" && set "CGO_ENABLED=0" && set "GOARCH=amd64" && $(GO) generate ./...
else
@cd internal/ent && GOPROXY="$(GOPROXY)" $(GO) generate ./...
endif
@echo [generate] Done.
# Install missing packages without deleting a usable local dependency tree.
frontend:
@echo [frontend] Installing dependencies...
@$(NPM_CMD) install --prefer-offline --no-audit --no-fund
@echo [frontend] Building production assets...
@$(NPM_CMD) run build
# Backend-only targets keep frontend files beside the executable for debugging.
backend-windows: frontend
@echo [backend] Building Windows amd64 executable...
ifeq ($(OS),Windows_NT)
@set "GOPROXY=$(GOPROXY)" && set "CGO_ENABLED=0" && set "GOOS=windows" && set "GOARCH=amd64" && $(GO) build -trimpath -ldflags="-s -w" -o $(DIST_DIR)\$(BINARY_NAME).exe .
else
@GOPROXY="$(GOPROXY)" CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GO) build -trimpath -ldflags="-s -w" -o $(DIST_DIR)/$(BINARY_NAME).exe .
endif
backend-linux: frontend
@echo [backend] Building Linux amd64 executable...
ifeq ($(OS),Windows_NT)
@set "GOPROXY=$(GOPROXY)" && set "CGO_ENABLED=0" && set "GOOS=linux" && set "GOARCH=amd64" && $(GO) build -trimpath -ldflags="-s -w" -o $(DIST_DIR)\$(BINARY_NAME) .
else
@GOPROXY="$(GOPROXY)" CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -trimpath -ldflags="-s -w" -o $(DIST_DIR)/$(BINARY_NAME) .
@chmod +x $(DIST_DIR)/$(BINARY_NAME)
endif
backend-darwin: frontend
@echo [backend] Building macOS amd64 executable...
ifeq ($(OS),Windows_NT)
@set "GOPROXY=$(GOPROXY)" && set "CGO_ENABLED=0" && set "GOOS=darwin" && set "GOARCH=amd64" && $(GO) build -trimpath -ldflags="-s -w" -o $(DIST_DIR)\$(BINARY_NAME) .
else
@GOPROXY="$(GOPROXY)" CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build -trimpath -ldflags="-s -w" -o $(DIST_DIR)/$(BINARY_NAME) .
@chmod +x $(DIST_DIR)/$(BINARY_NAME)
endif
backend: frontend
@echo [backend] Building for the current platform...
ifeq ($(OS),Windows_NT)
@set "GOPROXY=$(GOPROXY)" && set "CGO_ENABLED=0" && $(GO) build -trimpath -ldflags="-s -w" -o $(DIST_DIR)\$(BINARY_NAME).exe .
else
@GOPROXY="$(GOPROXY)" CGO_ENABLED=0 $(GO) build -trimpath -ldflags="-s -w" -o $(DIST_DIR)/$(BINARY_NAME) .
@chmod +x $(DIST_DIR)/$(BINARY_NAME)
endif
# Full builds embed frontend assets, then remove the duplicate loose files.
build-windows: clean frontend
@echo [build] Building Windows amd64 package...
ifeq ($(OS),Windows_NT)
@set "GOPROXY=$(GOPROXY)" && set "CGO_ENABLED=0" && set "GOOS=windows" && set "GOARCH=amd64" && $(GO) build -trimpath -ldflags="-s -w" -o $(WINDOWS_TEMP) .
@if exist $(DIST_DIR) rmdir /s /q $(DIST_DIR)
@mkdir $(DIST_DIR)
@move /y $(WINDOWS_TEMP) $(DIST_DIR)\$(BINARY_NAME).exe >nul
else
@GOPROXY="$(GOPROXY)" CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GO) build -trimpath -ldflags="-s -w" -o $(WINDOWS_TEMP) .
@rm -rf $(DIST_DIR) && mkdir -p $(DIST_DIR)
@mv $(WINDOWS_TEMP) $(DIST_DIR)/$(BINARY_NAME).exe
endif
@echo [build] Output: $(DIST_DIR)/$(BINARY_NAME).exe
build-linux: clean frontend
@echo [build] Building Linux amd64 package...
ifeq ($(OS),Windows_NT)
@set "GOPROXY=$(GOPROXY)" && set "CGO_ENABLED=0" && set "GOOS=linux" && set "GOARCH=amd64" && $(GO) build -trimpath -ldflags="-s -w" -o $(LINUX_TEMP) .
@if exist $(DIST_DIR) rmdir /s /q $(DIST_DIR)
@mkdir $(DIST_DIR)
@move /y $(LINUX_TEMP) $(DIST_DIR)\$(BINARY_NAME) >nul
else
@GOPROXY="$(GOPROXY)" CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -trimpath -ldflags="-s -w" -o $(LINUX_TEMP) .
@rm -rf $(DIST_DIR) && mkdir -p $(DIST_DIR)
@mv $(LINUX_TEMP) $(DIST_DIR)/$(BINARY_NAME)
@chmod +x $(DIST_DIR)/$(BINARY_NAME)
endif
@echo [build] Output: $(DIST_DIR)/$(BINARY_NAME)
build-darwin: clean frontend
@echo [build] Building macOS amd64 package...
ifeq ($(OS),Windows_NT)
@set "GOPROXY=$(GOPROXY)" && set "CGO_ENABLED=0" && set "GOOS=darwin" && set "GOARCH=amd64" && $(GO) build -trimpath -ldflags="-s -w" -o $(DARWIN_TEMP) .
@if exist $(DIST_DIR) rmdir /s /q $(DIST_DIR)
@mkdir $(DIST_DIR)
@move /y $(DARWIN_TEMP) $(DIST_DIR)\$(BINARY_NAME) >nul
else
@GOPROXY="$(GOPROXY)" CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build -trimpath -ldflags="-s -w" -o $(DARWIN_TEMP) .
@rm -rf $(DIST_DIR) && mkdir -p $(DIST_DIR)
@mv $(DARWIN_TEMP) $(DIST_DIR)/$(BINARY_NAME)
@chmod +x $(DIST_DIR)/$(BINARY_NAME)
endif
@echo [build] Output: $(DIST_DIR)/$(BINARY_NAME)
ifeq ($(OS),Windows_NT)
build: build-windows
else
build: clean frontend
@echo [build] Building current platform package...
@GOPROXY="$(GOPROXY)" CGO_ENABLED=0 $(GO) build -trimpath -ldflags="-s -w" -o $(BINARY_NAME) .
@rm -rf $(DIST_DIR) && mkdir -p $(DIST_DIR)
@mv $(BINARY_NAME) $(DIST_DIR)/$(BINARY_NAME)
@chmod +x $(DIST_DIR)/$(BINARY_NAME)
@echo [build] Output: $(DIST_DIR)/$(BINARY_NAME)
endif
dist: build
run:
ifeq ($(OS),Windows_NT)
@set "GOPROXY=$(GOPROXY)" && set "CGO_ENABLED=0" && $(GO) run .
else
@GOPROXY="$(GOPROXY)" CGO_ENABLED=0 $(GO) run .
endif
clean:
@echo [clean] Removing build artifacts...
ifeq ($(OS),Windows_NT)
@if exist $(DIST_DIR) rmdir /s /q $(DIST_DIR)
@if exist $(BINARY_NAME).exe del /f /q $(BINARY_NAME).exe
@if exist $(WINDOWS_TEMP) del /f /q $(WINDOWS_TEMP)
@if exist $(LINUX_TEMP) del /f /q $(LINUX_TEMP)
@if exist $(DARWIN_TEMP) del /f /q $(DARWIN_TEMP)
else
@rm -rf $(DIST_DIR)
@rm -f $(BINARY_NAME) $(BINARY_NAME).exe $(WINDOWS_TEMP) $(LINUX_TEMP) $(DARWIN_TEMP)
endif
@echo [clean] Done.
clean-all: clean
@echo [clean] Removing frontend dependencies...
ifeq ($(OS),Windows_NT)
@if exist node_modules rmdir /s /q node_modules
else
@rm -rf node_modules
endif
@echo [clean] Dependency cleanup complete.