소스 검색

Merge pull request #2057 from visuddhinanda/agile

支持弹窗上翻
visuddhinanda 1 년 전
부모
커밋
cd50c902d6

+ 0 - 2
dashboard/src/components/discussion/DiscussionButton.tsx

@@ -27,8 +27,6 @@ const DiscussionButton = ({
   const user = useAppSelector(currentUser);
   const discussions = useAppSelector(discussionList);
 
-  console.debug("discussions", discussions);
-
   const all = discussions?.filter((value) => value.res_id === resId);
   const my = all?.filter((value) => value.editor_uid === user?.id);
   let currCount = initCount;

+ 10 - 1
dashboard/src/components/template/Wbw/WbwDetail.tsx

@@ -28,6 +28,9 @@ import { useAppSelector } from "../../../hooks";
 import { currentUser } from "../../../reducers/current-user";
 import DiscussionButton from "../../discussion/DiscussionButton";
 import { courseUser } from "../../../reducers/course-user";
+import { tempSet } from "../../../reducers/setting";
+import { PopPlacement } from "./WbwPali";
+import store from "../../../store";
 
 interface IWidget {
   data: IWbw;
@@ -151,8 +154,14 @@ const WbwDetailWidget = ({
                   )
                 }
                 onClick={() => {
+                  store.dispatch(
+                    tempSet({
+                      key: PopPlacement,
+                      value: !popIsTop,
+                    })
+                  );
                   if (typeof onPopTopChange !== "undefined") {
-                    onPopTopChange(popIsTop);
+                    //onPopTopChange(popIsTop);
                   }
                 }}
               />

+ 29 - 1
dashboard/src/components/template/Wbw/WbwPali.tsx

@@ -24,6 +24,9 @@ import { ParaLinkCtl } from "../ParaLink";
 import { IStudio } from "../../auth/Studio";
 import WbwPaliDiscussionIcon from "./WbwPaliDiscussionIcon";
 import { TooltipPlacement } from "antd/lib/tooltip";
+import { temp } from "../../../reducers/setting";
+
+export const PopPlacement = "setting.wbw.pop.placement";
 
 //生成视频播放按钮
 interface IVideoIcon {
@@ -73,6 +76,19 @@ const WbwPaliWidget = ({
   const wbwAnchor = useAppSelector(anchor);
   const addParam = useAppSelector(relationAddParam);
   const wordSn = `${data.book}-${data.para}-${data.sn.join("-")}`;
+  const tempSettings = useAppSelector(temp);
+
+  useEffect(() => {
+    const popSetting = tempSettings?.find(
+      (value) => value.key === PopPlacement
+    );
+    console.debug("PopPlacement change", popSetting);
+    if (popSetting?.value === true) {
+      setPopOnTop(true);
+    } else {
+      setPopOnTop(false);
+    }
+  }, [tempSettings]);
 
   useEffect(() => {
     if (wbwAnchor) {
@@ -196,7 +212,18 @@ const WbwPaliWidget = ({
       onAttachmentSelectOpen={(open: boolean) => {
         setPopOpen(!open);
       }}
-      onPopTopChange={(value: boolean) => setPopOnTop(!value)}
+      onPopTopChange={(value: boolean) => {
+        console.debug(PopPlacement, value);
+        //setPopOnTop(!value);
+        /*
+        store.dispatch(
+          tempSet({
+            key: PopPlacement,
+            value: !value,
+          })
+        );
+        */
+      }}
     />
   );
 
@@ -316,6 +343,7 @@ const WbwPaliWidget = ({
     } else {
       popPlacement = toDivRight > 200 ? "bottom" : "bottomRight";
     }
+    //console.debug(PopPlacement, popPlacement);
     return (
       <div className="pali_shell" ref={divShell}>
         <span className="pali_shell_spell">

+ 1 - 1
dashboard/src/components/template/Wbw/WbwPaliDiscussionIcon.tsx

@@ -25,7 +25,7 @@ const WbwPaliDiscussionIcon = ({ data, studio }: IWidget) => {
       }
     }
   }
-  console.debug("WbwPaliDiscussionIcon render", studio, data, onlyMe);
+
   return (
     <DiscussionButton
       initCount={data.hasComment ? 1 : 0}

+ 20 - 1
dashboard/src/reducers/setting.ts

@@ -9,6 +9,7 @@ export interface ISettingItem {
 
 interface IState {
   settings?: ISettingItem[];
+  temp?: ISettingItem[];
   key?: string;
   value?: string | string[] | number | boolean;
 }
@@ -46,16 +47,34 @@ export const slice = createSlice({
       }
       set(state.settings);
     },
+    tempSet: (state, action: PayloadAction<ISettingItem>) => {
+      //将新的改变放入 settings
+      if (typeof state.temp !== "undefined") {
+        const index = state.temp.findIndex(
+          (element) => element.key === action.payload.key
+        );
+        if (index >= 0) {
+          state.temp[index].value = action.payload.value;
+        } else {
+          state.temp.push(action.payload);
+        }
+      } else {
+        state.temp = [action.payload];
+      }
+    },
   },
 });
 
-export const { refresh, onChange } = slice.actions;
+export const { refresh, onChange, tempSet } = slice.actions;
 
 export const setting = (state: RootState): IState => state.setting;
 
 export const settingInfo = (state: RootState): ISettingItem[] | undefined =>
   state.setting.settings;
 
+export const temp = (state: RootState): ISettingItem[] | undefined =>
+  state.setting.temp;
+
 export const onChangeKey = (state: RootState): string | undefined =>
   state.setting.key;
 export const onChangeValue = (