(by, button)
| 898 | } |
| 899 | |
| 900 | function clickSortButton(by, button) { |
| 901 | if (currentStatus.by === by) { |
| 902 | // 当前选项,点击时,反转排序 |
| 903 | currentStatus.order = button.textContent === '⬆' ? 'desc' : 'asc'; |
| 904 | } else { |
| 905 | // 非当前选项,点击时,以图标所示的顺序排序 |
| 906 | currentStatus.order = button.textContent === '⇧' ? 'asc' : 'desc'; |
| 907 | // 修改非当前选项按钮的图标 |
| 908 | for (const key in allButtons) { |
| 909 | if (key === by) continue; |
| 910 | if (Object.hasOwnProperty.call(allButtons, key)) { |
| 911 | const btnItem = allButtons[key]; |
| 912 | if (btnItem.el.textContent === '⬆') { |
| 913 | btnItem.el.textContent = '⇧'; |
| 914 | } else if (btnItem.el.textContent === '⬇') { |
| 915 | btnItem.el.textContent = '⇩'; |
| 916 | } |
| 917 | } |
| 918 | } |
| 919 | } |
| 920 | button.textContent = currentStatus.order === 'asc' ? '⬆' : '⬇'; |
| 921 | currentStatus.by = by; |
| 922 | sortFileList(); |
| 923 | sortFolderList(); |
| 924 | |
| 925 | } |
| 926 | |
| 927 | // create buttons |
| 928 | setTimeout(() => { |
no test coverage detected