suncloud 1 éve
szülő
commit
574f25cd84
1 módosított fájl, 5 hozzáadás és 1 törlés
  1. 5 1
      src/api/test.go

+ 5 - 1
src/api/test.go

@@ -279,8 +279,12 @@ func ExportTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 func TestTmplate(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	db := c.Param("scope")
 	fmt.Println(db)
+	filename := "考核试题模板.xlsx"
+	// url.PathEscape将字符串中的特殊字符进行编码,使其符合URL规范
+	filename = url.PathEscape(filename)
+
 	// 设置下载的文件名
-	c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", TESTS_TMPLATE_FILE))
+	c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filename))
 
 	// 设置文件类型
 	c.Writer.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")