Optimize loading speed (#45)
This commit is contained in:
1 parent
a18db299ee
commit
a0bcce5cf1
9 files changed
+92
-33
No files matched your search
-19
@@ -9,9 +9,6 @@ import 'mac-scrollbar/dist/mac-scrollbar.css';
|
||||
import dayjs from './plugins/dayjs';
|
||||
import './plugins/font-awesome';
|
||||
import { vLoading } from 'element-plus';
|
||||
import hl from 'highlight.js';
|
||||
import 'highlight.js/styles/night-owl.css';
|
||||
import copyToClipboard from 'copy-to-clipboard';
|
||||
import { initializeCookies, initializeFavicon, initializeTitle } from './utils/initializer';
|
||||
import config from './plugins/config';
|
||||
|
||||
@@ -33,22 +30,6 @@ const main = async () => {
|
||||
app.mount('#app');
|
||||
console.debug('app mounted');
|
||||
|
||||
app.directive('highlight', async (el) => {
|
||||
const blocks = el.querySelectorAll('pre code');
|
||||
blocks.forEach((block: HTMLPreElement) => {
|
||||
// create the copy button
|
||||
const copy = document.createElement('button');
|
||||
copy.innerHTML = i18n.global.t('common.button.copy').toString();
|
||||
// add the event listener to each click
|
||||
copy.addEventListener('click', () => {
|
||||
copyToClipboard(block.innerText);
|
||||
});
|
||||
// append the copy button to each code block
|
||||
block.parentElement?.prepend(copy);
|
||||
hl.highlightBlock(block);
|
||||
});
|
||||
});
|
||||
|
||||
// make app available globally
|
||||
// @ts-ignore
|
||||
window.app = app;
|
||||
|
||||
Reference in new issue
Block a user