mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
21
sop-admin/sop-admin-frontend/src/utils/file.ts
Normal file
21
sop-admin/sop-admin-frontend/src/utils/file.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
* @param filename 文件名称,带后缀,如:aa.txt
|
||||
* @param text 文件内容
|
||||
*/
|
||||
export function downloadText(filename, text) {
|
||||
const element = document.createElement("a");
|
||||
element.setAttribute(
|
||||
"href",
|
||||
"data:text/plain;charset=utf-8," + encodeURIComponent(text)
|
||||
);
|
||||
element.setAttribute("download", filename);
|
||||
|
||||
element.style.display = "none";
|
||||
document.body.appendChild(element);
|
||||
|
||||
element.click();
|
||||
|
||||
document.body.removeChild(element);
|
||||
}
|
@@ -21,6 +21,7 @@ import {
|
||||
dlgKeysShow,
|
||||
showKeysFormColumns,
|
||||
showKeysFormData,
|
||||
downloadIsvKey,
|
||||
viewKeys
|
||||
} from "./showKeys";
|
||||
import {
|
||||
@@ -98,8 +99,12 @@ import {
|
||||
v-model="showKeysFormData"
|
||||
:dialog="{ title: '秘钥 - 标识☆分配给开发者' }"
|
||||
:form="{ group: showKeysFormColumns, labelPosition: 'right' }"
|
||||
@confirm="downloadIsvKey"
|
||||
>
|
||||
<template #dialog-footer="{ handleCancel }">
|
||||
<el-button type="success" @click="downloadIsvKey">
|
||||
下载开发者秘钥
|
||||
</el-button>
|
||||
<el-button type="primary" @click="handleCancel">关闭</el-button>
|
||||
</template>
|
||||
</PlusDialogForm>
|
||||
|
@@ -2,10 +2,12 @@ import { ref } from "vue";
|
||||
import type { PlusFormGroupRow } from "plus-pro-components";
|
||||
import { api } from "@/api/isvList";
|
||||
import { KeyFormatEnum } from "@/model/enums";
|
||||
import { downloadText } from "@/utils/file";
|
||||
|
||||
// 弹窗显示
|
||||
export const dlgKeysShow = ref(false);
|
||||
export const showKeysFormData = ref<any>({
|
||||
appId: "",
|
||||
keyFormat: KeyFormatEnum.PKCS8,
|
||||
publicKeyIsv: "",
|
||||
privateKeyIsv: "",
|
||||
@@ -17,6 +19,15 @@ export const showKeysFormColumns: PlusFormGroupRow[] = [
|
||||
{
|
||||
title: "基本信息",
|
||||
columns: [
|
||||
{
|
||||
label: "AppId",
|
||||
prop: "appId",
|
||||
labelWidth: 100,
|
||||
valueType: "text",
|
||||
fieldProps: {
|
||||
disabled: true
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "秘钥格式",
|
||||
prop: "keyFormat",
|
||||
@@ -107,3 +118,23 @@ export const viewKeys = (row: any) => {
|
||||
dlgKeysShow.value = true;
|
||||
});
|
||||
};
|
||||
|
||||
const downloadTemplate = `AppID:
|
||||
{appId}
|
||||
|
||||
开发者私钥:
|
||||
{privateKeyIsv}
|
||||
|
||||
平台公钥:
|
||||
{publicKeyPlatform}
|
||||
|
||||
`;
|
||||
|
||||
export const downloadIsvKey = () => {
|
||||
let text = downloadTemplate
|
||||
.replace("{appId}", showKeysFormData.value.appId)
|
||||
.replace("{privateKeyIsv}", showKeysFormData.value.privateKeyIsv)
|
||||
.replace("{publicKeyPlatform}", showKeysFormData.value.publicKeyPlatform);
|
||||
|
||||
downloadText(`key_${new Date().getTime()}.txt`, text);
|
||||
};
|
||||
|
Reference in New Issue
Block a user