ui: add fill to pretest button (#1109)

This commit is contained in:
undefined authored and GitHub committed 2025-12-26 02:08:11 +08:00
1 parent 0f75f7ce36
commit c1327a55a2
3 files changed
+33

No files matched your search

@@ -57,6 +57,12 @@ code
border-radius: 0px !important
background: none !important
.scratchpad-fill-button
display: none
.mode--scratchpad .scratchpad-fill-button
display: inline-block
.token.tab:not(:empty),
.token.cr,
.token.lf,
@@ -1,4 +1,5 @@
import $ from 'jquery';
import Notification from 'vj/components/notification';
import { AutoloadPage } from 'vj/misc/Page';
import { i18n, tpl } from 'vj/utils';
@@ -33,6 +34,31 @@ const highlighterPage = new AutoloadPage('highlighterPage', () => {
$output.parent().prepend($(tpl`<h2>${i18n('Sample Output')} ${id}</h2>`))
.addClass('medium-6 columns sample').appendTo($c);
}
if ($root.find('.scratchpad-fill-button').length) return;
const $toolbar = $root.find('.toolbar');
const $button = $(tpl`
<div class="toolbar-item scratchpad-fill-button">
<a href="javascript:;">${i18n('Fill to Pretest')}</a>
</div>
`);
$button.on('click', (e) => {
const store = (window as any).store;
if (!store) return;
e.preventDefault();
try {
store.dispatch({
type: 'SCRATCHPAD_PRETEST_DATA_CHANGE',
payload: {
type: 'input',
value: $code.text(),
},
});
Notification.success(i18n('Input filled to pretest!'), 2000);
} catch (err) {
Notification.error(i18n('Failed to fill input'));
}
});
$toolbar.append($button);
}
}
});
+1
View File
@@ -407,6 +407,7 @@ File uploaded successfully.: 上传文件成功
File: 文件
Filename: 文件名
Files: 文件
Fill to Pretest: 填充到自测
Filter: 过滤
First of Contest: 全场一血
First of Problem: 题目一血