从后端请求回来的数据是密钥,密钥的格式一般就是:
所以将此内容导出以pem文件扩展名
demo:
<v-btn depressed color="primary" @click="exportSecretkey">
<v-icon class="pr-1">mdi-database-export-outline</v-icon>
导出密钥
</v-btn>
exportSecretkey() {
const blob = new Blob([this.credentials.signing.private_key], {
type: "text/plain;charset=utf-8"
});
if ("download" in document.createElement("a")) {
const elink = document.createElement("a");
elink.download = `${this.name}密钥.pem`;
elink.style.display = "none";
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href);
document.body.removeChild(elink);
}
}