修改了reducer,action,container。出现错误,无法加载css,json parse error

This commit is contained in:
dongzhimin 2025-04-19 11:10:49 +08:00
parent 6f83b7cb91
commit 056db885d1
4 changed files with 33 additions and 12 deletions

View File

@ -81,6 +81,8 @@ export const COMPOSE_CHANGE_MEDIA_ORDER = 'COMPOSE_CHANGE_MEDIA_ORDER';
export const COMPOSE_SET_STATUS = 'COMPOSE_SET_STATUS';
export const COMPOSE_FOCUS = 'COMPOSE_FOCUS';
export const COMPOSE_CHANGE_IS_SCHEDULED = 'COMPOSE_CHANGE_IS_SCHEDULED';
const messages = defineMessages({
uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' },
uploadErrorPoll: { id: 'upload_error.poll', defaultMessage: 'File upload not allowed with polls.' },
@ -835,3 +837,9 @@ export const changeMediaOrder = (a, b) => ({
a,
b,
});
export function changeIsScheduled() {
return {
type: COMPOSE_IS_SCHEDULED_CHANGE,
};
}

View File

@ -71,6 +71,11 @@ class ComposeForm extends ImmutablePureComponent {
singleColumn: PropTypes.bool,
lang: PropTypes.string,
maxChars: PropTypes.number,
schedule_time: PropTypes.string,
schedule_timezone: PropTypes.string,
is_scheduled: PropTypes.bool.isRequired,
scheduled_at: PropTypes.string,
};
static defaultProps = {
@ -312,6 +317,7 @@ class ComposeForm extends ImmutablePureComponent {
<div>
<label>计划时间UTC</label>
<input
className='search__input'
type='datetime-local'
/>
</div>

View File

@ -1,31 +1,26 @@
import { injectIntl,defineMessages } from "react-intl";
import { injectIntl, defineMessages } from "react-intl";
import { connect } from "react-redux";
import ScheduleIcon from '@/material-icons/400-20px/schedule.svg?react';
import { IconButton } from "@/mastodon/components/icon_button";
import { changeIsScheduled } from '../../actions/compose';
const mapStateToProps = () => ({
const mapStateToProps = (state) => ({
iconComponent: ScheduleIcon,
title: defineMessages({
title: {
id: 'compose.schedule_button.title',
defaultMessage: 'Schedule',
},
}),
active: false,
ariaControls: 'schedule-compose-form',
title: 'schedule',
active: state.getIn(['compose', 'is_scheduled']),
size: 18,
inverted: true,
});
const mapDispatchToProps = dispatch => ({
onClick () {
dispatch({ type: 'SCHEDULE_COMPOSE' });
dispatch(changeIsScheduled());
},
});

View File

@ -50,6 +50,7 @@ import {
COMPOSE_CHANGE_MEDIA_ORDER,
COMPOSE_SET_STATUS,
COMPOSE_FOCUS,
COMPOSE_CHANGE_IS_SCHEDULED,
} from '../actions/compose';
import { REDRAFT } from '../actions/statuses';
import { STORE_HYDRATE } from '../actions/store';
@ -94,6 +95,11 @@ const initialState = ImmutableMap({
focusY: 0,
dirty: false,
}),
schedule_time: new Date().toLocaleString('zh-CN').split('/').join('-').split(' ').join('T')+'.0',
schedule_timezone: new Date().getTimezoneOffset() > 0?'-':'+' + (0 - new Date().getTimezoneOffset() / 60) + ':' + ((0 - new Date().getTimezoneOffset() % 60) === 30 ? '30' :'00'),
is_scheduled: false,
scheduled_at: null,
});
const initialPoll = ImmutableMap({
@ -560,6 +566,12 @@ export default function compose(state = initialState, action) {
return list.splice(indexA, 1).splice(indexB, 0, moveItem);
});
case COMPOSE_CHANGE_IS_SCHEDULED:
return state.withMutations(map => {
map.set('is_scheduled', !state.get('is_scheduled'));
map.set('scheduled_at', state.get('schedule_time') + state.get('schedule_timezone'));
map.set('idempotencyKey', uuid());
});
default:
return state;
}