mirror of
https://github.com/go-gitea/gitea
synced 2024-12-27 03:56:02 +01:00
507fbf4c3c
As per https://github.com/go-gitea/gitea/pull/30115#discussion_r1626060164, prefer `querySelector` by enabling [`unicorn/prefer-query-selector`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-query-selector.md) and autofixing all except 10 issues. According to [this](https://old.reddit.com/r/learnjavascript/comments/i0f5o8/performance_of_getelementbyid_vs_queryselector/), querySelector may be faster as well, so it's a win-win. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
22 lines
791 B
JavaScript
22 lines
791 B
JavaScript
import {createApp} from 'vue';
|
|
|
|
export async function initRepoCodeFrequency() {
|
|
const el = document.querySelector('#repo-code-frequency-chart');
|
|
if (!el) return;
|
|
|
|
const {default: RepoCodeFrequency} = await import(/* webpackChunkName: "code-frequency-graph" */'../components/RepoCodeFrequency.vue');
|
|
try {
|
|
const View = createApp(RepoCodeFrequency, {
|
|
locale: {
|
|
loadingTitle: el.getAttribute('data-locale-loading-title'),
|
|
loadingTitleFailed: el.getAttribute('data-locale-loading-title-failed'),
|
|
loadingInfo: el.getAttribute('data-locale-loading-info'),
|
|
},
|
|
});
|
|
View.mount(el);
|
|
} catch (err) {
|
|
console.error('RepoCodeFrequency failed to load', err);
|
|
el.textContent = el.getAttribute('data-locale-component-failed-to-load');
|
|
}
|
|
}
|