feat: Add "Open in Browser" context menu item to artist and album page (#1096)

This commit is contained in:
Changjian Gao 2021-12-20 18:57:45 +08:00 committed by qier222
parent e9f45c5352
commit 773f7bee9e
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
5 changed files with 19 additions and 2 deletions

View file

@ -179,6 +179,7 @@ export default {
addToPlaylist: 'Add to playlist', addToPlaylist: 'Add to playlist',
searchInPlaylist: 'Search in playlist', searchInPlaylist: 'Search in playlist',
copyUrl: 'Copy URL', copyUrl: 'Copy URL',
openInBrowser: 'Open in Browser',
allPlaylists: 'All Playlists', allPlaylists: 'All Playlists',
minePlaylists: 'My Playlists', minePlaylists: 'My Playlists',
likedPlaylists: 'Liked Playlists', likedPlaylists: 'Liked Playlists',

View file

@ -180,6 +180,7 @@ export default {
addToPlaylist: '添加到歌单', addToPlaylist: '添加到歌单',
searchInPlaylist: '歌单内搜索', searchInPlaylist: '歌单内搜索',
copyUrl: '复制链接', copyUrl: '复制链接',
openInBrowser: '在浏览器中打开',
allPlaylists: '全部歌单', allPlaylists: '全部歌单',
minePlaylists: '创建的歌单', minePlaylists: '创建的歌单',
likedPlaylists: '收藏的歌单', likedPlaylists: '收藏的歌单',

View file

@ -176,6 +176,7 @@ export default {
removeFromLibrary: '從音樂庫刪除', removeFromLibrary: '從音樂庫刪除',
addToPlaylist: '新增至歌單', addToPlaylist: '新增至歌單',
searchInPlaylist: '歌單內搜尋', searchInPlaylist: '歌單內搜尋',
openInBrowser: '在瀏覽器中打開',
copyUrl: '複製連結', copyUrl: '複製連結',
allPlaylists: '全部歌單', allPlaylists: '全部歌單',
minePlaylists: '我建立的歌單', minePlaylists: '我建立的歌單',

View file

@ -137,6 +137,9 @@
<div class="item" @click="copyUrl(album.id)">{{ <div class="item" @click="copyUrl(album.id)">{{
$t('contextMenu.copyUrl') $t('contextMenu.copyUrl')
}}</div> }}</div>
<div class="item" @click="openInBrowser(album.id)">{{
$t('contextMenu.openInBrowser')
}}</div>
</ContextMenu> </ContextMenu>
</div> </div>
</template> </template>
@ -305,7 +308,7 @@ export default {
}, },
copyUrl(id) { copyUrl(id) {
let showToast = this.showToast; let showToast = this.showToast;
this.$copyText('https://music.163.com/#/album?id=' + id) this.$copyText(`https://music.163.com/#/album?id=${id}`)
.then(function () { .then(function () {
showToast(locale.t('toast.copied')); showToast(locale.t('toast.copied'));
}) })
@ -313,6 +316,10 @@ export default {
showToast(`${locale.t('toast.copyFailed')}${error}`); showToast(`${locale.t('toast.copyFailed')}${error}`);
}); });
}, },
openInBrowser(id) {
const url = `https://music.163.com/#/album?id=${id}`;
window.open(url);
},
}, },
}; };
</script> </script>

View file

@ -169,6 +169,9 @@
<div class="item" @click="copyUrl(artist.id)">{{ <div class="item" @click="copyUrl(artist.id)">{{
$t('contextMenu.copyUrl') $t('contextMenu.copyUrl')
}}</div> }}</div>
<div class="item" @click="openInBrowser(artist.id)">{{
$t('contextMenu.openInBrowser')
}}</div>
</ContextMenu> </ContextMenu>
</div> </div>
</template> </template>
@ -339,7 +342,7 @@ export default {
}, },
copyUrl(id) { copyUrl(id) {
let showToast = this.showToast; let showToast = this.showToast;
this.$copyText('https://music.163.com/#/artist?id=' + id) this.$copyText(`https://music.163.com/#/artist?id=${id}`)
.then(function () { .then(function () {
showToast(locale.t('toast.copied')); showToast(locale.t('toast.copied'));
}) })
@ -347,6 +350,10 @@ export default {
showToast(`${locale.t('toast.copyFailed')}${error}`); showToast(`${locale.t('toast.copyFailed')}${error}`);
}); });
}, },
openInBrowser(id) {
const url = `https://music.163.com/#/artist?id=${id}`;
window.open(url);
},
}, },
}; };
</script> </script>