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