|
@@ -2,13 +2,15 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
|
|
|
|
|
|
import type { RootState } from "../store";
|
|
import type { RootState } from "../store";
|
|
|
|
|
|
|
|
-export interface IOpenArticle {
|
|
|
|
|
- type: string;
|
|
|
|
|
- articleId: string;
|
|
|
|
|
|
|
+export interface ISite {
|
|
|
|
|
+ title: string;
|
|
|
|
|
+ url: string;
|
|
|
|
|
+ id: string;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
interface IState {
|
|
interface IState {
|
|
|
- article?: IOpenArticle;
|
|
|
|
|
|
|
+ site?: ISite;
|
|
|
|
|
+ title?: string;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const initialState: IState = {};
|
|
const initialState: IState = {};
|
|
@@ -17,17 +19,23 @@ export const slice = createSlice({
|
|
|
name: "open-article",
|
|
name: "open-article",
|
|
|
initialState,
|
|
initialState,
|
|
|
reducers: {
|
|
reducers: {
|
|
|
- openArticle: (state, action: PayloadAction<IOpenArticle>) => {
|
|
|
|
|
- state.article = action.payload;
|
|
|
|
|
|
|
+ refresh: (state, action: PayloadAction<ISite>) => {
|
|
|
|
|
+ state.site = action.payload;
|
|
|
|
|
+ },
|
|
|
|
|
+ setTitle: (state, action: PayloadAction<string>) => {
|
|
|
|
|
+ state.title = action.payload;
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-export const open = slice.actions;
|
|
|
|
|
|
|
+export const { refresh, setTitle } = slice.actions;
|
|
|
|
|
|
|
|
export const openArticle = (state: RootState): IState => state.openArticle;
|
|
export const openArticle = (state: RootState): IState => state.openArticle;
|
|
|
|
|
|
|
|
-export const articleInfo = (state: RootState): IOpenArticle | undefined =>
|
|
|
|
|
- state.openArticle.article;
|
|
|
|
|
|
|
+export const siteInfo = (state: RootState): ISite | undefined =>
|
|
|
|
|
+ state.openArticle.site;
|
|
|
|
|
+
|
|
|
|
|
+export const pageTitle = (state: RootState): string | undefined =>
|
|
|
|
|
+ state.openArticle.title;
|
|
|
|
|
|
|
|
export default slice.reducer;
|
|
export default slice.reducer;
|