mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-16 01:26:16 -08:00
菜单添加排序
This commit is contained in:
1 parent
0e85c86c5c
commit
711cf5684a
9 files changed
+34
-10
No files matched your search
@@ -5,6 +5,7 @@ export default function aspectRatio(art) {
|
||||
return {
|
||||
disable: !option.aspectRatio,
|
||||
name: 'aspectRatio',
|
||||
index: 20,
|
||||
html: `
|
||||
${i18n.get('Aspect ratio')}:
|
||||
<span data-ratio="default" class="default current">${i18n.get('Default')}</span>
|
||||
|
||||
@@ -2,6 +2,7 @@ export default function close(art) {
|
||||
return {
|
||||
disable: false,
|
||||
name: 'close',
|
||||
index: 50,
|
||||
html: art.i18n.get('Close'),
|
||||
click: () => {
|
||||
art.contextmenu.hide();
|
||||
|
||||
@@ -46,11 +46,11 @@ export default class Contextmenu {
|
||||
refs.$contextmenu.classList.add('artplayer-contextmenu');
|
||||
option.contextmenu
|
||||
.filter(item => !item.disable)
|
||||
.forEach(item => {
|
||||
.map(item => {
|
||||
id++;
|
||||
const menu = typeof item === 'function' ? item(this.art) : item;
|
||||
const $menu = document.createElement('div');
|
||||
$menu.setAttribute('data-art-menu-id', id);
|
||||
$menu.dataset.artMenuId = menu.index || id;
|
||||
$menu.setAttribute('class', `art-menu art-menu-${menu.name || id}`);
|
||||
append($menu, menu.html);
|
||||
setStyles($menu, menu.style || {});
|
||||
@@ -61,7 +61,14 @@ export default class Contextmenu {
|
||||
this.art.emit('contextmenu:click', $menu);
|
||||
});
|
||||
}
|
||||
this[`$${menu.name || id}`] = append(refs.$contextmenu, $menu);
|
||||
this[`$${menu.name || id}`] = $menu;
|
||||
return $menu;
|
||||
})
|
||||
.sort(
|
||||
(a, b) =>
|
||||
Number(a.dataset.artMenuId) - Number(b.dataset.artMenuId)
|
||||
).forEach($menu => {
|
||||
append(refs.$contextmenu, $menu);
|
||||
});
|
||||
append(refs.$player, refs.$contextmenu);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
export default function info(art) {
|
||||
return {
|
||||
disable: false,
|
||||
name: 'info',
|
||||
index: 30,
|
||||
html: art.i18n.get('Video info'),
|
||||
click: () => {
|
||||
art.info.show();
|
||||
|
||||
@@ -5,6 +5,7 @@ export default function playbackRate(art) {
|
||||
return {
|
||||
disable: !option.playbackRate,
|
||||
name: 'playbackRate',
|
||||
index: 10,
|
||||
html: `
|
||||
${i18n.get('Play speed')}:
|
||||
<span data-rate="0.5">0.5</span>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export default {
|
||||
disable: false,
|
||||
name: 'version',
|
||||
index: 40,
|
||||
html: '<a href="https://github.com/zhw2590582/artplayer" target="_blank">ArtPlayer __VERSION__</a>'
|
||||
};
|
||||
Reference in new issue
Block a user