confirm.ts 584 B

12345678910111213141516171819202122232425262728
  1. import { defineStore } from "pinia";
  2. export const useConfirmStore = props => {
  3. const { modalUuid } = props;
  4. if (!modalUuid) return null;
  5. return defineStore(`confirm-${modalUuid}`, {
  6. state: () => ({
  7. message: "",
  8. onCompleted: null,
  9. action: null,
  10. params: null
  11. }),
  12. actions: {
  13. init({ message, onCompleted, action, params }) {
  14. this.message = message;
  15. this.onCompleted = onCompleted;
  16. this.action = action;
  17. this.params = params;
  18. },
  19. confirm() {
  20. this.onCompleted({
  21. action: this.action,
  22. params: this.params
  23. });
  24. }
  25. }
  26. })();
  27. };