You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hydro/packages/ui-default/pages/setting.page.tsx

30 lines
807 B
TypeScript

import yaml from 'js-yaml';
import Schema from 'schemastery';
import Notification from 'vj/components/notification';
import { NamedPage } from 'vj/misc/Page';
import { request } from 'vj/utils';
const page = new NamedPage('manage_config', async () => {
const schema = new Schema(UiContext.schema);
setInterval(() => {
try {
const v = yaml.load($('#config').val().toString());
schema(v);
$('#info').text('');
} catch (e) {
console.debug(e);
$('#info').text(e.message);
}
}, 1000);
$('#submit').on('click', () => {
const value = $('#config').val();
request.post('', { value }).then(() => {
Notification.success('保存成功');
}).catch((e) => {
Notification.error('保存失败:', e.message);
});
});
});
export default page;