Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e67176edf | ||
|
|
151d0343aa | ||
|
|
994f7b71dd | ||
|
|
a4313ef770 | ||
|
|
65dc1861da | ||
|
|
4079fd0e69 | ||
|
|
ac0d673d3b | ||
|
|
0478c201db | ||
|
|
1f25df980d | ||
|
|
bed116fcb7 | ||
|
|
7db2097435 | ||
|
|
cefb7005db |
No files matched your search
@@ -50,6 +50,9 @@ jobs:
|
||||
- name: Type check and build
|
||||
run: |
|
||||
cd frontend
|
||||
# 设置构建环境变量,确保与本地构建一致
|
||||
export VITE_OUTDIR=production
|
||||
export VITE_ADDRESS_BASE_URL=/production/
|
||||
# 并行执行类型检查和构建以节省时间
|
||||
npm run type-check &
|
||||
npm run build:prod &
|
||||
@@ -57,9 +60,12 @@ jobs:
|
||||
# 检查构建结果
|
||||
echo "Build completed, checking production directory:"
|
||||
ls -la production/
|
||||
# 验证构建产物中的 base 路径
|
||||
echo "Verifying base path in index.html:"
|
||||
grep -o 'href="/production/' production/index.html | head -1 || echo "Warning: base path not found"
|
||||
|
||||
# 预处理部署目录权限
|
||||
- name: Prepare deployment directory
|
||||
# 准备临时部署目录
|
||||
- name: Prepare temp directory
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.HOST_PI }}
|
||||
@@ -67,61 +73,105 @@ jobs:
|
||||
password: ${{ secrets.PASS_PI }}
|
||||
port: 22
|
||||
script: |
|
||||
echo "Preparing deployment directory..."
|
||||
sudo rm -rf /home/pi/lm-www/frontend_tmp
|
||||
sudo mkdir -p /home/pi/lm-www/frontend_tmp/production
|
||||
sudo chown -R pi:pi /home/pi/lm-www/frontend_tmp
|
||||
|
||||
# 安装 rsync(用于带进度显示的文件传输)
|
||||
- name: Install rsync
|
||||
run: sudo apt-get update && sudo apt-get install -y rsync sshpass
|
||||
|
||||
# 计算要传输的文件总大小
|
||||
- name: Calculate total size
|
||||
id: calc_size
|
||||
run: |
|
||||
cd frontend/production
|
||||
TOTAL_SIZE=$(du -sb . | cut -f1)
|
||||
echo "total_size=$TOTAL_SIZE" >> $GITHUB_OUTPUT
|
||||
echo "Total size to transfer: $(numfmt --to=iec-i --suffix=B $TOTAL_SIZE)"
|
||||
|
||||
# 将构建产物传输到服务器(带进度显示)
|
||||
- name: Copy build files to server with progress
|
||||
run: |
|
||||
set -e
|
||||
echo "Starting file transfer with rsync..."
|
||||
|
||||
# 启动后台传输(使用 --info=progress2 只显示总体进度,减少输出)
|
||||
sshpass -p "${{ secrets.PASS_PI }}" rsync -avz --info=progress2 \
|
||||
-e "ssh -o StrictHostKeyChecking=no" \
|
||||
frontend/production/ \
|
||||
pi@${{ secrets.HOST_PI }}:/home/pi/lm-www/frontend_tmp/production/ > /tmp/rsync.log 2>&1 &
|
||||
RSYNC_PID=$!
|
||||
|
||||
# 每10秒显示一次进度
|
||||
TOTAL_SIZE=${{ steps.calc_size.outputs.total_size }}
|
||||
echo "📦 Total size: $(numfmt --to=iec-i --suffix=B $TOTAL_SIZE 2>/dev/null || echo "${TOTAL_SIZE}B")"
|
||||
|
||||
while kill -0 $RSYNC_PID 2>/dev/null; do
|
||||
sleep 10
|
||||
# 通过SSH检查目标目录大小
|
||||
TRANSFERRED=$(sshpass -p "${{ secrets.PASS_PI }}" ssh -o StrictHostKeyChecking=no \
|
||||
pi@${{ secrets.HOST_PI }} \
|
||||
"du -sb /home/pi/lm-www/frontend_tmp/production 2>/dev/null | cut -f1" || echo "0")
|
||||
|
||||
# 停止nginx避免文件占用
|
||||
sudo nginx -s quit 2>/dev/null || true
|
||||
if [ "$TRANSFERRED" != "0" ] && [ "$TOTAL_SIZE" != "0" ]; then
|
||||
PERCENT=$((TRANSFERRED * 100 / TOTAL_SIZE))
|
||||
TRANSFERRED_HR=$(numfmt --to=iec-i --suffix=B $TRANSFERRED 2>/dev/null || echo "${TRANSFERRED}B")
|
||||
TOTAL_HR=$(numfmt --to=iec-i --suffix=B $TOTAL_SIZE 2>/dev/null || echo "${TOTAL_SIZE}B")
|
||||
echo "📦 Transfer progress: $PERCENT% ($TRANSFERRED_HR / $TOTAL_HR)"
|
||||
else
|
||||
echo "📦 Transfer in progress..."
|
||||
fi
|
||||
done
|
||||
|
||||
# 等待传输完成并检查退出码
|
||||
wait $RSYNC_PID
|
||||
EXIT_CODE=$?
|
||||
|
||||
# 显示 rsync 的最后几行输出
|
||||
echo "--- rsync output (last 20 lines) ---"
|
||||
tail -20 /tmp/rsync.log || true
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
echo "✅ File transfer completed!"
|
||||
else
|
||||
echo "❌ File transfer failed with exit code $EXIT_CODE"
|
||||
exit $EXIT_CODE
|
||||
fi
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
# 完成部署:直接替换并重启 nginx
|
||||
- name: Deploy to production
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.HOST_PI }}
|
||||
username: pi
|
||||
password: ${{ secrets.PASS_PI }}
|
||||
port: 22
|
||||
script: |
|
||||
set -e
|
||||
|
||||
# 清理旧文件并重建目录结构
|
||||
sudo rm -rf /home/pi/lm-www/frontend
|
||||
echo "Deploying to production..."
|
||||
# 确保 frontend 目录存在
|
||||
sudo mkdir -p /home/pi/lm-www/frontend
|
||||
# 删除原有的 production 目录
|
||||
sudo rm -rf /home/pi/lm-www/frontend/production
|
||||
# 将新的 production 目录移过去
|
||||
sudo mv /home/pi/lm-www/frontend_tmp/production /home/pi/lm-www/frontend/production
|
||||
# 清理临时目录
|
||||
sudo rm -rf /home/pi/lm-www/frontend_tmp
|
||||
|
||||
# 设置正确的目录权限供文件传输
|
||||
sudo chown -R pi:pi /home/pi/lm-www/frontend
|
||||
sudo chmod -R 755 /home/pi/lm-www/frontend
|
||||
|
||||
# 将构建产物传输到服务器
|
||||
- name: Copy build files to server
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.HOST_PI }}
|
||||
username: pi
|
||||
password: ${{ secrets.PASS_PI }}
|
||||
port: 22
|
||||
source: "frontend/production/*"
|
||||
target: "/home/pi/lm-www/"
|
||||
overwrite: true
|
||||
|
||||
# 完成部署配置
|
||||
- name: Finalize deployment
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.HOST_PI }}
|
||||
username: pi
|
||||
password: ${{ secrets.PASS_PI }}
|
||||
port: 22
|
||||
script: |
|
||||
echo "Finalizing deployment..."
|
||||
|
||||
# 设置Web服务器权限
|
||||
echo "Setting permissions..."
|
||||
sudo chown -R www-data:www-data /home/pi/lm-www/frontend/
|
||||
sudo chmod -R 644 /home/pi/lm-www/frontend/
|
||||
sudo find /home/pi/lm-www/frontend/ -type d -exec chmod 755 {} \;
|
||||
|
||||
# 启动nginx并验证
|
||||
echo "Starting nginx..."
|
||||
if sudo nginx -t; then
|
||||
sudo systemctl start nginx
|
||||
sudo systemctl reload nginx
|
||||
|
||||
if sudo systemctl is-active --quiet nginx; then
|
||||
echo "✅ Frontend deployment completed successfully!"
|
||||
else
|
||||
echo "❌ Nginx failed to start"
|
||||
sudo systemctl status nginx --no-pager -l
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "❌ Nginx configuration test failed!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Verifying deployment structure..."
|
||||
ls -la /home/pi/lm-www/frontend/
|
||||
ls -la /home/pi/lm-www/frontend/production/ || echo "Warning: production directory not found"
|
||||
|
||||
echo "Reloading nginx..."
|
||||
sudo systemctl reload nginx
|
||||
|
||||
echo "✅ Deployment completed!"
|
||||
@@ -28,6 +28,9 @@
|
||||
### 客户管理
|
||||

