spug/spug_web/src/pages/system/setting/AlarmSetting.js

45 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* Copyright (c) OpenSpug Organization. https://github.com/openspug/spug
* Copyright (c) <spug.dev@gmail.com>
* Released under the MIT License.
*/
import React from 'react';
import { observer } from 'mobx-react';
import { Button, Form, Input, message } from 'antd';
import styles from './index.module.css';
import { http } from 'libs';
import store from './store';
import lds from 'lodash';
export default observer(function () {
function handleSubmit() {
store.loading = true;
const value = lds.get(store.settings, 'spug_key.value');
http.post('/api/setting/', {data: [{key: 'spug_key', value}]})
.then(() => {
message.success('保存成功');
store.fetchSettings()
})
.finally(() => store.loading = false)
}
return (
<React.Fragment>
<div className={styles.title}>报警服务设置</div>
<Form style={{maxWidth: 320}}>
<Form.Item
colon={false}
label="调用凭据"
help={<span>该凭据用于调用spug内置的报警服务请关注公众号<span style={{color: '#008dff'}}>Spug运维</span></span>}>
<Input
value={lds.get(store.settings, 'spug_key.value')}
onChange={e => lds.set(store.settings, 'spug_key.value', e.target.value)}
placeholder="请输入"/>
</Form.Item>
<Button type="primary" loading={store.loading} onClick={handleSubmit}>保存设置</Button>
</Form>
</React.Fragment>
)
})