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.
30 lines
811 B
TypeScript
30 lines
811 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/request';
|
|
|
|
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;
|