|
||||
|
||||
### 许可证管理
|
||||

|
||||
|
||||
客户管理模块提供完整的客户信息管理功能,包括客户信息的增删改查、状态管理、授权关联等核心功能。
|
||||
|
||||
## 核心功能
|
||||
|
||||
@@ -28,6 +28,9 @@ Access URL: [lm.cedar-v.com:18080](http://lm.cedar-v.com:18080)
|
||||
### Customer Management
|
||||

|
||||
|
||||
### License Management
|
||||

|
||||
|
||||
The customer management module provides comprehensive customer information management features, including CRUD operations for customer data, status management, and authorization associations.
|
||||
|
||||
## Key Features
|
||||
|
||||
+21
-3
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"license-manager/internal/api/routes"
|
||||
"license-manager/internal/config"
|
||||
@@ -53,10 +54,27 @@ func main() {
|
||||
|
||||
cfg := config.GetConfig()
|
||||
|
||||
// 初始化数据库
|
||||
if err := database.InitDatabase(&cfg.Database); err != nil {
|
||||
log.Fatalf("数据库初始化失败: %v", err)
|
||||
// 初始化数据库(失败时重试)
|
||||
const (
|
||||
maxDBRetries = 200
|
||||
retryInterval = 3 * time.Second
|
||||
)
|
||||
|
||||
var dbErr error
|
||||
for attempt := 1; attempt <= maxDBRetries; attempt++ {
|
||||
dbErr = database.InitDatabase(&cfg.Database)
|
||||
if dbErr == nil {
|
||||
break
|
||||
}
|
||||
|
||||
if attempt == maxDBRetries {
|
||||
log.Fatalf("数据库初始化失败: %v", dbErr)
|
||||
}
|
||||
|
||||
log.Warnf("数据库初始化失败(第%d次): %v,将在 %v 后重试...", attempt, dbErr, retryInterval)
|
||||
time.Sleep(retryInterval)
|
||||
}
|
||||
|
||||
defer database.Close()
|
||||
|
||||
// 运行数据库迁移
|
||||
|
||||
@@ -32,7 +32,7 @@ services:
|
||||
|
||||
# Backend service - using GitHub registry image
|
||||
backend:
|
||||
image: ghcr.io/cedar-v/license-manager-backend:v0.1.0
|
||||
image: ghcr.io/cedar-v/license-manager-backend:v1.0.0
|
||||
container_name: license-manager-backend-git
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
@@ -69,7 +69,7 @@ services:
|
||||
|
||||
# Frontend service - using GitHub registry image
|
||||
frontend:
|
||||
image: ghcr.io/cedar-v/license-manager-frontend:v0.1.0
|
||||
image: ghcr.io/cedar-v/license-manager-frontend:v1.0.0
|
||||
container_name: license-manager-frontend-git
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 133 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 395 KiB After Width: | Height: | Size: 364 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 474 KiB |
File renamed without changes.
@@ -5,7 +5,7 @@
|
||||
|
||||
---
|
||||
|
||||
## 🎉 首个框架版本发布
|
||||
## 🎉 首个正式版本发布
|
||||
|
||||
这是License Manager项目的第一个正式版本,包含了基础的系统框架和核心功能。
|
||||
本版本聚焦“全生命周期 License 管理”场景,兼顾 SaaS 交付与离线部署,
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Release v1.0.1
|
||||
|
||||
**发布日期**:2025-11-22
|
||||
|
||||
---
|
||||
|
||||
## ✨ 新增功能
|
||||
|
||||
- **数据库初始化重试机制**:提升系统在启动过程中的稳定性与容错能力
|
||||
- **许可证管理功能**:支持许可证的撤销与下载操作,增强管理灵活性
|
||||
- **语言切换功能**:新增语言切换入口,优化语言选择界面,提升国际化体验
|
||||
- **官方文档**:更新官方文档,增加许可证结构与验证(客户端要点)说明,商业价值说明等。
|
||||
|
||||
## 🛠 优化与改进
|
||||
|
||||
- **许可证信息展示**:更新国际化文本,优化展示逻辑,提升可读性
|
||||
- **导航与菜单栏**:完善导航栏与菜单栏结构,暂时禁用搜索与通知按钮,提升整体交互体验
|
||||
- **授权基础信息**:优化剩余天数展示逻辑,提升用户体验
|
||||
|
||||
@@ -74,7 +74,11 @@ Axios.interceptors.request.use(config => {
|
||||
})
|
||||
// 添加响应拦截器
|
||||
Axios.interceptors.response.use(response => {
|
||||
// console.log(response)
|
||||
// 处理文件下载等二进制响应
|
||||
if (response.config?.responseType === 'blob') {
|
||||
return response
|
||||
}
|
||||
|
||||
const apiData = response.data as any
|
||||
// 这个 Code 是和后端约定的业务 Code
|
||||
const code = apiData.code
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { AxiosResponse } from 'axios'
|
||||
import Axios from './https'
|
||||
// 授权码(AuthorizationCode)类型 - 供授权管理页面使用
|
||||
export interface AuthorizationCode {
|
||||
@@ -214,6 +215,13 @@ export function deactivateLicense(id: string): Promise<ApiResponse<Authorization
|
||||
return Axios.patch(`/api/v1/authorization-codes/${id}/deactivate`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤销许可证
|
||||
*/
|
||||
export function revokeLicense(id: string, reason: string): Promise<ApiResponse> {
|
||||
return Axios.put(`/api/v1/licenses/${id}/revoke`, { reason })
|
||||
}
|
||||
|
||||
// 许可证设备信息类型(与后端 LicenseListItem 对应)
|
||||
export interface LicenseDevice {
|
||||
id: string
|
||||
@@ -303,6 +311,15 @@ export function getLicenseDeviceDetail(id: string): Promise<ApiResponse<LicenseD
|
||||
return Axios.get(`/api/v1/licenses/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载许可证文件
|
||||
*/
|
||||
export function downloadLicenseFile(id: string): Promise<AxiosResponse<Blob>> {
|
||||
return Axios.get(`/api/v1/licenses/${id}/download`, {
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
// 创建许可证请求(手动绑定设备)
|
||||
export interface LicenseDeviceCreateRequest {
|
||||
authorization_code_id: string
|
||||
|
||||
@@ -98,15 +98,21 @@
|
||||
|
||||
<!-- 操作按钮组 -->
|
||||
<div class="action-buttons">
|
||||
<!-- 搜索按钮 -->
|
||||
<!-- 搜索按钮(暂时禁用) -->
|
||||
<!--
|
||||
<el-tooltip :content="t('navigation.tooltip.search')" placement="bottom">
|
||||
<button class="action-btn" @click="handleSearchClick">
|
||||
<NavIcon name="search" />
|
||||
</button>
|
||||
</el-tooltip>
|
||||
-->
|
||||
|
||||
<!-- 通知按钮 -->
|
||||
<el-tooltip :content="t('navigation.tooltip.notification')" placement="bottom">
|
||||
<!-- 通知按钮(暂时隐藏) -->
|
||||
<el-tooltip
|
||||
v-if="showNotification"
|
||||
:content="t('navigation.tooltip.notification')"
|
||||
placement="bottom"
|
||||
>
|
||||
<button class="action-btn notification-btn" @click="handleNotificationClick">
|
||||
<NavIcon name="notification" />
|
||||
<span v-if="notificationCount" class="notification-badge">
|
||||
@@ -116,11 +122,28 @@
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 语言切换按钮 -->
|
||||
<el-tooltip :content="t('navigation.tooltip.language')" placement="bottom">
|
||||
<button class="action-btn" @click="handleLanguageClick">
|
||||
<NavIcon name="language" />
|
||||
</button>
|
||||
</el-tooltip>
|
||||
<el-dropdown trigger="click" @command="handleLanguageChange">
|
||||
<span class="dropdown-trigger">
|
||||
<el-tooltip :content="t('navigation.tooltip.language')" placement="bottom">
|
||||
<button class="action-btn language-btn">
|
||||
<NavIcon name="language" />
|
||||
<span class="language-label">{{ currentLanguageLabel }}</span>
|
||||
</button>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-for="option in languageOptions"
|
||||
:key="option.code"
|
||||
:command="option.code"
|
||||
:class="{ active: option.code === currentLanguage }"
|
||||
>
|
||||
{{ option.label }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
|
||||
<!-- 主题切换按钮 -->
|
||||
<el-tooltip :content="t('navigation.tooltip.theme')" placement="bottom">
|
||||
@@ -134,7 +157,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessageBox, ElMessage } from 'element-plus'
|
||||
@@ -142,6 +165,7 @@ import { useAppStore } from '@/store/modules/app'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import NavIcon from '@/components/common/icons/NavIcon.vue'
|
||||
import { useBreadcrumb } from '@/utils/breadcrumb'
|
||||
import { changeLanguage, type SupportedLocale } from '@/utils/language'
|
||||
|
||||
// 组件属性接口定义
|
||||
interface Props {
|
||||
@@ -151,6 +175,9 @@ interface Props {
|
||||
// 定义组件属性和默认值
|
||||
const { notificationCount = 24 } = defineProps<Props>()
|
||||
|
||||
// 功能暂未启用,隐藏通知入口
|
||||
const showNotification = false
|
||||
|
||||
// 定义组件事件
|
||||
const emit = defineEmits<{
|
||||
sidebarToggle: []
|
||||
@@ -162,7 +189,7 @@ const emit = defineEmits<{
|
||||
}>()
|
||||
|
||||
// 使用国际化
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
// 使用store和组合函数
|
||||
const router = useRouter()
|
||||
@@ -207,10 +234,30 @@ const handleNotificationClick = () => {
|
||||
emit('notificationClick')
|
||||
}
|
||||
|
||||
// 处理语言切换点击
|
||||
const handleLanguageClick = () => {
|
||||
// 语言切换
|
||||
const languageOptions: Array<{ code: SupportedLocale; label: string }> = [
|
||||
{ code: 'en', label: 'English' },
|
||||
{ code: 'zh', label: '中文' },
|
||||
{ code: 'ja', label: '日本語' }
|
||||
]
|
||||
const currentLanguage = ref(locale.value as SupportedLocale)
|
||||
const currentLanguageLabel = computed(
|
||||
() => languageOptions.find(option => option.code === currentLanguage.value)?.label || ''
|
||||
)
|
||||
const handleLanguageChange = (lang: SupportedLocale) => {
|
||||
if (lang === currentLanguage.value) return
|
||||
changeLanguage(lang)
|
||||
currentLanguage.value = lang
|
||||
emit('languageClick')
|
||||
window.location.reload()
|
||||
}
|
||||
watch(
|
||||
locale,
|
||||
value => {
|
||||
currentLanguage.value = value as SupportedLocale
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
// 处理主题切换点击
|
||||
const handleThemeClick = () => {
|
||||
@@ -541,6 +588,25 @@ const handleUserCommand = async (command: string) => {
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
|
||||
.dropdown-trigger {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.language-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
width: auto;
|
||||
min-width: 40px;
|
||||
padding: 0 12px;
|
||||
}
|
||||
|
||||
.language-label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--app-text-primary);
|
||||
}
|
||||
|
||||
/* 通知徽章 */
|
||||
.notification-badge {
|
||||
position: absolute;
|
||||
@@ -561,6 +627,11 @@ const handleUserCommand = async (command: string) => {
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
:deep(.el-dropdown-menu__item.active) {
|
||||
color: var(--el-color-primary) !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 侧边栏状态配合 - 桌面端 */
|
||||
.nav-content--sidebar-collapsed {
|
||||
left: 64px !important; /* 侧边栏收起时的宽度,使用!important确保优先级 */
|
||||
|
||||
@@ -348,8 +348,12 @@
|
||||
"licenseKey": "License key",
|
||||
"licenseStatus": "License status",
|
||||
"statusDescription": "This license is generated and bound to the specified hardware for runtime validation.",
|
||||
"downloadButton": "Download License File",
|
||||
"messages": {
|
||||
"loadError": "Failed to load license devices"
|
||||
"loadError": "Failed to load license devices",
|
||||
"downloadSuccess": "License file download started",
|
||||
"downloadError": "Failed to download license file",
|
||||
"missingLicense": "License information not found"
|
||||
}
|
||||
},
|
||||
"licenseModal": {
|
||||
@@ -401,6 +405,11 @@
|
||||
"revokeTitle": "Warning",
|
||||
"revokeConfirmButton": "Confirm Revoke",
|
||||
"revokeCancelButton": "Cancel",
|
||||
"revokeReasonPlaceholder": "Please enter revocation reason",
|
||||
"revokeReasonRequired": "Revocation reason is required",
|
||||
"revokeReasonMax": "Revocation reason cannot exceed 500 characters",
|
||||
"revokeSuccess": "License revoked successfully",
|
||||
"revokeError": "Failed to revoke the license, please try again later",
|
||||
"loadError": "Failed to load license details",
|
||||
"missingId": "Missing license ID"
|
||||
}
|
||||
@@ -627,7 +636,13 @@
|
||||
"activatedDevices": "Activated Devices Count",
|
||||
"creationTime": "Creation Time",
|
||||
"expiryTime": "Expiry Time",
|
||||
"remainingDays": "Remaining Days"
|
||||
"remainingDays": "Remaining Time",
|
||||
"remainingTime": {
|
||||
"permanent": "Permanent",
|
||||
"years": "{years} year(s)",
|
||||
"yearMonth": "{years} year(s) {months} month(s)",
|
||||
"days": "{days} day(s)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,8 +348,12 @@
|
||||
"licenseKey": "ライセンスキー",
|
||||
"licenseStatus": "ライセンス状態",
|
||||
"statusDescription": "このライセンスは指定ハードウェアにバインドされ、システム検証に利用されます",
|
||||
"downloadButton": "ライセンスファイルをダウンロード",
|
||||
"messages": {
|
||||
"loadError": "デバイスライセンスの取得に失敗しました"
|
||||
"loadError": "デバイスライセンスの取得に失敗しました",
|
||||
"downloadSuccess": "ライセンスファイルのダウンロードを開始しました",
|
||||
"downloadError": "ライセンスファイルのダウンロードに失敗しました",
|
||||
"missingLicense": "ライセンス情報が見つかりません"
|
||||
}
|
||||
},
|
||||
"licenseModal": {
|
||||
@@ -401,6 +405,11 @@
|
||||
"revokeTitle": "警告",
|
||||
"revokeConfirmButton": "取り消し確認",
|
||||
"revokeCancelButton": "キャンセル",
|
||||
"revokeReasonPlaceholder": "取り消し理由を入力してください",
|
||||
"revokeReasonRequired": "取り消し理由は必須です",
|
||||
"revokeReasonMax": "取り消し理由は500文字以内で入力してください",
|
||||
"revokeSuccess": "ライセンスを正常に取り消しました",
|
||||
"revokeError": "ライセンスの取り消しに失敗しました。後でもう一度お試しください",
|
||||
"loadError": "ライセンス詳細の読み込みに失敗しました",
|
||||
"missingId": "ライセンスIDが不足しています"
|
||||
}
|
||||
@@ -627,7 +636,13 @@
|
||||
"activatedDevices": "アクティベート済みデバイス数",
|
||||
"creationTime": "作成日時",
|
||||
"expiryTime": "有効期限",
|
||||
"remainingDays": "残り日数"
|
||||
"remainingDays": "残り時間",
|
||||
"remainingTime": {
|
||||
"permanent": "永久",
|
||||
"years": "{years}年",
|
||||
"yearMonth": "{years}年{months}ヶ月",
|
||||
"days": "{days}日"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,8 +348,12 @@
|
||||
"licenseKey": "许可证密钥",
|
||||
"licenseStatus": "许可证状态",
|
||||
"statusDescription": "此许可证已生成并绑定到指定硬件,可用于系统运行验证",
|
||||
"downloadButton": "许可证文件下载",
|
||||
"messages": {
|
||||
"loadError": "获取设备列表失败"
|
||||
"loadError": "获取设备列表失败",
|
||||
"downloadSuccess": "许可证文件已开始下载",
|
||||
"downloadError": "下载许可证文件失败",
|
||||
"missingLicense": "未找到许可证信息"
|
||||
}
|
||||
},
|
||||
"licenseModal": {
|
||||
@@ -386,7 +390,7 @@
|
||||
"copyCode": "复制授权码",
|
||||
"updateLicense": "变更授权",
|
||||
"renewLicense": "延期授权",
|
||||
"revokeLicense": "吊销授权",
|
||||
"revokeLicense": "撤销许可证",
|
||||
"downloadCertificate": "下载部署包"
|
||||
},
|
||||
"messages": {
|
||||
@@ -395,12 +399,17 @@
|
||||
"codeEmpty": "授权码为空",
|
||||
"updateComingSoon": "变更授权功能开发中...",
|
||||
"renewComingSoon": "延期授权功能开发中...",
|
||||
"revokeComingSoon": "吊销授权功能开发中...",
|
||||
"revokeComingSoon": "撤销许可证功能开发中...",
|
||||
"downloadComingSoon": "下载凭单功能开发中...",
|
||||
"revokeConfirm": "确定要吊销此授权吗?此操作不可撤销!",
|
||||
"revokeConfirm": "确定要撤销此许可证吗?此操作不可逆!",
|
||||
"revokeTitle": "警告",
|
||||
"revokeConfirmButton": "确定吊销",
|
||||
"revokeConfirmButton": "确定撤销",
|
||||
"revokeCancelButton": "取消",
|
||||
"revokeReasonPlaceholder": "请输入撤销原因",
|
||||
"revokeReasonRequired": "请填写撤销原因",
|
||||
"revokeReasonMax": "撤销原因不能超过500个字符",
|
||||
"revokeSuccess": "许可证已成功撤销",
|
||||
"revokeError": "撤销许可证失败,请稍后重试",
|
||||
"loadError": "加载授权详情失败",
|
||||
"missingId": "缺少授权ID"
|
||||
}
|
||||
@@ -627,7 +636,13 @@
|
||||
"activatedDevices": "已激活设备数量",
|
||||
"creationTime": "创建时间",
|
||||
"expiryTime": "到期时间",
|
||||
"remainingDays": "剩余时间(天)"
|
||||
"remainingDays": "剩余时间",
|
||||
"remainingTime": {
|
||||
"permanent": "永久",
|
||||
"years": "{years}年",
|
||||
"yearMonth": "{years}年{months}个月",
|
||||
"days": "{days}天"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,6 @@
|
||||
<div class="info-label">{{ t('pages.licenses.detail.authorizationInfo.customerCode') }}:</div>
|
||||
<div class="info-value">{{ licenseData?.customer_info?.customer_code || '-' }}</div>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<div class="info-label">{{ t('pages.licenses.detail.authorizationInfo.createdBy') }}:</div>
|
||||
<div class="info-value">{{ licenseData?.created_by || '-' }}</div>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<div class="info-label">{{ t('pages.licenses.detail.authorizationInfo.description') }}:</div>
|
||||
<div class="info-value">{{ licenseData?.description || '-' }}</div>
|
||||
|
||||
@@ -38,10 +38,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 剩余时间(天) -->
|
||||
<!-- 剩余时间 -->
|
||||
<div class="stat-card stat-card-4">
|
||||
<div class="card-content">
|
||||
<div class="stat-value">{{ getRemainingDays(licenseData?.end_date) }}</div>
|
||||
<div class="stat-value">{{ formatRemainingTime(licenseData?.end_date) }}</div>
|
||||
<div class="stat-label">{{ $t('customers.basicInfo.remainingDays') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -52,12 +52,14 @@
|
||||
<script setup lang="ts">
|
||||
import type { AuthorizationCode } from '@/api/license'
|
||||
import { formatDateShort as formatDateUtil } from '@/utils/date'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
licenseData: AuthorizationCode | null
|
||||
}
|
||||
|
||||
defineProps<Props>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const getActivatedLicenses = (license?: AuthorizationCode | null) => {
|
||||
if (!license) return 0
|
||||
@@ -75,13 +77,34 @@ const formatDateShort = (date?: string) => {
|
||||
return formatDateUtil(date)
|
||||
}
|
||||
|
||||
const getRemainingDays = (endDate?: string) => {
|
||||
const formatRemainingTime = (endDate?: string) => {
|
||||
if (!endDate) return '-'
|
||||
const now = new Date()
|
||||
const end = new Date(endDate)
|
||||
const diff = end.getTime() - now.getTime()
|
||||
const days = Math.ceil(diff / (1000 * 60 * 60 * 24))
|
||||
return days > 0 ? days : 0
|
||||
if (Number.isNaN(end.getTime())) return '-'
|
||||
const now = new Date()
|
||||
const diffMs = end.getTime() - now.getTime()
|
||||
const days = Math.max(0, Math.ceil(diffMs / (1000 * 60 * 60 * 24)))
|
||||
|
||||
if (days > 36500) {
|
||||
return t('customers.basicInfo.remainingTime.permanent')
|
||||
}
|
||||
|
||||
if (days >= 731) {
|
||||
const years = Math.floor(days / 365)
|
||||
return t('customers.basicInfo.remainingTime.years', { years })
|
||||
}
|
||||
|
||||
if (days >= 366) {
|
||||
const years = Math.floor(days / 365)
|
||||
const remainingDays = days - years * 365
|
||||
if (remainingDays === 0) {
|
||||
return t('customers.basicInfo.remainingTime.years', { years })
|
||||
}
|
||||
const months = Math.max(1, Math.round(remainingDays / 30))
|
||||
return t('customers.basicInfo.remainingTime.yearMonth', { years, months })
|
||||
}
|
||||
|
||||
return t('customers.basicInfo.remainingTime.days', { days })
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -146,6 +146,28 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 下载按钮 -->
|
||||
<div class="download-section">
|
||||
<el-button
|
||||
class="download-license-btn"
|
||||
type="primary"
|
||||
:loading="isDownloading(device.id)"
|
||||
@click="handleDownloadLicense(device)"
|
||||
>
|
||||
{{ t('pages.licenses.detail.licenseInfo.downloadButton') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
class="revoke-license-btn"
|
||||
type="danger"
|
||||
plain
|
||||
:loading="isRevoking(device.id)"
|
||||
:disabled="device.status === 'revoked'"
|
||||
@click="handleRevokeLicense(device)"
|
||||
>
|
||||
{{ t('pages.licenses.detail.actions.revokeLicense') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -162,16 +184,20 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch, reactive, computed, nextTick } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type { AuthorizationCode, LicenseDevice, LicenseDeviceCreateRequest } from '@/api/license'
|
||||
import { getLicenseDevices, getLicenseDeviceDetail, createLicenseDevice } from '@/api/license'
|
||||
import { getLicenseDevices, getLicenseDeviceDetail, createLicenseDevice, downloadLicenseFile, revokeLicense } from '@/api/license'
|
||||
import { formatDate } from '@/utils/date'
|
||||
|
||||
interface Props {
|
||||
licenseData: AuthorizationCode | null
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'licenseRevoked'): void
|
||||
}>()
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -184,6 +210,8 @@ const addForm = reactive({
|
||||
hardware_fingerprint: '',
|
||||
remark: ''
|
||||
})
|
||||
const downloadingMap = reactive<Record<string, boolean>>({})
|
||||
const revokingMap = reactive<Record<string, boolean>>({})
|
||||
|
||||
const authorizationCodeId = computed(() => props.licenseData?.id || '')
|
||||
const authorizationCodeValue = computed(() => props.licenseData?.code || '--')
|
||||
@@ -322,6 +350,116 @@ const handleCopyAuthorizationCode = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const isDownloading = (licenseId: string) => {
|
||||
return Boolean(licenseId && downloadingMap[licenseId])
|
||||
}
|
||||
|
||||
const isRevoking = (licenseId: string) => {
|
||||
return Boolean(licenseId && revokingMap[licenseId])
|
||||
}
|
||||
|
||||
const extractFilename = (contentDisposition?: string) => {
|
||||
if (!contentDisposition) return ''
|
||||
const utfMatch = /filename\*=utf-8''([^;]+)/i.exec(contentDisposition)
|
||||
if (utfMatch?.[1]) {
|
||||
try {
|
||||
return decodeURIComponent(utfMatch[1])
|
||||
} catch (error) {
|
||||
console.warn('Failed to decode filename from header:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const asciiMatch = /filename="?([^"]+)"?/i.exec(contentDisposition)
|
||||
return asciiMatch?.[1] || ''
|
||||
}
|
||||
|
||||
const handleDownloadLicense = async (device: LicenseDevice) => {
|
||||
if (!device?.id) {
|
||||
ElMessage.warning(t('pages.licenses.detail.licenseInfo.messages.missingLicense'))
|
||||
return
|
||||
}
|
||||
|
||||
downloadingMap[device.id] = true
|
||||
try {
|
||||
const response = await downloadLicenseFile(device.id)
|
||||
const disposition =
|
||||
response.headers?.['content-disposition'] || response.headers?.['Content-Disposition']
|
||||
const filename =
|
||||
extractFilename(disposition) ||
|
||||
`${device.customer_name || 'license'}-${device.id}.lic`
|
||||
|
||||
const blobUrl = window.URL.createObjectURL(response.data)
|
||||
const link = document.createElement('a')
|
||||
link.href = blobUrl
|
||||
link.download = filename
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
window.URL.revokeObjectURL(blobUrl)
|
||||
|
||||
ElMessage.success(t('pages.licenses.detail.licenseInfo.messages.downloadSuccess'))
|
||||
} catch (error: any) {
|
||||
console.error('下载许可证失败:', error)
|
||||
const backendMessage = error?.backendMessage || error?.message
|
||||
ElMessage.error(
|
||||
backendMessage || t('pages.licenses.detail.licenseInfo.messages.downloadError')
|
||||
)
|
||||
} finally {
|
||||
downloadingMap[device.id] = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleRevokeLicense = async (device: LicenseDevice) => {
|
||||
if (!device?.id) {
|
||||
ElMessage.error(t('pages.licenses.detail.messages.missingId'))
|
||||
return
|
||||
}
|
||||
|
||||
if (device.status === 'revoked') {
|
||||
return
|
||||
}
|
||||
|
||||
let reason = ''
|
||||
try {
|
||||
const { value } = await ElMessageBox.prompt(
|
||||
t('pages.licenses.detail.messages.revokeConfirm'),
|
||||
t('pages.licenses.detail.messages.revokeTitle'),
|
||||
{
|
||||
confirmButtonText: t('pages.licenses.detail.messages.revokeConfirmButton'),
|
||||
cancelButtonText: t('pages.licenses.detail.messages.revokeCancelButton'),
|
||||
type: 'warning',
|
||||
inputType: 'textarea',
|
||||
inputPlaceholder: t('pages.licenses.detail.messages.revokeReasonPlaceholder'),
|
||||
inputValidator: (val: string) => {
|
||||
if (!val || !val.trim()) {
|
||||
return t('pages.licenses.detail.messages.revokeReasonRequired')
|
||||
}
|
||||
if (val.trim().length > 500) {
|
||||
return t('pages.licenses.detail.messages.revokeReasonMax')
|
||||
}
|
||||
return true
|
||||
},
|
||||
inputErrorMessage: t('pages.licenses.detail.messages.revokeReasonRequired')
|
||||
}
|
||||
)
|
||||
reason = value.trim()
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
revokingMap[device.id] = true
|
||||
try {
|
||||
await revokeLicense(device.id, reason)
|
||||
ElMessage.success(t('pages.licenses.detail.messages.revokeSuccess'))
|
||||
await fetchDevices()
|
||||
emit('licenseRevoked')
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || t('pages.licenses.detail.messages.revokeError'))
|
||||
} finally {
|
||||
revokingMap[device.id] = false
|
||||
}
|
||||
}
|
||||
|
||||
const submitAddLicense = async () => {
|
||||
if (!addFormRef.value) return
|
||||
|
||||
@@ -621,6 +759,42 @@ const submitAddLicense = async () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.download-license-btn {
|
||||
min-width: 148px;
|
||||
background: #00C27C;
|
||||
border: none;
|
||||
color: #FFFFFF;
|
||||
font-family: 'Source Han Sans CN', sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 21px;
|
||||
border-radius: 4px;
|
||||
|
||||
&:hover {
|
||||
background: #019C7C;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.download-section {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.revoke-license-btn {
|
||||
min-width: 148px;
|
||||
border: 1px solid #F0142F;
|
||||
color: #F0142F;
|
||||
background: transparent;
|
||||
|
||||
&:hover:not(.is-disabled) {
|
||||
background: rgba(240, 20, 47, 0.08);
|
||||
color: #d01228;
|
||||
border-color: #d01228;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
|
||||
@@ -62,9 +62,6 @@
|
||||
<el-button class="action-btn-inline renew-btn" @click="handleRenewLicense">
|
||||
{{ $t('pages.licenses.detail.actions.renewLicense') }}
|
||||
</el-button>
|
||||
<el-button class="action-btn-inline revoke-btn" @click="handleRevokeLicense">
|
||||
{{ $t('pages.licenses.detail.actions.revokeLicense') }}
|
||||
</el-button>
|
||||
<el-button class="action-btn-inline download-btn" @click="handleDownloadCertificate">
|
||||
{{ $t('pages.licenses.detail.actions.downloadCertificate') }}
|
||||
</el-button>
|
||||
@@ -75,7 +72,11 @@
|
||||
<div class="tab-content-area">
|
||||
<BasicInfo v-if="activeTab === 'basic'" :license-data="licenseData" />
|
||||
<AuthorizationInfo v-if="activeTab === 'authorization'" :license-data="licenseData" />
|
||||
<LicenseInfo v-if="activeTab === 'license'" :license-data="licenseData" />
|
||||
<LicenseInfo
|
||||
v-if="activeTab === 'license'"
|
||||
:license-data="licenseData"
|
||||
@license-revoked="loadLicenseData"
|
||||
/>
|
||||
<ChangeHistory v-if="activeTab === 'history'" :license-data="licenseData" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -86,7 +87,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getLicenseDetail, type AuthorizationCode } from '@/api/license'
|
||||
import LicenseTabIcon from '@/components/common/icons/LicenseTabIcon.vue'
|
||||
@@ -141,18 +142,6 @@ const handleRenewLicense = () => {
|
||||
ElMessage.info(t('pages.licenses.detail.messages.renewComingSoon'))
|
||||
}
|
||||
|
||||
const handleRevokeLicense = () => {
|
||||
ElMessageBox.confirm(t('pages.licenses.detail.messages.revokeConfirm'), t('pages.licenses.detail.messages.revokeTitle'), {
|
||||
confirmButtonText: t('pages.licenses.detail.messages.revokeConfirmButton'),
|
||||
cancelButtonText: t('pages.licenses.detail.messages.revokeCancelButton'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
ElMessage.info(t('pages.licenses.detail.messages.revokeComingSoon'))
|
||||
}).catch(() => {
|
||||
// 取消操作
|
||||
})
|
||||
}
|
||||
|
||||
const handleDownloadCertificate = () => {
|
||||
ElMessage.info(t('pages.licenses.detail.messages.downloadComingSoon'))
|
||||
}
|
||||
@@ -399,16 +388,6 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
&.revoke-btn {
|
||||
background: #F0142F;
|
||||
color: white;
|
||||
border: none;
|
||||
|
||||
&:hover {
|
||||
background: #d01228;
|
||||
}
|
||||
}
|
||||
|
||||
&.download-btn {
|
||||
background: #00C27C;
|
||||
color: white;
|
||||
|
||||
Reference in new issue
Block a user