Ver código fonte

update axios-init and db.go

Hamidreza Ghavami 1 ano atrás
pai
commit
85c715a2f6
3 arquivos alterados com 21 adições e 5 exclusões
  1. 12 0
      database/db.go
  2. 1 1
      web/assets/css/custom.css
  3. 8 4
      web/assets/js/axios-init.js

+ 12 - 0
database/db.go

@@ -1,6 +1,8 @@
 package database
 
 import (
+	"bytes"
+	"io"
 	"io/fs"
 	"os"
 	"path"
@@ -104,3 +106,13 @@ func GetDB() *gorm.DB {
 func IsNotFound(err error) bool {
 	return err == gorm.ErrRecordNotFound
 }
+
+func IsSQLiteDB(file io.Reader) (bool, error) {
+	signature := []byte("SQLite format 3\x00")
+	buf := make([]byte, len(signature))
+	_, err := file.Read(buf)
+	if err != nil {
+		return false, err
+	}
+	return bytes.Equal(buf, signature), nil
+}

+ 1 - 1
web/assets/css/custom.css

@@ -1,5 +1,5 @@
 #app {
-    height: 100%;
+    height: 100vh;
 }
 
 .ant-space {

+ 8 - 4
web/assets/js/axios-init.js

@@ -3,10 +3,14 @@ axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
 
 axios.interceptors.request.use(
     config => {
-        config.data = Qs.stringify(config.data, {
-            arrayFormat: 'repeat'
-        });
+        if (config.data instanceof FormData) {
+            config.headers['Content-Type'] = 'multipart/form-data';
+        } else {
+            config.data = Qs.stringify(config.data, {
+                arrayFormat: 'repeat',
+            });
+        }
         return config;
     },
     error => Promise.reject(error)
-);
+);