|
@@ -1,7 +1,9 @@
|
|
|
import { message } from "antd";
|
|
import { message } from "antd";
|
|
|
import { useEffect, useState } from "react";
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
+import { modeChange } from "../../reducers/article-mode";
|
|
|
|
|
|
|
|
import { get } from "../../request";
|
|
import { get } from "../../request";
|
|
|
|
|
+import store from "../../store";
|
|
|
import { IArticleDataResponse, IArticleResponse } from "../api/Article";
|
|
import { IArticleDataResponse, IArticleResponse } from "../api/Article";
|
|
|
import ArticleView from "./ArticleView";
|
|
import ArticleView from "./ArticleView";
|
|
|
|
|
|
|
@@ -28,6 +30,7 @@ const Widget = ({
|
|
|
}: IWidgetArticle) => {
|
|
}: IWidgetArticle) => {
|
|
|
const [articleData, setArticleData] = useState<IArticleDataResponse>();
|
|
const [articleData, setArticleData] = useState<IArticleDataResponse>();
|
|
|
const [articleMode, setArticleMode] = useState<ArticleMode>(mode);
|
|
const [articleMode, setArticleMode] = useState<ArticleMode>(mode);
|
|
|
|
|
+
|
|
|
let channels: string[] = [];
|
|
let channels: string[] = [];
|
|
|
if (typeof articleId !== "undefined") {
|
|
if (typeof articleId !== "undefined") {
|
|
|
const aId = articleId.split("_");
|
|
const aId = articleId.split("_");
|
|
@@ -37,15 +40,19 @@ const Widget = ({
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
|
+ console.log("mode", mode, articleMode);
|
|
|
if (!active) {
|
|
if (!active) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (mode !== "read" && articleMode !== "read") {
|
|
|
|
|
- setArticleMode(mode);
|
|
|
|
|
|
|
+ setArticleMode(mode);
|
|
|
|
|
+ //发布mode变更
|
|
|
|
|
+ store.dispatch(modeChange(mode));
|
|
|
|
|
+
|
|
|
|
|
+ if (mode !== articleMode && mode !== "read" && articleMode !== "read") {
|
|
|
console.log("set mode", mode, articleMode);
|
|
console.log("set mode", mode, articleMode);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- setArticleMode(mode);
|
|
|
|
|
|
|
+
|
|
|
if (typeof type !== "undefined" && typeof articleId !== "undefined") {
|
|
if (typeof type !== "undefined" && typeof articleId !== "undefined") {
|
|
|
get<IArticleResponse>(`/v2/${type}/${articleId}/${mode}`).then((json) => {
|
|
get<IArticleResponse>(`/v2/${type}/${articleId}/${mode}`).then((json) => {
|
|
|
if (json.ok) {
|
|
if (json.ok) {
|