loadingModel.js 880 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { Toast, Portal } from "@ant-design/react-native";
  2. // 加载页
  3. export default {
  4. state: {
  5. status: "loading",
  6. title: "成功",
  7. show: false,
  8. time: -1,
  9. tKey: "",
  10. },
  11. actions: ({ model, setState }) => ({
  12. loading() {
  13. const { tKey } = model();
  14. if (!tKey) {
  15. const newKey = Toast.loading("Loading...", 0);
  16. setState({
  17. tKey: newKey,
  18. });
  19. }
  20. },
  21. success(title) {
  22. const { clearLoading } = model();
  23. clearLoading();
  24. Toast.success(title, 2);
  25. },
  26. warnning(title) {
  27. const { clearLoading } = model();
  28. clearLoading();
  29. Toast.info(title, 2);
  30. },
  31. clearLoading() {
  32. const { tKey } = model();
  33. if (tKey) {
  34. Portal.remove(tKey);
  35. setState({
  36. tKey: "",
  37. });
  38. }
  39. },
  40. }),
  41. };