Bläddra i källkod

增加下载密钥功能

张佳燕 1 år sedan
förälder
incheckning
32297d23f0
2 ändrade filer med 16 tillägg och 6 borttagningar
  1. 1 1
      public/config.js
  2. 15 5
      src/views/user_manage/index.vue

+ 1 - 1
public/config.js

@@ -1,6 +1,6 @@
 window.g = {
   ApiUrl: 'https://aiotota.dpm.org.cn/middle-management',
-  wsPath: 'wss://aiotota.dpm.org.cn/websocket',
+  wsPath: 'wss://aiotota.dpm.org.cn/websocket?token=',
   // ApiUrl: 'http://192.168.11.9:9086/middle-management',
   // wsPath: 'ws://192.168.11.9:19086/websocket?token=',
 }

+ 15 - 5
src/views/user_manage/index.vue

@@ -1,10 +1,7 @@
 <template>
   <div class="app-container">
     <!--操作区-->
-    <el-button
-      type="primary"
-      icon="el-icon-plus"
-      @click="create()"
+    <el-button type="primary" icon="el-icon-plus" @click="create()"
       >添加账号</el-button
     >
     <el-select
@@ -104,7 +101,7 @@
           {{ scope.row.createTime }}
         </template>
       </el-table-column>
-      <el-table-column align="center" prop="" label="操作区" width="200">
+      <el-table-column align="center" prop="" label="操作区" width="280">
         <template slot-scope="scope">
           <el-button type="primary" size="small" @click="create(scope.row)"
             >编辑</el-button
@@ -115,6 +112,12 @@
             @click="deleteUser(scope.row.id)"
             >删除</el-button
           >
+          <el-button
+            type="primary"
+            size="small"
+            @click="getAppKeyAndAppSecret(scope.row)"
+            >下载密钥</el-button
+          >
         </template>
       </el-table-column>
     </el-table>
@@ -218,6 +221,8 @@ import {
 } from "@/api/user";
 import Pagination from "@/components/Pagination";
 import { checkRole } from "@/utils/checkRole";
+import { saveAs } from "file-saver"; // 字符串保存成 TXT 文件保存到电脑
+
 export default {
   components: { Pagination },
   filters: {
@@ -310,6 +315,11 @@ export default {
         this.listLoading = false;
       });
     },
+    getAppKeyAndAppSecret(row) {
+      let str = `appId: ${row.appId}\r\nappKey: ${row.appKey}\r\nappSecret: ${row.appSecret}\r\nprivateKey: ${row.privateKey}`;
+      let strData = new Blob([str], { type: "text/plain;charset=utf-8" });
+      saveAs(strData, "密钥.txt");
+    },
     // 打开添加账号对话框
     create(row) {
       if (row) {