浏览代码

modify alert message

ming 3 年之前
父节点
当前提交
2039392525
共有 3 个文件被更改,包括 9 次插入2 次删除
  1. 1 1
      api/main.py
  2. 2 0
      api/static/gen_avatar.html
  3. 6 1
      api/static/script_msg.js

+ 1 - 1
api/main.py

@@ -96,7 +96,7 @@ async def swapFace(req:swap_req):
     name_hash = str(time.time()).replace('.','')
     x = threading.Thread(target=gen_avatar, args=(name_hash,req.imgurl))
     x.start()
-    return '人物生成中,請稍候'
+    return {'msg':'人物生成中,請稍候'}
 
 @app.post("/uploadfile/")
 async def create_upload_file(file: UploadFile = File(...)):

+ 2 - 0
api/static/gen_avatar.html

@@ -10,6 +10,8 @@
   <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
   <link rel="stylesheet" href="static/style.css">
   <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
+  <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.18/dist/sweetalert2.all.min.js"></script>
+  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.18/dist/sweetalert2.min.css">
   <style>
     body {
       font-family: "Lato", sans-serif;

+ 6 - 1
api/static/script_msg.js

@@ -106,7 +106,12 @@ $(".gen_avatar").click(function () {
     type: 'post',
     data: objstr,
     success: function (suc_data) {
-      alert(suc_data.msg)
+      Swal.fire({
+        title: "資料已送出",
+        icon: 'success',
+        text: `${suc_data.msg}`,
+        confirmButtonColor: '#3085d6',
+      });
     },
     //data:JSON.stringify({n1:"12",n2:"22"}),
     error: function (error) {