Browse Source

微调错误提示

master
zhangjiming 4 months ago
parent
commit
af67d0cfe4
  1. 2
      src/pages/Setting.tsx
  2. 8
      src/store/features/contextSlice.ts

2
src/pages/Setting.tsx

@ -45,10 +45,12 @@ export default function Setting() {
const onSaveClick = async () => {
const server = addrInput.current!.value;
try {
const res = await dispatch(saveConfig({ server, standbyMinutes: selectStandby[0] })).unwrap();
if (res.success) {
Toast.show('保存成功');
}
} catch (err) {}
};
const back = () => navigate(-1);

8
src/store/features/contextSlice.ts

@ -22,7 +22,7 @@ interface ContextState {
setting: SettingDTO;
settingReqStatus: ReqStatus;
error: string | null;
error?: string;
}
const orgGwdXmStr = localStorage.getItem('org_gwd_xm');
@ -60,7 +60,7 @@ const initialState: ContextState = {
standbyMinutes: 20,
},
settingReqStatus: 'idle',
error: null,
error: undefined,
};
export const fetchConfig = createAsyncThunk('context/fetchConfig', async (_, thunkAPI) => {
@ -128,7 +128,7 @@ export const contextSlice = createSlice({
});
builder.addCase(fetchConfig.rejected, (state, action) => {
state.settingReqStatus = 'failed';
state.error = action.payload as string;
state.error = action.error.message;
});
builder.addCase(saveConfig.pending, (state) => {
state.settingReqStatus = 'loading';
@ -138,7 +138,7 @@ export const contextSlice = createSlice({
});
builder.addCase(saveConfig.rejected, (state, action) => {
state.settingReqStatus = 'failed';
state.error = action.payload as string;
state.error = action.error.message;
});
builder.addCase(refreshSyncProgress.fulfilled, (state, action) => {
if (action.payload) {

Loading…
Cancel
Save