mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
2.0.0(preview)
This commit is contained in:
1 parent
d5929d78b1
commit
1c8b62a6d9
33 files changed
+307
-241
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { NamedPage } from 'vj/misc/PageLoader';
|
||||
import Notification from 'vj/components/notification';
|
||||
import { ActionDialog } from 'vj/components/dialog';
|
||||
|
||||
import request from 'vj/utils/request';
|
||||
|
||||
const page = new NamedPage('manage_script', () => {
|
||||
const runScriptDialog = new ActionDialog({
|
||||
$body: $('.dialog__body--run-script > div'),
|
||||
onDispatch(action) {
|
||||
const $args = runScriptDialog.$dom.find('[name="args"]');
|
||||
if (action === 'ok' && $args.val() === '') {
|
||||
$args.focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
});
|
||||
runScriptDialog.clear = function () {
|
||||
this.$dom.find('[name="args"]').val('');
|
||||
return this;
|
||||
};
|
||||
|
||||
window.runScript = async function (id) {
|
||||
const action = await runScriptDialog.clear().open();
|
||||
if (action !== 'ok') return;
|
||||
const args = runScriptDialog.$dom.find('[name="args"]').val();
|
||||
try {
|
||||
await request.post('', {
|
||||
args,
|
||||
id,
|
||||
});
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
Notification.error(error.message);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
export default page;
|
||||
Reference in new issue
Block a user