mirror of
https://github.com/go-gitea/gitea.git
synced 2026-02-27 17:11:03 +01:00
Lazy-load 3 Vue components that are safe to defer (no pop-in effects). This reduces `index-domready` from 515 KiB to 502 KiB (-2.5%). The old `vue3-calendar-heatmap` vendor chunk (264 KiB) that previously loaded on every page is eliminated entirely — it was mostly duplicate `tippy.js` and `vue` copies that webpack had split out. The actual heatmap library is only ~12 KiB minified, now inlined into the `ActivityHeatmap` async chunk. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import {queryElems} from '../utils/dom.ts';
|
|
import {parseIssueHref} from '../utils.ts';
|
|
import {createApp} from 'vue';
|
|
import {createTippy, getAttachedTippyInstance} from '../modules/tippy.ts';
|
|
|
|
export function initMarkupRefIssue(el: HTMLElement) {
|
|
queryElems(el, '.ref-issue', (el) => {
|
|
el.addEventListener('mouseenter', showMarkupRefIssuePopup);
|
|
el.addEventListener('focus', showMarkupRefIssuePopup);
|
|
});
|
|
}
|
|
|
|
function showMarkupRefIssuePopup(e: MouseEvent | FocusEvent) {
|
|
const refIssue = e.currentTarget as HTMLElement;
|
|
if (getAttachedTippyInstance(refIssue)) return;
|
|
if (refIssue.classList.contains('ref-external-issue')) return;
|
|
|
|
const issuePathInfo = parseIssueHref(refIssue.getAttribute('href')!);
|
|
if (!issuePathInfo.ownerName) return;
|
|
|
|
const el = document.createElement('div');
|
|
const onShowAsync = async () => {
|
|
const {default: ContextPopup} = await import(/* webpackChunkName: "ContextPopup" */ '../components/ContextPopup.vue');
|
|
const view = createApp(ContextPopup, {
|
|
// backend: GetIssueInfo
|
|
loadIssueInfoUrl: `${window.config.appSubUrl}/${issuePathInfo.ownerName}/${issuePathInfo.repoName}/issues/${issuePathInfo.indexString}/info`,
|
|
});
|
|
view.mount(el);
|
|
};
|
|
const tippy = createTippy(refIssue, {
|
|
theme: 'default',
|
|
content: el,
|
|
trigger: 'mouseenter focus',
|
|
placement: 'top-start',
|
|
interactive: true,
|
|
role: 'dialog',
|
|
interactiveBorder: 5,
|
|
// onHide() { return false }, // help to keep the popup and debug the layout
|
|
onShow: () => { onShowAsync() },
|
|
});
|
|
tippy.show();
|
|
}
|