|
@@ -28,56 +28,57 @@
|
|
|
<a-select-option value="OFFLINE">离线激活</a-select-option>
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
- <a-form-item
|
|
|
- v-show="authForm.authType == 'ONLINE'"
|
|
|
- label="密匙"
|
|
|
- prop="accessKey"
|
|
|
- >
|
|
|
- <a-input
|
|
|
- v-model:value="authForm.accessKey"
|
|
|
- :maxlength="255"
|
|
|
- allowClear
|
|
|
- />
|
|
|
- </a-form-item>
|
|
|
- <a-form-item
|
|
|
- v-show="authForm.authType == 'ONLINE'"
|
|
|
- label="密钥"
|
|
|
- prop="accessSecret"
|
|
|
- >
|
|
|
- <a-input
|
|
|
- v-model:value="authForm.accessSecret"
|
|
|
- :maxlength="255"
|
|
|
- allowClear
|
|
|
- />
|
|
|
- </a-form-item>
|
|
|
- <a-form-item v-show="authForm.authType == 'OFFLINE'" label="授权文件">
|
|
|
- <a-upload
|
|
|
- accept=".lic"
|
|
|
- :before-upload="customRequest"
|
|
|
- :showUploadList="false"
|
|
|
- :disabled="loading"
|
|
|
- >
|
|
|
- <a-button>
|
|
|
+ <template v-if="authForm.authType == 'ONLINE'">
|
|
|
+ <a-form-item label="密匙" prop="accessKey">
|
|
|
+ <a-input
|
|
|
+ v-model:value="authForm.accessKey"
|
|
|
+ :maxlength="255"
|
|
|
+ allowClear
|
|
|
+ />
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="密钥" prop="accessSecret">
|
|
|
+ <a-input
|
|
|
+ v-model:value="authForm.accessSecret"
|
|
|
+ :maxlength="255"
|
|
|
+ allowClear
|
|
|
+ />
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item style="margin-left: 72px">
|
|
|
+ <a-button type="primary" :loading="confirmLoading" @click="submitForm"
|
|
|
+ >保存</a-button
|
|
|
+ >
|
|
|
+ </a-form-item>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template v-if="authForm.authType == 'OFFLINE'">
|
|
|
+ <a-form-item label="授权文件">
|
|
|
+ <a-upload
|
|
|
+ accept=".lic"
|
|
|
+ :before-upload="beforeUpload"
|
|
|
+ :disabled="importLoading"
|
|
|
+ >
|
|
|
+ <a-button>
|
|
|
+ <template #icon>
|
|
|
+ <svg-icon name="file"></svg-icon>
|
|
|
+ </template>
|
|
|
+ 选择文件
|
|
|
+ </a-button>
|
|
|
+ </a-upload>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="硬件信息">
|
|
|
+ <a-button :loading="loading" @click="exportFile">
|
|
|
<template #icon>
|
|
|
- <svg-icon name="file"></svg-icon>
|
|
|
+ <svg-icon name="export"></svg-icon>
|
|
|
</template>
|
|
|
- 选择文件
|
|
|
+ 导出信息
|
|
|
</a-button>
|
|
|
- </a-upload>
|
|
|
- </a-form-item>
|
|
|
- <a-form-item v-if="authForm.authType == 'OFFLINE'" label="硬件信息">
|
|
|
- <a-button :loading="loading" @click="exportFile">
|
|
|
- <template #icon>
|
|
|
- <svg-icon name="export"></svg-icon>
|
|
|
- </template>
|
|
|
- 导出信息
|
|
|
- </a-button>
|
|
|
- </a-form-item>
|
|
|
- <a-form-item v-else>
|
|
|
- <a-button type="primary" :loading="loading" @click="submitForm"
|
|
|
- >保存</a-button
|
|
|
- >
|
|
|
- </a-form-item>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item style="margin-left: 72px">
|
|
|
+ <a-button type="primary" :loading="importLoading" @click="uploadFile"
|
|
|
+ >保存</a-button
|
|
|
+ >
|
|
|
+ </a-form-item>
|
|
|
+ </template>
|
|
|
</a-form>
|
|
|
</a-card>
|
|
|
</template>
|
|
@@ -89,7 +90,9 @@ import {
|
|
|
onlineAuth,
|
|
|
} from "../../api/authManagementPage";
|
|
|
import { message } from "ant-design-vue";
|
|
|
-import { onMounted, reactive } from "vue";
|
|
|
+import type { UploadProps } from "ant-design-vue";
|
|
|
+
|
|
|
+import { onMounted, reactive, ref } from "vue";
|
|
|
import { downloadFileURL } from "@/utils/utils";
|
|
|
import useLoading from "@/hooks/loading";
|
|
|
|
|
@@ -126,7 +129,6 @@ let authForm: AuthFormType = reactive({
|
|
|
onMounted(async () => {
|
|
|
await fetchData();
|
|
|
});
|
|
|
-const { loading, setLoading } = useLoading();
|
|
|
|
|
|
async function fetchData() {
|
|
|
const res = await getAuthInfo();
|
|
@@ -150,25 +152,39 @@ async function fetchData() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const { loading: confirmLoading, setLoading: setConfirmLoading } = useLoading();
|
|
|
async function submitForm() {
|
|
|
if (loading.value) return;
|
|
|
- setLoading(true);
|
|
|
+ setConfirmLoading(true);
|
|
|
await onlineAuth(authForm).catch(() => {});
|
|
|
- setLoading(false);
|
|
|
+ setConfirmLoading(false);
|
|
|
void message.success("操作成功");
|
|
|
}
|
|
|
|
|
|
// offline-auth
|
|
|
-async function customRequest(data: { file: File }) {
|
|
|
- setLoading(true);
|
|
|
+let fileList = $ref<UploadProps["fileList"]>([]);
|
|
|
+const beforeUpload: UploadProps["beforeUpload"] = (file) => {
|
|
|
+ fileList = [file];
|
|
|
+ return false;
|
|
|
+};
|
|
|
+const { loading: importLoading, setLoading: setImportLoading } = useLoading();
|
|
|
+async function uploadFile() {
|
|
|
+ if (!fileList?.length) return;
|
|
|
+ setImportLoading(true);
|
|
|
+
|
|
|
let formData = new FormData();
|
|
|
- formData.append("file", data.file);
|
|
|
- await offlineAuth(formData).catch(() => {});
|
|
|
- setLoading(false);
|
|
|
+ formData.append("file", fileList[0] as any);
|
|
|
+ let err = false;
|
|
|
+ await offlineAuth(formData).catch(() => {
|
|
|
+ err = true;
|
|
|
+ });
|
|
|
+ setImportLoading(false);
|
|
|
+ if (err) return;
|
|
|
void message.success("上传成功!");
|
|
|
await fetchData();
|
|
|
}
|
|
|
|
|
|
+const { loading, setLoading } = useLoading();
|
|
|
async function exportFile() {
|
|
|
if (loading.value) return;
|
|
|
setLoading(true);
|