Skip to content

Commit

Permalink
fix: missing extension while downloading art variants
Browse files Browse the repository at this point in the history
Closes: #5
  • Loading branch information
FlandiaYingman committed May 3, 2024
1 parent 00fd938 commit d5ddf7a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@mdi/font": "^7.4.47",
"file-saver": "^2.0.5",
"lodash": "^4.17.21",
"mime-types": "^2.1.35",
"pinia": "^2.1.7",
"vue": "^3.4.15",
"vue-i18n": "^9.9.0",
Expand Down
10 changes: 5 additions & 5 deletions src/views/art/ArtView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { useArkwaifu } from '@/stores/arkwaifu-api'
import { storeToRefs } from 'pinia'
import { useMetaStore } from '@/stores/meta'
import ArtPanel from '@/components/art/ArtPanel.vue'
import mime from 'mime-types'
const props = defineProps<{
id: string
Expand All @@ -78,16 +79,15 @@ watchEffect(async () => {
}
})
function filename(variant: Variant): string {
function filename(variant: Variant, format: string): string {
let filename = variant.artID
if (variant.variation != Variation.Origin) {
filename += `.${variant.variation}`
}
if (variant.variation != Variation.Origin) filename += `.${variant.variation}`
filename += `.${mime.extension(format)}`
return filename
}
function download(variant: Variant, format: string) {
const name = filename(variant)
const name = filename(variant, format)
const url = api.contentSrcOf(variant.artID, variant.variation)
if (format == 'image/webp') {
saveAs(url, name)
Expand Down
17 changes: 17 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,7 @@ __metadata:
eslint-plugin-vue: "npm:^9.20.1"
file-saver: "npm:^2.0.5"
lodash: "npm:^4.17.21"
mime-types: "npm:^2.1.35"
npm-run-all: "npm:^4.1.5"
pinia: "npm:^2.1.7"
prettier: "npm:^3.2.4"
Expand Down Expand Up @@ -3740,6 +3741,22 @@ __metadata:
languageName: node
linkType: hard

"mime-db@npm:1.52.0":
version: 1.52.0
resolution: "mime-db@npm:1.52.0"
checksum: 10/54bb60bf39e6f8689f6622784e668a3d7f8bed6b0d886f5c3c446cb3284be28b30bf707ed05d0fe44a036f8469976b2629bbea182684977b084de9da274694d7
languageName: node
linkType: hard

"mime-types@npm:^2.1.35":
version: 2.1.35
resolution: "mime-types@npm:2.1.35"
dependencies:
mime-db: "npm:1.52.0"
checksum: 10/89aa9651b67644035de2784a6e665fc685d79aba61857e02b9c8758da874a754aed4a9aced9265f5ed1171fd934331e5516b84a7f0218031b6fa0270eca1e51a
languageName: node
linkType: hard

"mimic-fn@npm:^2.1.0":
version: 2.1.0
resolution: "mimic-fn@npm:2.1.0"
Expand Down

0 comments on commit d5ddf7a

Please sign in to comment.