feat(sign): 面板「签名证书」页
- /admin/sign-profiles:平台上选(Windows/iOS)、名称、证书、口令、iOS 描述文件 - 列表只显示元数据(平台徽标、格式、是否含描述文件、时间),删除按钮二次确认 - 文件选择器改成统一风格按钮 + 文件名回显,隐藏原生 input - 路由/侧边栏/面包屑/i18n(zh+en 各 40 键)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { Boxes, Code, CreditCard, DollarSign, FileLock, Gauge, GitBranch, HardDrive, Hash, Key, KeyRound, Mail, Megaphone, MessageSquare, Monitor, Network, PackageCheck, Plug, ScrollText, Settings, Shield, Smartphone, Users, Variable } from 'lucide-vue-next'
|
||||
import { Boxes, Code, CreditCard, DollarSign, FileKey2, FileLock, Gauge, GitBranch, HardDrive, Hash, Key, KeyRound, Mail, Megaphone, MessageSquare, Monitor, Network, PackageCheck, Plug, ScrollText, Settings, Shield, Smartphone, Users, Variable } from 'lucide-vue-next'
|
||||
import { computed, onMounted, reactive, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { usePreferredDark } from '@vueuse/core'
|
||||
@@ -104,6 +104,11 @@ const navMain = computed(() => [
|
||||
url: '/admin/protect',
|
||||
icon: PackageCheck,
|
||||
},
|
||||
{
|
||||
title: t('nav.signProfiles'),
|
||||
url: '/admin/sign-profiles',
|
||||
icon: FileKey2,
|
||||
},
|
||||
{
|
||||
title: t('nav.users'),
|
||||
url: '/admin/users',
|
||||
|
||||
@@ -24,6 +24,7 @@ const breadcrumbs = computed(() => {
|
||||
announcements: t('nav.announcements'),
|
||||
versions: t('nav.versions'),
|
||||
protect: t('nav.protect'),
|
||||
'sign-profiles': t('nav.signProfiles'),
|
||||
'card-types': t('nav.cardTypes'),
|
||||
'agent-apps': t('nav.agentApps'),
|
||||
agents: t('nav.agents'),
|
||||
|
||||
@@ -0,0 +1,330 @@
|
||||
<script setup lang="ts">
|
||||
import { FileKey2, Loader2, ShieldCheck, Trash2, Upload } from 'lucide-vue-next'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { toast } from 'vue-sonner'
|
||||
|
||||
import { BasicPage } from '@/components/global-layout'
|
||||
import api from '@/services/api'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
interface SignProfile {
|
||||
id: number
|
||||
platform: 'windows' | 'ios'
|
||||
name: string
|
||||
cert_format: string
|
||||
subject: string
|
||||
not_after: string | null
|
||||
status: string
|
||||
has_profile: boolean
|
||||
last_used_at: string | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
const items = ref<SignProfile[]>([])
|
||||
const loading = ref(true)
|
||||
const uploading = ref(false)
|
||||
|
||||
const form = ref({
|
||||
platform: 'windows' as 'windows' | 'ios',
|
||||
name: '',
|
||||
password: '',
|
||||
})
|
||||
const certFile = ref<File | null>(null)
|
||||
const profileFile = ref<File | null>(null)
|
||||
const certInput = ref<HTMLInputElement | null>(null)
|
||||
const profileInput = ref<HTMLInputElement | null>(null)
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await api.get<{ items: SignProfile[] }>('/dev/sign-profiles')
|
||||
items.value = data?.items || []
|
||||
}
|
||||
catch (e: any) {
|
||||
toast.error(e.message || t('admin.signProfiles.loadFailed'))
|
||||
}
|
||||
finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function pickCert(e: Event) {
|
||||
const input = e.target as HTMLInputElement
|
||||
const f = input.files?.[0]
|
||||
if (f && !/\.(pfx|p12)$/i.test(f.name)) {
|
||||
toast.error(t('admin.signProfiles.onlyPfx'))
|
||||
input.value = ''
|
||||
return
|
||||
}
|
||||
certFile.value = f || null
|
||||
}
|
||||
|
||||
function pickProfile(e: Event) {
|
||||
const input = e.target as HTMLInputElement
|
||||
profileFile.value = input.files?.[0] || null
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!form.value.name.trim()) {
|
||||
toast.error(t('admin.signProfiles.needName'))
|
||||
return
|
||||
}
|
||||
if (!certFile.value) {
|
||||
toast.error(t('admin.signProfiles.needCert'))
|
||||
return
|
||||
}
|
||||
if (form.value.platform === 'ios' && !profileFile.value) {
|
||||
toast.error(t('admin.signProfiles.needProfile'))
|
||||
return
|
||||
}
|
||||
uploading.value = true
|
||||
try {
|
||||
const fd = new FormData()
|
||||
fd.append('platform', form.value.platform)
|
||||
fd.append('name', form.value.name.trim())
|
||||
fd.append('password', form.value.password)
|
||||
fd.append('cert', certFile.value)
|
||||
if (form.value.platform === 'ios' && profileFile.value)
|
||||
fd.append('profile', profileFile.value)
|
||||
|
||||
await api.postFormData('/dev/sign-profiles', fd)
|
||||
toast.success(t('admin.signProfiles.uploaded'))
|
||||
form.value.name = ''
|
||||
form.value.password = ''
|
||||
certFile.value = null
|
||||
profileFile.value = null
|
||||
if (certInput.value)
|
||||
certInput.value.value = ''
|
||||
if (profileInput.value)
|
||||
profileInput.value.value = ''
|
||||
await load()
|
||||
}
|
||||
catch (e: any) {
|
||||
toast.error(e.message || t('admin.signProfiles.uploadFailed'))
|
||||
}
|
||||
finally {
|
||||
uploading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const pendingDelete = ref<number | null>(null)
|
||||
|
||||
async function remove(item: SignProfile) {
|
||||
if (pendingDelete.value !== item.id) {
|
||||
pendingDelete.value = item.id
|
||||
toast.warning(t('admin.signProfiles.confirmDelete', { name: item.name }))
|
||||
window.setTimeout(() => {
|
||||
if (pendingDelete.value === item.id)
|
||||
pendingDelete.value = null
|
||||
}, 4000)
|
||||
return
|
||||
}
|
||||
pendingDelete.value = null
|
||||
try {
|
||||
await api.delete(`/dev/sign-profiles/${item.id}`)
|
||||
toast.success(t('admin.signProfiles.deleted'))
|
||||
await load()
|
||||
}
|
||||
catch (e: any) {
|
||||
toast.error(e.message || t('admin.signProfiles.loadFailed'))
|
||||
}
|
||||
}
|
||||
|
||||
function platformLabel(p: string) {
|
||||
return p === 'ios' ? 'iOS' : 'Windows'
|
||||
}
|
||||
|
||||
function formatTime(v: string | null) {
|
||||
return v ? new Date(v).toLocaleString() : '-'
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BasicPage :title="t('admin.signProfiles.title')" :description="t('admin.signProfiles.description')" sticky>
|
||||
<template #actions>
|
||||
<UiButton variant="outline" :disabled="loading" @click="load">
|
||||
<Loader2 v-if="loading" class="mr-2 h-4 w-4 animate-spin" />
|
||||
{{ t('admin.signProfiles.refresh') }}
|
||||
</UiButton>
|
||||
</template>
|
||||
|
||||
<div class="space-y-6">
|
||||
<!-- 上传 -->
|
||||
<UiCard>
|
||||
<UiCardHeader>
|
||||
<UiCardTitle class="flex items-center gap-2 text-base">
|
||||
<FileKey2 class="h-4 w-4" />
|
||||
{{ t('admin.signProfiles.uploadTitle') }}
|
||||
</UiCardTitle>
|
||||
<p class="text-sm text-muted-foreground">
|
||||
{{ t('admin.signProfiles.uploadHint') }}
|
||||
</p>
|
||||
</UiCardHeader>
|
||||
<UiCardContent class="space-y-4">
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium">{{ t('admin.signProfiles.platform') }}</label>
|
||||
<select
|
||||
v-model="form.platform"
|
||||
class="h-9 w-full rounded-md border border-input bg-background px-3 text-sm"
|
||||
>
|
||||
<option value="windows">
|
||||
{{ t('admin.signProfiles.platformWindows') }}
|
||||
</option>
|
||||
<option value="ios">
|
||||
{{ t('admin.signProfiles.platformIos') }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium">{{ t('admin.signProfiles.name') }}</label>
|
||||
<input
|
||||
v-model="form.name"
|
||||
class="h-9 w-full rounded-md border border-input bg-background px-3 text-sm"
|
||||
:placeholder="t('admin.signProfiles.namePlaceholder')"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium">{{ t('admin.signProfiles.cert') }}</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input ref="certInput" type="file" accept=".pfx,.p12" class="hidden" @change="pickCert">
|
||||
<UiButton type="button" variant="outline" size="sm" @click="certInput?.click()">
|
||||
<FileKey2 class="mr-1.5 h-3.5 w-3.5" />
|
||||
{{ t('admin.signProfiles.chooseFile') }}
|
||||
</UiButton>
|
||||
<span class="truncate text-xs text-muted-foreground">
|
||||
{{ certFile ? certFile.name : t('admin.signProfiles.noFile') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium">{{ t('admin.signProfiles.password') }}</label>
|
||||
<input
|
||||
v-model="form.password"
|
||||
type="password"
|
||||
class="h-9 w-full rounded-md border border-input bg-background px-3 text-sm"
|
||||
:placeholder="t('admin.signProfiles.passwordPlaceholder')"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="form.platform === 'ios'">
|
||||
<label class="mb-1 block text-sm font-medium">{{ t('admin.signProfiles.provision') }}</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input ref="profileInput" type="file" accept=".mobileprovision" class="hidden" @change="pickProfile">
|
||||
<UiButton type="button" variant="outline" size="sm" @click="profileInput?.click()">
|
||||
<Upload class="mr-1.5 h-3.5 w-3.5" />
|
||||
{{ t('admin.signProfiles.chooseFile') }}
|
||||
</UiButton>
|
||||
<span class="truncate text-xs text-muted-foreground">
|
||||
{{ profileFile ? profileFile.name : t('admin.signProfiles.noFile') }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-muted-foreground">
|
||||
{{ t('admin.signProfiles.provisionHint') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<UiButton :disabled="uploading" @click="submit">
|
||||
<Upload class="mr-2 h-4 w-4" />
|
||||
{{ uploading ? t('admin.signProfiles.working') : t('admin.signProfiles.upload') }}
|
||||
</UiButton>
|
||||
<span class="text-xs text-muted-foreground">{{ t('admin.signProfiles.securityNote') }}</span>
|
||||
</div>
|
||||
</UiCardContent>
|
||||
</UiCard>
|
||||
|
||||
<!-- 列表 -->
|
||||
<UiCard>
|
||||
<UiCardHeader>
|
||||
<UiCardTitle class="text-base">
|
||||
{{ t('admin.signProfiles.list') }}
|
||||
</UiCardTitle>
|
||||
</UiCardHeader>
|
||||
<UiCardContent>
|
||||
<div v-if="loading" class="flex items-center gap-2 py-8 text-sm text-muted-foreground">
|
||||
<Loader2 class="h-4 w-4 animate-spin" />
|
||||
{{ t('admin.signProfiles.loading') }}
|
||||
</div>
|
||||
<div v-else-if="!items.length" class="py-10 text-center text-sm text-muted-foreground">
|
||||
{{ t('admin.signProfiles.empty') }}
|
||||
</div>
|
||||
<div v-else class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="border-b text-left text-muted-foreground">
|
||||
<tr>
|
||||
<th class="px-2 py-2 font-medium">
|
||||
{{ t('admin.signProfiles.colName') }}
|
||||
</th>
|
||||
<th class="px-2 py-2 font-medium">
|
||||
{{ t('admin.signProfiles.colPlatform') }}
|
||||
</th>
|
||||
<th class="px-2 py-2 font-medium">
|
||||
{{ t('admin.signProfiles.colFormat') }}
|
||||
</th>
|
||||
<th class="px-2 py-2 font-medium">
|
||||
{{ t('admin.signProfiles.colProvision') }}
|
||||
</th>
|
||||
<th class="px-2 py-2 font-medium">
|
||||
{{ t('admin.signProfiles.colCreated') }}
|
||||
</th>
|
||||
<th class="px-2 py-2 text-right font-medium">
|
||||
{{ t('admin.signProfiles.colActions') }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in items" :key="item.id" class="border-b last:border-0">
|
||||
<td class="px-2 py-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<ShieldCheck class="h-4 w-4 text-emerald-600 dark:text-emerald-400" />
|
||||
<span class="font-medium">{{ item.name }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-2 py-3">
|
||||
<span
|
||||
class="rounded border px-1.5 py-0.5 text-xs"
|
||||
:class="item.platform === 'ios'
|
||||
? 'border-violet-500/40 text-violet-600 dark:text-violet-400'
|
||||
: 'border-sky-500/40 text-sky-600 dark:text-sky-400'"
|
||||
>{{ platformLabel(item.platform) }}</span>
|
||||
</td>
|
||||
<td class="px-2 py-3 font-mono text-xs text-muted-foreground">
|
||||
{{ item.cert_format }}
|
||||
</td>
|
||||
<td class="px-2 py-3 text-xs">
|
||||
<span v-if="item.has_profile" class="text-emerald-600 dark:text-emerald-400">{{ t('admin.signProfiles.hasProfile') }}</span>
|
||||
<span v-else class="text-muted-foreground">-</span>
|
||||
</td>
|
||||
<td class="px-2 py-3 text-xs text-muted-foreground">
|
||||
{{ formatTime(item.created_at) }}
|
||||
</td>
|
||||
<td class="px-2 py-3">
|
||||
<div class="flex justify-end">
|
||||
<UiButton
|
||||
size="sm"
|
||||
:variant="pendingDelete === item.id ? 'destructive' : 'ghost'"
|
||||
@click="remove(item)"
|
||||
>
|
||||
<Trash2 class="h-4 w-4" :class="pendingDelete === item.id ? '' : 'text-destructive'" />
|
||||
<span v-if="pendingDelete === item.id" class="ml-1 text-xs">{{ t('admin.signProfiles.confirm') }}</span>
|
||||
</UiButton>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</UiCardContent>
|
||||
</UiCard>
|
||||
</div>
|
||||
</BasicPage>
|
||||
</template>
|
||||
@@ -2625,6 +2625,48 @@
|
||||
"working": "Working…",
|
||||
"published": "Version {v} created",
|
||||
"kind": "Type"
|
||||
},
|
||||
"signProfiles": {
|
||||
"title": "Signing certificates",
|
||||
"description": "Upload Windows pfx / iOS p12+provision; protected artifacts are re-signed with them. Certs and passwords are encrypted at rest and never sent back",
|
||||
"uploadTitle": "Upload certificate",
|
||||
"uploadHint": "Windows uses .pfx/.p12; iOS needs both .p12 and .mobileprovision",
|
||||
"platform": "Platform",
|
||||
"platformWindows": "Windows (Authenticode)",
|
||||
"platformIos": "iOS (zsign)",
|
||||
"name": "Name",
|
||||
"namePlaceholder": "e.g. my code signing cert",
|
||||
"cert": "Certificate file",
|
||||
"password": "Password",
|
||||
"passwordPlaceholder": "password of the pfx/p12",
|
||||
"provision": "Provisioning profile",
|
||||
"provisionHint": "Must be an Apple-issued .mobileprovision",
|
||||
"upload": "Upload",
|
||||
"working": "Working…",
|
||||
"refresh": "Refresh",
|
||||
"securityNote": "Encrypted at rest with AES-256-GCM; the API never returns contents",
|
||||
"list": "Certificates",
|
||||
"loading": "Loading…",
|
||||
"empty": "No certificates yet",
|
||||
"colName": "Name",
|
||||
"colPlatform": "Platform",
|
||||
"colFormat": "Format",
|
||||
"colProvision": "Profile",
|
||||
"colCreated": "Created",
|
||||
"colActions": "Actions",
|
||||
"hasProfile": "included",
|
||||
"onlyPfx": "Only .pfx / .p12 are supported",
|
||||
"needName": "Name is required",
|
||||
"needCert": "Choose a certificate file",
|
||||
"needProfile": "iOS requires a provisioning profile",
|
||||
"uploaded": "Certificate saved (encrypted)",
|
||||
"uploadFailed": "Upload failed",
|
||||
"loadFailed": "Failed to load",
|
||||
"deleted": "Deleted",
|
||||
"chooseFile": "Choose file",
|
||||
"noFile": "none",
|
||||
"confirmDelete": "Click again to delete {name}",
|
||||
"confirm": "Confirm"
|
||||
}
|
||||
},
|
||||
"auth": {
|
||||
@@ -3275,7 +3317,8 @@
|
||||
"storage": "Storage",
|
||||
"admin": "Admin",
|
||||
"agent": "Agent",
|
||||
"protect": "Protection"
|
||||
"protect": "Protection",
|
||||
"signProfiles": "Certificates"
|
||||
},
|
||||
"footer": {
|
||||
"brand": "Weishouquan",
|
||||
|
||||
@@ -2644,6 +2644,48 @@
|
||||
"working": "处理中…",
|
||||
"published": "已生成版本 {v}",
|
||||
"kind": "类型"
|
||||
},
|
||||
"signProfiles": {
|
||||
"title": "签名证书",
|
||||
"description": "上传 Windows pfx / iOS p12+描述文件,加壳产物用它们重签;证书与口令一律加密存储,永不下发前端",
|
||||
"uploadTitle": "上传证书",
|
||||
"uploadHint": "Windows 用 .pfx/.p12;iOS 需要 .p12 + .mobileprovision 两件套",
|
||||
"platform": "平台",
|
||||
"platformWindows": "Windows(Authenticode)",
|
||||
"platformIos": "iOS(zsign 重签)",
|
||||
"name": "名称",
|
||||
"namePlaceholder": "例如 我的代码签名证书",
|
||||
"cert": "证书文件",
|
||||
"password": "证书口令",
|
||||
"passwordPlaceholder": "pfx/p12 的导出密码",
|
||||
"provision": "描述文件",
|
||||
"provisionHint": "必须是苹果签发的 .mobileprovision,伪造的无法解析",
|
||||
"upload": "上传",
|
||||
"working": "处理中…",
|
||||
"refresh": "刷新",
|
||||
"securityNote": "证书与口令加密落盘(AES-256-GCM),接口不会回传内容",
|
||||
"list": "已上传的证书",
|
||||
"loading": "加载中…",
|
||||
"empty": "还没有上传证书",
|
||||
"colName": "名称",
|
||||
"colPlatform": "平台",
|
||||
"colFormat": "格式",
|
||||
"colProvision": "描述文件",
|
||||
"colCreated": "创建时间",
|
||||
"colActions": "操作",
|
||||
"hasProfile": "已包含",
|
||||
"onlyPfx": "证书只支持 .pfx / .p12",
|
||||
"needName": "请填写名称",
|
||||
"needCert": "请选择证书文件",
|
||||
"needProfile": "iOS 必须上传描述文件",
|
||||
"uploaded": "证书已加密保存",
|
||||
"uploadFailed": "上传失败",
|
||||
"loadFailed": "加载失败",
|
||||
"deleted": "已删除",
|
||||
"chooseFile": "选择文件",
|
||||
"noFile": "未选择",
|
||||
"confirmDelete": "再点一次删除「{name}」",
|
||||
"confirm": "确认"
|
||||
}
|
||||
},
|
||||
"auth": {
|
||||
@@ -3294,7 +3336,8 @@
|
||||
"storage": "存储",
|
||||
"admin": "管理员",
|
||||
"agent": "代理商",
|
||||
"protect": "加壳加固"
|
||||
"protect": "加壳加固",
|
||||
"signProfiles": "签名证书"
|
||||
},
|
||||
"footer": {
|
||||
"brand": "网络验证",
|
||||
|
||||
@@ -113,6 +113,12 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('@/pages/admin/protect/index.vue'),
|
||||
meta: { title: '加壳加固 - 管理后台' },
|
||||
},
|
||||
{
|
||||
path: 'sign-profiles',
|
||||
name: 'AdminSignProfiles',
|
||||
component: () => import('@/pages/admin/sign-profiles/index.vue'),
|
||||
meta: { title: '签名证书 - 管理后台' },
|
||||
},
|
||||
{
|
||||
path: 'versions/create',
|
||||
name: 'AdminVersionCreate',
|
||||
|
||||
Vendored
+13
@@ -374,6 +374,13 @@ declare module 'vue-router/auto-routes' {
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/admin/sign-profiles/': RouteRecordInfo<
|
||||
'/admin/sign-profiles/',
|
||||
'/admin/sign-profiles',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'/admin/sms-settings/': RouteRecordInfo<
|
||||
'/admin/sms-settings/',
|
||||
'/admin/sms-settings',
|
||||
@@ -982,6 +989,12 @@ declare module 'vue-router/auto-routes' {
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/pages/admin/sign-profiles/index.vue': {
|
||||
routes:
|
||||
| '/admin/sign-profiles/'
|
||||
views:
|
||||
| never
|
||||
}
|
||||
'src/pages/admin/sms-settings/index.vue': {
|
||||
routes:
|
||||
| '/admin/sms-settings/'
|
||||
|
||||
Reference in New Issue
Block a user