Files
mini-programs/src/store/evaluateStore.ts

54 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { create } from "zustand";
export enum EvaluateScene {
list,
publish,
detail,
user,
userEdit,
share,
}
export interface EvaluateCallback {
type: EvaluateScene | "";
// flag是用来区分跳转ntrp测试后的操作和直接修改ntrp水平成功后的操作
// score是用在加入球局前判断是否满足球局要求的返回值限定为必传
// next有两个地方调用ntrp结果页handleGoon、ntrp弹窗NTRPEvaluatePopup直接修改点击保存按钮时
next: ({ flag, score }: { flag?: boolean; score: string }) => void;
onCancel: () => void;
}
export interface EvaluateCallbackType extends EvaluateCallback {
setCallback: (options: {
type: EvaluateScene | "";
next: ({ flag, score }: { flag?: boolean; score: string }) => void;
onCancel: () => void;
}) => void;
clear: () => void;
}
export const useEvaluateCallback = create<EvaluateCallbackType>()((set) => ({
type: "",
next: () => { },
onCancel: () => { },
setCallback: ({ type, next, onCancel }) => {
set({
type,
next,
onCancel,
});
},
clear: () => {
set({ type: "", next: () => { }, onCancel: () => { } });
},
}));
export const useEvaluate = () =>
useEvaluateCallback(({ type, next, onCancel, setCallback, clear }) => ({
type,
next,
onCancel,
setCallback,
clear,
}));