feat: 添加下载授权文件功能,支持下载包含授权码和RSA公钥的压缩包,并更新相关国际化文本
This commit is contained in:
1 parent
c9958b12c3
commit
994a5de632
22 files changed
+716
-93
No files matched your search
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
// Vue 文件类型检查配置
|
||||
"volar.takeOverMode.enabled": true,
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true,
|
||||
|
||||
// TypeScript 检查配置
|
||||
"typescript.preferences.includePackageJsonAutoImports": "on",
|
||||
"typescript.suggest.autoImports": true,
|
||||
|
||||
// 启用实时类型检查
|
||||
"typescript.validate.enable": true,
|
||||
"javascript.validate.enable": true,
|
||||
|
||||
// 显示所有诊断信息(包括未使用的变量)
|
||||
"typescript.preferences.showUnused": true,
|
||||
"javascript.preferences.showUnused": true,
|
||||
|
||||
// Vue 文件检查
|
||||
"volar.codeLens.pugTools": false,
|
||||
"volar.codeLens.scriptSetupTools": true,
|
||||
|
||||
// 文件关联
|
||||
"files.associations": {
|
||||
"*.vue": "vue"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,6 +320,15 @@ export function downloadLicenseFile(id: string): Promise<AxiosResponse<Blob>> {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载授权文件包(授权码+公钥)
|
||||
*/
|
||||
export function downloadAuthorizationFile(id: string): Promise<AxiosResponse<Blob>> {
|
||||
return Axios.get(`/api/v1/authorization-codes/${id}/download`, {
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
// 创建许可证请求(手动绑定设备)
|
||||
export interface LicenseDeviceCreateRequest {
|
||||
authorization_code_id: string
|
||||
|
||||
@@ -128,8 +128,19 @@ const quickOptions = computed(() => [
|
||||
|
||||
// 响应式数据
|
||||
const { isMobile } = useDevice()
|
||||
const selectedQuick = ref('week')
|
||||
const dateRange = ref<[string, string]>(['2024-05-13', '2024-05-17']) // 初始值会被handleQuickSelect('week')覆盖
|
||||
const selectedQuick = ref('month')
|
||||
|
||||
const getCurrentMonthRange = (): [string, string] => {
|
||||
const today = new Date()
|
||||
const startDate = new Date(today.getFullYear(), today.getMonth(), 1)
|
||||
const endDate = new Date(today.getFullYear(), today.getMonth() + 1, 0)
|
||||
return [
|
||||
startDate.toISOString().split('T')[0],
|
||||
endDate.toISOString().split('T')[0]
|
||||
]
|
||||
}
|
||||
|
||||
const dateRange = ref<[string, string]>(getCurrentMonthRange())
|
||||
const chartRef = ref()
|
||||
const datePickerRef = ref()
|
||||
|
||||
@@ -141,6 +152,11 @@ const chartLoading = ref(false)
|
||||
const chartOption = computed(() => {
|
||||
const dates = trendData.value.map(item => item.date.substring(5)) // 只显示月-日
|
||||
const values = trendData.value.map(item => item.value)
|
||||
const rawMax = values.length ? Math.max(...values) : 0
|
||||
const baseMax = Math.max(rawMax, 20)
|
||||
const minTickCount = 4 // 至少展示4个区间
|
||||
const niceInterval = Math.max(5, Math.ceil(baseMax / minTickCount / 5) * 5)
|
||||
const niceMax = Math.ceil(baseMax / niceInterval) * niceInterval
|
||||
|
||||
return {
|
||||
grid: {
|
||||
@@ -169,8 +185,8 @@ const chartOption = computed(() => {
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
min: 0,
|
||||
max: 20,
|
||||
interval: 5,
|
||||
max: niceMax,
|
||||
interval: niceInterval,
|
||||
axisLine: {
|
||||
show: false
|
||||
},
|
||||
@@ -367,9 +383,9 @@ const updateChartData = () => {
|
||||
|
||||
onMounted(() => {
|
||||
console.log('LicenseTrendChart 组件已挂载,开始初始化')
|
||||
// 初始化时直接调用快捷选择,设置为本周
|
||||
handleQuickSelect('week')
|
||||
console.log('已调用 handleQuickSelect(week)')
|
||||
// 初始化时直接调用快捷选择,设置为本月
|
||||
handleQuickSelect('month')
|
||||
console.log('已调用 handleQuickSelect(month)')
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -98,6 +98,19 @@
|
||||
|
||||
<!-- 操作按钮组 -->
|
||||
<div class="action-buttons">
|
||||
<!-- 文档 & GitHub 外部链接 -->
|
||||
<template v-for="link in externalLinks" :key="link.key">
|
||||
<el-tooltip :content="t(`navigation.tooltip.${link.key}`)" placement="bottom">
|
||||
<button
|
||||
class="action-btn external-link-btn"
|
||||
type="button"
|
||||
@click="handleExternalLink(link.url)"
|
||||
>
|
||||
<span class="external-link-label">{{ t(`navigation.external.${link.key}`) }}</span>
|
||||
</button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
|
||||
<!-- 搜索按钮(暂时禁用) -->
|
||||
<!--
|
||||
<el-tooltip :content="t('navigation.tooltip.search')" placement="bottom">
|
||||
@@ -178,6 +191,17 @@ const { notificationCount = 24 } = defineProps<Props>()
|
||||
// 功能暂未启用,隐藏通知入口
|
||||
const showNotification = false
|
||||
|
||||
type ExternalLinkKey = 'docs' | 'github'
|
||||
interface ExternalLink {
|
||||
key: ExternalLinkKey
|
||||
url: string
|
||||
}
|
||||
|
||||
const externalLinks: ExternalLink[] = [
|
||||
{ key: 'docs', url: 'https://docs.lm.cedar-v.com/' },
|
||||
{ key: 'github', url: 'https://github.com/cedar-v/license-manager' }
|
||||
]
|
||||
|
||||
// 定义组件事件
|
||||
const emit = defineEmits<{
|
||||
sidebarToggle: []
|
||||
@@ -229,6 +253,10 @@ const handleNotificationClick = () => {
|
||||
emit('notificationClick')
|
||||
}
|
||||
|
||||
const handleExternalLink = (url: string) => {
|
||||
window.open(url, '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
|
||||
// 语言切换
|
||||
const languageOptions: Array<{ code: SupportedLocale; label: string }> = [
|
||||
{ code: 'en', label: 'English' },
|
||||
@@ -579,6 +607,20 @@ const handleUserCommand = async (command: string) => {
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.external-link-btn {
|
||||
min-width: 72px;
|
||||
padding: 0 16px;
|
||||
width: auto;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.external-link-label {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--app-text-primary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.action-btn:hover {
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
@@ -810,6 +852,10 @@ const handleUserCommand = async (command: string) => {
|
||||
background: rgba(255, 255, 255, 0.08) !important;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .external-link-label {
|
||||
color: #f9fafb !important;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .action-btn:hover {
|
||||
background: rgba(16, 185, 129, 0.15) !important;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,13 @@
|
||||
"search": "Search",
|
||||
"notification": "Notifications",
|
||||
"language": "Switch Language",
|
||||
"theme": "Switch Theme"
|
||||
"theme": "Switch Theme",
|
||||
"docs": "Open Documentation",
|
||||
"github": "Open GitHub"
|
||||
},
|
||||
"external": {
|
||||
"docs": "Docs",
|
||||
"github": "GitHub"
|
||||
},
|
||||
"breadcrumb": {
|
||||
"dashboard": "Dashboard",
|
||||
@@ -391,7 +397,7 @@
|
||||
"updateLicense": "Update License",
|
||||
"renewLicense": "Renew License",
|
||||
"revokeLicense": "Revoke License",
|
||||
"downloadCertificate": "Download Deployment Package"
|
||||
"downloadCertificate": "Download Authorization File"
|
||||
},
|
||||
"messages": {
|
||||
"copySuccess": "License code copied to clipboard",
|
||||
@@ -400,7 +406,8 @@
|
||||
"updateComingSoon": "Update license feature is under development...",
|
||||
"renewComingSoon": "Renew license feature is under development...",
|
||||
"revokeComingSoon": "Revoke license feature is under development...",
|
||||
"downloadComingSoon": "Download certificate feature is under development...",
|
||||
"downloadSuccess": "Authorization file download started",
|
||||
"downloadError": "Failed to download authorization file, please try again later",
|
||||
"revokeConfirm": "Are you sure you want to revoke this license? This action cannot be undone!",
|
||||
"revokeTitle": "Warning",
|
||||
"revokeConfirmButton": "Confirm Revoke",
|
||||
|
||||
@@ -64,7 +64,13 @@
|
||||
"search": "検索",
|
||||
"notification": "通知",
|
||||
"language": "言語切り替え",
|
||||
"theme": "テーマ切り替え"
|
||||
"theme": "テーマ切り替え",
|
||||
"docs": "ドキュメントを開く",
|
||||
"github": "GitHub を開く"
|
||||
},
|
||||
"external": {
|
||||
"docs": "ドキュメント",
|
||||
"github": "GitHub"
|
||||
},
|
||||
"breadcrumb": {
|
||||
"dashboard": "ダッシュボード",
|
||||
@@ -391,7 +397,7 @@
|
||||
"updateLicense": "ライセンス更新",
|
||||
"renewLicense": "ライセンス延長",
|
||||
"revokeLicense": "ライセンス取り消し",
|
||||
"downloadCertificate": "デプロイメントパッケージをダウンロード"
|
||||
"downloadCertificate": "認証ファイルをダウンロード"
|
||||
},
|
||||
"messages": {
|
||||
"copySuccess": "ライセンスコードがクリップボードにコピーされました",
|
||||
@@ -400,7 +406,8 @@
|
||||
"updateComingSoon": "ライセンス更新機能は開発中です...",
|
||||
"renewComingSoon": "ライセンス延長機能は開発中です...",
|
||||
"revokeComingSoon": "ライセンス取り消し機能は開発中です...",
|
||||
"downloadComingSoon": "証明書ダウンロード機能は開発中です...",
|
||||
"downloadSuccess": "認証ファイルのダウンロードを開始しました",
|
||||
"downloadError": "認証ファイルのダウンロードに失敗しました。後でもう一度お試しください",
|
||||
"revokeConfirm": "このライセンスを取り消してもよろしいですか?この操作は元に戻せません!",
|
||||
"revokeTitle": "警告",
|
||||
"revokeConfirmButton": "取り消し確認",
|
||||
|
||||
@@ -64,7 +64,13 @@
|
||||
"search": "搜索",
|
||||
"notification": "消息通知",
|
||||
"language": "切换语言",
|
||||
"theme": "切换主题"
|
||||
"theme": "切换主题",
|
||||
"docs": "查看文档",
|
||||
"github": "打开 GitHub"
|
||||
},
|
||||
"external": {
|
||||
"docs": "文档",
|
||||
"github": "GitHub"
|
||||
},
|
||||
"breadcrumb": {
|
||||
"dashboard": "仪表盘",
|
||||
@@ -391,7 +397,7 @@
|
||||
"updateLicense": "变更授权",
|
||||
"renewLicense": "延期授权",
|
||||
"revokeLicense": "撤销许可证",
|
||||
"downloadCertificate": "下载部署包"
|
||||
"downloadCertificate": "授权文件下载"
|
||||
},
|
||||
"messages": {
|
||||
"copySuccess": "授权码已复制到剪贴板",
|
||||
@@ -400,7 +406,8 @@
|
||||
"updateComingSoon": "变更授权功能开发中...",
|
||||
"renewComingSoon": "延期授权功能开发中...",
|
||||
"revokeComingSoon": "撤销许可证功能开发中...",
|
||||
"downloadComingSoon": "下载凭单功能开发中...",
|
||||
"downloadSuccess": "授权文件已开始下载",
|
||||
"downloadError": "下载授权文件失败,请稍后重试",
|
||||
"revokeConfirm": "确定要撤销此许可证吗?此操作不可逆!",
|
||||
"revokeTitle": "警告",
|
||||
"revokeConfirmButton": "确定撤销",
|
||||
|
||||
@@ -386,7 +386,7 @@ const handleDownloadLicense = async (device: LicenseDevice) => {
|
||||
response.headers?.['content-disposition'] || response.headers?.['Content-Disposition']
|
||||
const filename =
|
||||
extractFilename(disposition) ||
|
||||
`${device.customer_name || 'license'}-${device.id}.lic`
|
||||
`${device.customer_name || 'license'}-${device.id}.zip`
|
||||
|
||||
const blobUrl = window.URL.createObjectURL(response.data)
|
||||
const link = document.createElement('a')
|
||||
|
||||
@@ -89,7 +89,7 @@ import { ref, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getLicenseDetail, type AuthorizationCode } from '@/api/license'
|
||||
import { getLicenseDetail, downloadAuthorizationFile, type AuthorizationCode } from '@/api/license'
|
||||
import LicenseTabIcon from '@/components/common/icons/LicenseTabIcon.vue'
|
||||
import BasicInfo from './components/BasicInfo.vue'
|
||||
import AuthorizationInfo from './components/AuthorizationInfo.vue'
|
||||
@@ -142,8 +142,62 @@ const handleRenewLicense = () => {
|
||||
ElMessage.info(t('pages.licenses.detail.messages.renewComingSoon'))
|
||||
}
|
||||
|
||||
const handleDownloadCertificate = () => {
|
||||
ElMessage.info(t('pages.licenses.detail.messages.downloadComingSoon'))
|
||||
const getFileNameFromDisposition = (disposition?: string | null) => {
|
||||
const defaultName = 'authorization_package.zip'
|
||||
if (!disposition) return defaultName
|
||||
|
||||
const utf8Match = disposition.match(/filename\*=UTF-8''([^;]+)/i)
|
||||
if (utf8Match?.[1]) {
|
||||
try {
|
||||
return decodeURIComponent(utf8Match[1])
|
||||
} catch {
|
||||
return utf8Match[1]
|
||||
}
|
||||
}
|
||||
|
||||
const asciiMatch = disposition.match(/filename="?([^";]+)"?/i)
|
||||
if (asciiMatch?.[1]) {
|
||||
return asciiMatch[1]
|
||||
}
|
||||
|
||||
return defaultName
|
||||
}
|
||||
|
||||
const handleDownloadCertificate = async () => {
|
||||
if (!licenseData.value?.id) {
|
||||
ElMessage.error(t('pages.licenses.detail.messages.missingId'))
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await downloadAuthorizationFile(licenseData.value.id)
|
||||
const fileName = getFileNameFromDisposition(response.headers['content-disposition'])
|
||||
const blob = new Blob([response.data], { type: 'application/zip' })
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = fileName
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
window.URL.revokeObjectURL(url)
|
||||
ElMessage.success(t('pages.licenses.detail.messages.downloadSuccess'))
|
||||
} catch (error: any) {
|
||||
console.error('下载授权文件失败:', error)
|
||||
let message = t('pages.licenses.detail.messages.downloadError')
|
||||
if (error?.response?.data instanceof Blob) {
|
||||
try {
|
||||
const text = await error.response.data.text()
|
||||
const parsed = JSON.parse(text)
|
||||
if (parsed?.message) {
|
||||
message = parsed.message
|
||||
}
|
||||
} catch {
|
||||
// ignore parse errors
|
||||
}
|
||||
}
|
||||
ElMessage.error(message)
|
||||
}
|
||||
}
|
||||
|
||||
const loadLicenseData = async () => {
|
||||
|
||||
Reference in new issue
Block a user