From 7061aa5df1965a2d1e67f7f7d3c10b6bddb04e24 Mon Sep 17 00:00:00 2001
From: rjg <746338628@qq.com>
Date: Fri, 16 May 2025 15:25:47 +0800
Subject: [PATCH] fix:证书有效性
---
src/api/license/uploadLicense.js | 18 +++++++++
src/views/license/upload.vue | 57 ++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/src/api/license/uploadLicense.js b/src/api/license/uploadLicense.js
new file mode 100644
index 0000000..2fd8158
--- /dev/null
+++ b/src/api/license/uploadLicense.js
@@ -0,0 +1,18 @@
+import axios from 'axios';
+
+/**
+ * 上传 License 文件
+ * @param {File} file 要上传的文件
+ * @returns {Promise} 返回上传结果
+ */
+export function uploadLicense(file) {
+ const formData = new FormData();
+ formData.append('file', file);
+
+ return axios.post('/api/blade-system/license/uploadLicense', formData, {
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ Authorization: `Bearer ${localStorage.getItem('token')}`, // 替换为实际的认证 token
+ },
+ });
+}
\ No newline at end of file
diff --git a/src/views/license/upload.vue b/src/views/license/upload.vue
new file mode 100644
index 0000000..c9378c6
--- /dev/null
+++ b/src/views/license/upload.vue
@@ -0,0 +1,57 @@
+<!-- filepath: /d:/work/drone-web-manage/src/views/license/upload.vue -->
+<template>
+ <basic-container>
+ <el-upload
+ class="upload-demo"
+ drag
+ :http-request="customUpload"
+ :show-file-list="false"
+ accept=".lic"
+ >
+ <i class="el-icon-upload"></i>
+ <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
+ <div class="el-upload__tip">仅支持扩展名:lic</div>
+ </el-upload>
+ </basic-container>
+</template>
+
+<script>
+import { uploadLicense } from '@/api/license/uploadLicense';
+
+export default {
+ methods: {
+ async customUpload({ file }) {
+ try {
+ const response = await uploadLicense(file);
+ if (response.data.success) {
+ this.$message.success('文件上传成功');
+ } else {
+ this.$message.error(response.data.message || '文件上传失败');
+ }
+ } catch (error) {
+ console.error('上传失败:', error);
+ this.$message.error('文件上传失败');
+ }
+ },
+ },
+};
+</script>
+
+<style scoped>
+.upload-demo {
+ width: 100%;
+ border: 2px dashed #d9d9d9;
+ border-radius: 6px;
+ background-color: #fafafa;
+ text-align: center;
+ padding: 40px 20px;
+}
+.el-upload__text {
+ font-size: 16px;
+ color: #606266;
+}
+.el-upload__tip {
+ font-size: 12px;
+ color: #909399;
+}
+</style>
\ No newline at end of file
--
Gitblit v1.9.3