Fix downloading texture
This commit is contained in:
parent
444dee3f14
commit
3022f9f337
|
|
@ -45,13 +45,14 @@
|
|||
>
|
||||
{{ $t('user.setAsAvatar') }}
|
||||
</el-button>
|
||||
<a
|
||||
<el-button
|
||||
v-if="canBeDownloaded"
|
||||
v-t="'skinlib.show.download'"
|
||||
class="el-button el-button--default el-button--medium"
|
||||
:href="`${baseUrl}/raw/${tid}.png`"
|
||||
:download="`${name}`.png"
|
||||
/>
|
||||
size="medium"
|
||||
data-test="download"
|
||||
@click="download"
|
||||
>
|
||||
{{ $t('skinlib.show.download') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="warning"
|
||||
size="medium"
|
||||
|
|
@ -232,6 +233,13 @@ export default {
|
|||
})
|
||||
await this.removeClosetItem()
|
||||
},
|
||||
download() {
|
||||
const a = document.createElement('a')
|
||||
a.href = `${this.baseUrl}/raw/${this.tid}.png`
|
||||
a.download = `${this.name}.png`
|
||||
const event = new MouseEvent('click')
|
||||
a.dispatchEvent(event)
|
||||
},
|
||||
async changeTextureName() {
|
||||
let value
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -130,6 +130,18 @@ test('operation panel should not be rendered if not auth', () => {
|
|||
expect(wrapper.find('.box-warning').exists()).toBeFalse()
|
||||
})
|
||||
|
||||
test('download texture', async () => {
|
||||
Object.assign(window.blessing.extra, { currentUid: 1 })
|
||||
Vue.prototype.$http.get.mockResolvedValue({ tid: 1, name: 'abc' })
|
||||
const wrapper = mount(Show, {
|
||||
mocks: {
|
||||
$route: ['/skinlib/show/1', '1'],
|
||||
},
|
||||
})
|
||||
await wrapper.vm.$nextTick()
|
||||
wrapper.find('[data-test="download"]').trigger('click')
|
||||
})
|
||||
|
||||
test('link to downloading texture', async () => {
|
||||
Object.assign(window.blessing.extra, { download: false })
|
||||
Vue.prototype.$http.get.mockResolvedValue({ hash: '123' })
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user