|
@@ -1,84 +1,85 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <div class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5">
|
|
|
- <h3 class="section-title">授权信息</h3>
|
|
|
- <div>
|
|
|
- <a-form :labelCol="{ style: { width: '150px' } }">
|
|
|
- <a-form-item label="当前信息" style="margin-bottom: 5px">
|
|
|
- <span>{{ info.activation }}</span>
|
|
|
- </a-form-item>
|
|
|
- <a-form-item label="人数限制" style="margin-bottom: 5px">
|
|
|
- <span>{{ info.maxCount }}</span>
|
|
|
- </a-form-item>
|
|
|
- <a-form-item label="当前人数" style="margin-bottom: 5px">
|
|
|
- <span>{{ info.onlineCount }}</span>
|
|
|
- </a-form-item>
|
|
|
- <a-form-item label="过期时间" style="margin-bottom: 5px">
|
|
|
- <span>{{ info.expire }}</span>
|
|
|
- </a-form-item>
|
|
|
- <a-form-item label="授权模式" style="margin-bottom: 5px">
|
|
|
- <span>{{ info.type }}</span>
|
|
|
- </a-form-item>
|
|
|
- </a-form>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="tw-bg-white tw-p-5 tw-rounded-xl">
|
|
|
- <a-form :labelCol="{ style: { width: '150px' } }" style="width: 600px">
|
|
|
- <a-form-item label="授权模式">
|
|
|
- <a-select v-model:value="authForm.authType" style="width: 200px">
|
|
|
- <a-select-option value="ONLINE">在线激活</a-select-option>
|
|
|
- <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-card title="授权信息">
|
|
|
+ <a-form class="tiny" :labelCol="{ style: { width: '72px' } }">
|
|
|
+ <a-form-item label="当前信息">
|
|
|
+ <a-tag :bordered="false" :color="info.auth ? 'success' : 'default'">{{
|
|
|
+ info.activation
|
|
|
+ }}</a-tag>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="人数限制">
|
|
|
+ <span>{{ info.maxCount }}</span>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="当前人数">
|
|
|
+ <span>{{ info.onlineCount }}</span>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="过期时间">
|
|
|
+ <span>{{ info.expire }}</span>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="授权模式">
|
|
|
+ <span>{{ info.type }}</span>
|
|
|
+ </a-form-item>
|
|
|
+ </a-form>
|
|
|
+ </a-card>
|
|
|
+ <a-card title="授权设置">
|
|
|
+ <a-form :labelCol="{ style: { width: '72px' } }" style="width: 600px">
|
|
|
+ <a-form-item label="授权模式">
|
|
|
+ <a-select v-model:value="authForm.authType" style="width: 120px">
|
|
|
+ <a-select-option value="ONLINE">在线激活</a-select-option>
|
|
|
+ <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-input
|
|
|
- v-model:value="authForm.accessSecret"
|
|
|
- :maxlength="255"
|
|
|
- allowClear
|
|
|
- />
|
|
|
- </a-form-item>
|
|
|
- <a-form-item
|
|
|
- v-show="authForm.authType == 'OFFLINE'"
|
|
|
- label="导入授权文件"
|
|
|
+ <a-button>
|
|
|
+ <template #icon>
|
|
|
+ <svg-icon name="file"></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-upload
|
|
|
- accept=".lic"
|
|
|
- :customRequest="customRequest"
|
|
|
- :showUploadList="false"
|
|
|
- >
|
|
|
- <a-button type="primary">选择文件</a-button>
|
|
|
- </a-upload>
|
|
|
- </a-form-item>
|
|
|
- <a-form-item v-if="authForm.authType == 'OFFLINE'" label="硬件信息">
|
|
|
- <a-button type="primary" @click="exportFile">导出硬件信息</a-button>
|
|
|
- </a-form-item>
|
|
|
- <a-form-item v-else>
|
|
|
- <a-button
|
|
|
- style="margin-left: 150px"
|
|
|
- type="primary"
|
|
|
- @click="submitForm"
|
|
|
- >保存</a-button
|
|
|
- >
|
|
|
- </a-form-item>
|
|
|
- </a-form>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ </a-form-item>
|
|
|
+ </a-form>
|
|
|
+ </a-card>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
@@ -90,6 +91,7 @@ import {
|
|
|
import { message } from "ant-design-vue";
|
|
|
import { onMounted, reactive } from "vue";
|
|
|
import { downloadFileURL } from "@/utils/utils";
|
|
|
+import useLoading from "@/hooks/loading";
|
|
|
|
|
|
interface InfoType {
|
|
|
activation: string;
|
|
@@ -97,6 +99,7 @@ interface InfoType {
|
|
|
type: string;
|
|
|
maxCount: string;
|
|
|
onlineCount: number;
|
|
|
+ auth: boolean;
|
|
|
}
|
|
|
|
|
|
interface AuthFormType {
|
|
@@ -111,6 +114,7 @@ let info: InfoType = reactive({
|
|
|
type: "",
|
|
|
maxCount: "",
|
|
|
onlineCount: 0,
|
|
|
+ auth: false,
|
|
|
});
|
|
|
|
|
|
let authForm: AuthFormType = reactive({
|
|
@@ -122,9 +126,11 @@ let authForm: AuthFormType = reactive({
|
|
|
onMounted(async () => {
|
|
|
await fetchData();
|
|
|
});
|
|
|
+const { loading, setLoading } = useLoading();
|
|
|
|
|
|
async function fetchData() {
|
|
|
const res = await getAuthInfo();
|
|
|
+ info.auth = res.data.auth;
|
|
|
if (res.data.auth == true) {
|
|
|
info.activation = "已授权";
|
|
|
if (info.activation == "已授权" && !res.data.expireTime) {
|
|
@@ -143,21 +149,30 @@ async function fetchData() {
|
|
|
info.activation = "未授权";
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
async function submitForm() {
|
|
|
- await onlineAuth(authForm);
|
|
|
+ if (loading.value) return;
|
|
|
+ setLoading(true);
|
|
|
+ await onlineAuth(authForm).catch(() => {});
|
|
|
+ setLoading(false);
|
|
|
void message.success("操作成功");
|
|
|
}
|
|
|
|
|
|
// offline-auth
|
|
|
async function customRequest(data: { file: File }) {
|
|
|
+ setLoading(true);
|
|
|
let formData = new FormData();
|
|
|
formData.append("file", data.file);
|
|
|
- await offlineAuth(formData);
|
|
|
+ await offlineAuth(formData).catch(() => {});
|
|
|
+ setLoading(false);
|
|
|
void message.success("上传成功!");
|
|
|
await fetchData();
|
|
|
}
|
|
|
|
|
|
async function exportFile() {
|
|
|
- await downloadFileURL("/api/ess/system/auth/device/info");
|
|
|
+ if (loading.value) return;
|
|
|
+ setLoading(true);
|
|
|
+ await downloadFileURL("/api/ess/system/auth/device/info").catch(() => {});
|
|
|
+ setLoading(false);
|
|
|
}
|
|
|
</script>
|