修复一些问题
This commit is contained in:
@@ -159,7 +159,7 @@ func V1_user_api(r *gin.RouterGroup) {
|
||||
_, is_login := ctx.Get("user_info")
|
||||
//fmt.Println(is_login)
|
||||
//fmt.Println(user_info)
|
||||
if is_login == true {
|
||||
if is_login {
|
||||
//fmt.Println("loged")
|
||||
cookie_any, _ := ctx.Get("cookie") //这个cookie在中间件已经判断为有效的,否则is_login不可能为true,所以直接在数据库删除应该是安全的
|
||||
//删除数据库里的cookie
|
||||
|
||||
@@ -185,7 +185,7 @@ func Router_def(r *gin.RouterGroup) {
|
||||
user_info, is_login := ctx.Get("user_info")
|
||||
|
||||
//判断是否登录
|
||||
if is_login == true {
|
||||
if is_login {
|
||||
|
||||
ctx.HTML(http.StatusOK, "setting-my.html", gin.H{
|
||||
"is_login": is_login,
|
||||
@@ -201,7 +201,7 @@ func Router_def(r *gin.RouterGroup) {
|
||||
user_info, is_login := ctx.Get("user_info")
|
||||
user, _ := ctx.Get("user")
|
||||
//判断是否登录
|
||||
if is_login == true {
|
||||
if is_login {
|
||||
|
||||
ctx.HTML(http.StatusOK, "setting-security.html", gin.H{
|
||||
"is_login": is_login,
|
||||
|
||||
@@ -33,7 +33,7 @@ func Router_file(r *gin.RouterGroup) {
|
||||
upload := r.Group("/upload") //定义上传组
|
||||
//4大媒体上传接口,严格判断文件类型,可以直接被前端引用
|
||||
upload.POST("/image", func(ctx *gin.Context) {
|
||||
|
||||
Return_json(ctx, "api_ok", nil)
|
||||
})
|
||||
upload.POST("/video", func(ctx *gin.Context) {
|
||||
|
||||
|
||||
Vendored
+2
-1
@@ -28,7 +28,8 @@ function load_json(key) {
|
||||
}
|
||||
|
||||
function post_file(path, file, file_name, callback) {
|
||||
var head_path = "/file";
|
||||
//console.log(file)
|
||||
var head_path = "/file/upload";
|
||||
// 创建FormData对象
|
||||
const formData = new FormData();
|
||||
formData.append("file", file, file_name); // 'file' 是后端接收文件的字段名
|
||||
|
||||
@@ -503,7 +503,7 @@
|
||||
document.getElementById('preview-img').src = previewUrl;
|
||||
// 清理旧URL
|
||||
setTimeout(() => URL.revokeObjectURL(previewUrl), 1000);
|
||||
}, 'image/jpeg', 0.85);
|
||||
}, 'image/png', 0.85);
|
||||
updateImageInfo();
|
||||
}
|
||||
}
|
||||
@@ -556,10 +556,10 @@
|
||||
});
|
||||
|
||||
const blob = await new Promise(resolve =>
|
||||
canvas.toBlob(resolve, 'image/jpeg', 0.9)
|
||||
canvas.toBlob(resolve, 'image/png', 0.9)
|
||||
);
|
||||
|
||||
post_file("/upload", blob, `avatar_${Date.now()}.jpg`, (c) => {
|
||||
post_file("/image", blob, `avatar_${Date.now()}.jpg`, (c) => {
|
||||
if (c.statusCode == 200) {
|
||||
if (c.data.err_code == 0) {
|
||||
//save_json("cookie", c.data.return.cookie)
|
||||
@@ -588,17 +588,17 @@
|
||||
// }
|
||||
// });
|
||||
|
||||
if (!response.ok) throw new Error(`服务器错误: ${response.status}`);
|
||||
// if (!response.ok) throw new Error(`服务器错误: ${response.status}`);
|
||||
|
||||
const result = await response.json();
|
||||
if (result.err_code == 0) {
|
||||
showMessage(`✅ 上传成功!`, 'success');
|
||||
set_user_avatar(result.data.path);
|
||||
console.log(get_user_avatar());
|
||||
avatar_toolt.hide();
|
||||
} else {
|
||||
showMessage(`❌ 上传失败: ${result.err_msg}`, 'error');
|
||||
}
|
||||
// const result = await response.json();
|
||||
// if (result.err_code == 0) {
|
||||
// showMessage(`✅ 上传成功!`, 'success');
|
||||
// set_user_avatar(result.data.path);
|
||||
// console.log(get_user_avatar());
|
||||
// avatar_toolt.hide();
|
||||
// } else {
|
||||
// showMessage(`❌ 上传失败: ${result.err_msg}`, 'error');
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user