fix code suffix

This commit is contained in:
Zhang Minghan 2023-09-23 18:58:12 +08:00
parent b723cb5821
commit f05e3658c4
2 changed files with 4 additions and 2 deletions

View File

@ -90,11 +90,11 @@ function Wrapper({ onSend }: WrapperProps) {
{
hash.length > 0 &&
<div className={`hash-box`}>
<a className={`download-box`} target={`_blank`} href={`${rest_api}/generation/download/tar?hash=${hash}`}>
<a className={`download-box`} href={`${rest_api}/generation/download/tar?hash=${hash}`}>
<FileDown className={`h-6 w-6`} />
<p>{ t('generate.download', { name: "tar.gz"}) }</p>
</a>
<a className={`download-box`} target={`_blank`} href={`${rest_api}/generation/download/zip?hash=${hash}`}>
<a className={`download-box`} href={`${rest_api}/generation/download/zip?hash=${hash}`}>
<FileDown className={`h-6 w-6`} />
<p>{ t('generate.download', { name: "zip"}) }</p>
</a>

View File

@ -23,11 +23,13 @@ type WebsocketGenerationForm struct {
func ProjectTarDownloadAPI(c *gin.Context) {
hash := strings.TrimSpace(c.Query("hash"))
c.Writer.Header().Add("Content-Disposition", "attachment; filename=code.tar.gz")
c.File(fmt.Sprintf("generation/data/out/%s.tar.gz", hash))
}
func ProjectZipDownloadAPI(c *gin.Context) {
hash := strings.TrimSpace(c.Query("hash"))
c.Writer.Header().Add("Content-Disposition", "attachment; filename=code.zip")
c.File(fmt.Sprintf("generation/data/out/%s.zip", hash))
}