mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
修复关闭通知
This commit is contained in:
parent
0a9e9e972d
commit
6c87634bb3
|
@ -204,8 +204,8 @@ export default (app: Router) => {
|
|||
const logger: Logger = Container.get('logger');
|
||||
try {
|
||||
const authService = Container.get(AuthService);
|
||||
const data = await authService.updateNotificationMode(req.body);
|
||||
res.send({ code: 200, data });
|
||||
const result = await authService.updateNotificationMode(req.body);
|
||||
res.send(result);
|
||||
} catch (e) {
|
||||
logger.error('🔥 error: %o', e);
|
||||
return next(e);
|
||||
|
|
|
@ -272,7 +272,7 @@ export default class AuthService {
|
|||
return new Promise((resolve) => {
|
||||
this.authDb.update(
|
||||
{ type: AuthDataType.notification },
|
||||
payload,
|
||||
{ ...payload },
|
||||
{ upsert: true, returnUpdatedDocs: true },
|
||||
(err, num, doc: any) => {
|
||||
if (err) {
|
||||
|
|
|
@ -60,6 +60,7 @@ export default class NotificationService {
|
|||
const notificationModeAction = this.modeMap.get(type);
|
||||
return await notificationModeAction?.call(this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private async goCqHttpBot() {
|
||||
|
|
|
@ -7,22 +7,25 @@ const { Option } = Select;
|
|||
|
||||
const NotificationSetting = ({ data }: any) => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [notificationMode, setNotificationMode] = useState<string>('');
|
||||
const [notificationMode, setNotificationMode] = useState<string>('closed');
|
||||
const [fields, setFields] = useState<any[]>([]);
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const handleOk = (values: any) => {
|
||||
if (values.type == 'closed') {
|
||||
values.type = '';
|
||||
}
|
||||
request
|
||||
.put(`${config.apiPrefix}user/notification`, {
|
||||
data: {
|
||||
...values,
|
||||
},
|
||||
})
|
||||
.then((data: any) => {
|
||||
if (data && data.code === 200) {
|
||||
message.success('通知发送成功');
|
||||
.then((_data: any) => {
|
||||
if (_data && _data.code === 200) {
|
||||
message.success(values.type ? '通知发送成功' : '通知关闭成功');
|
||||
} else {
|
||||
message.error(data.data);
|
||||
message.error(_data.data);
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
|
@ -33,7 +36,7 @@ const NotificationSetting = ({ data }: any) => {
|
|||
const notificationModeChange = (value: string) => {
|
||||
setNotificationMode(value);
|
||||
const _fields = (config.notificationModeMap as any)[value];
|
||||
setFields(_fields);
|
||||
setFields(_fields || []);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -70,11 +73,9 @@ const NotificationSetting = ({ data }: any) => {
|
|||
<Input.TextArea autoSize={true} placeholder={`请输入${x.label}`} />
|
||||
</Form.Item>
|
||||
))}
|
||||
{notificationMode !== '' && (
|
||||
<Button type="primary" htmlType="submit">
|
||||
保存
|
||||
</Button>
|
||||
)}
|
||||
<Button type="primary" htmlType="submit">
|
||||
保存
|
||||
</Button>
|
||||
</Form>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -74,7 +74,7 @@ export default {
|
|||
{ value: 'iGot', label: 'IGot' },
|
||||
{ value: 'pushPlus', label: 'PushPlus' },
|
||||
{ value: 'email', label: '邮箱' },
|
||||
{ value: '', label: '已关闭' },
|
||||
{ value: 'closed', label: '已关闭' },
|
||||
],
|
||||
notificationModeMap: {
|
||||
goCqHttpBot: [
|
||||
|
|
Loading…
Reference in New Issue
Block a user