mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: add experimental speculation rules
This commit is contained in:
3 files changed
+40
-9
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { formatSeconds } from '@hydrooj/utils/lib/common';
|
||||
import NProgress from 'nprogress';
|
||||
import { NamedPage } from 'vj/misc/Page';
|
||||
import { tpl } from 'vj/utils';
|
||||
import { addSpeculationRules, tpl } from 'vj/utils';
|
||||
|
||||
const contestTimer = $(tpl`<pre class="contest-timer" style="display:none"></pre>`);
|
||||
contestTimer.appendTo(document.body);
|
||||
@@ -21,4 +21,15 @@ export default new NamedPage(['contest_detail', 'contest_problemlist', 'contest_
|
||||
NProgress.start();
|
||||
updateProgress();
|
||||
setInterval(updateProgress, 1000);
|
||||
|
||||
addSpeculationRules({
|
||||
prerender: [{
|
||||
'where': {
|
||||
'or': [
|
||||
{ 'href_matches': '/p/*' },
|
||||
{ 'href_matches': '/d/*/p/*' },
|
||||
],
|
||||
},
|
||||
}],
|
||||
});
|
||||
});
|
||||
@@ -9,7 +9,7 @@ import Notification from 'vj/components/notification';
|
||||
import { downloadProblemSet } from 'vj/components/zipDownloader';
|
||||
import { NamedPage } from 'vj/misc/Page';
|
||||
import {
|
||||
delay, i18n, pjax, request, tpl,
|
||||
addSpeculationRules, delay, i18n, pjax, request, tpl,
|
||||
} from 'vj/utils';
|
||||
|
||||
const list = [];
|
||||
@@ -343,6 +343,17 @@ const page = new NamedPage(['problem_main'], () => {
|
||||
});
|
||||
$(document).on('vjContentNew', (e) => processElement(e.target));
|
||||
processElement(document);
|
||||
|
||||
addSpeculationRules({
|
||||
prerender: [{
|
||||
'where': {
|
||||
'or': [
|
||||
{ 'href_matches': '/p/*' },
|
||||
{ 'href_matches': '/d/*/p/*' },
|
||||
],
|
||||
},
|
||||
}],
|
||||
});
|
||||
});
|
||||
|
||||
export default page;
|
||||
Reference in new issue
Block a user