Skip to content

Commit aeabe43

Browse files
committed
🐛 fix(表现): go
回退错误
1 parent 448513f commit aeabe43

8 files changed

+2435
-2016
lines changed

dist/vue-page-stack.cjs.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-page-stack.es.js

+40-40
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineComponent as R, getCurrentInstance as U, queuePostFlushCb as S, onMounted as D, onUpdated as H, onBeforeUnmount as w, isVNode as K, cloneVNode as y, callWithAsyncErrorHandling as v, ErrorCodes as x, setTransitionHooks as j } from "vue";
1+
import { defineComponent as R, getCurrentInstance as U, queuePostFlushCb as g, onMounted as w, onUpdated as D, onBeforeUnmount as H, isVNode as K, cloneVNode as y, callWithAsyncErrorHandling as v, ErrorCodes as x, setTransitionHooks as j } from "vue";
22
const i = {
33
componentName: "VuePageStack",
44
pushName: "push",
@@ -55,7 +55,7 @@ const L = (e) => e.__isSuspense, V = {
5555
function m(e) {
5656
e.shapeFlag &= ~f.COMPONENT_SHOULD_KEEP_ALIVE, e.shapeFlag &= ~f.COMPONENT_KEPT_ALIVE;
5757
}
58-
function d(e) {
58+
function h(e) {
5959
return e.shapeFlag & f.SUSPENSE ? e.ssContent : e;
6060
}
6161
const o = [], q = R({
@@ -65,65 +65,65 @@ const o = [], q = R({
6565
setup(e, { slots: s, emit: r }) {
6666
const l = U(), E = l.ctx, u = l.suspense, {
6767
renderer: {
68-
p,
69-
m: h,
68+
p: N,
69+
m: T,
7070
um: A,
7171
o: { createElement: M }
7272
}
7373
} = E, I = M("div");
74-
E.activate = (n, t, a, O, T) => {
75-
const N = n.component;
76-
h(n, t, a, V.ENTER, u), p(N.vnode, n, t, a, N, u, O, n.slotScopeIds, T), S(() => {
77-
N.isDeactivated = !1, N.a && k(N.a);
78-
const P = n.props && n.props.onVnodeMounted;
79-
P && b(P, N.parent, n);
74+
E.activate = (n, a, t, O, d) => {
75+
const p = n.component;
76+
T(n, a, t, V.ENTER, u), N(p.vnode, n, a, t, p, u, O, n.slotScopeIds, d), g(() => {
77+
p.isDeactivated = !1, p.a && k(p.a);
78+
const S = n.props && n.props.onVnodeMounted;
79+
S && b(S, p.parent, n);
8080
}, u);
8181
}, E.deactivate = (n) => {
82-
const t = n.component;
83-
h(n, I, null, V.LEAVE, u), S(() => {
84-
t.da && k(t.da);
85-
const a = n.props && n.props.onVnodeUnmounted;
86-
a && b(a, t.parent, n), t.isDeactivated = !0;
82+
const a = n.component;
83+
T(n, I, null, V.LEAVE, u), g(() => {
84+
a.da && k(a.da);
85+
const t = n.props && n.props.onVnodeUnmounted;
86+
t && b(t, a.parent, n), a.isDeactivated = !0;
8787
}, u);
8888
};
8989
function F(n) {
9090
m(n), A(n, l, u, !0);
9191
}
9292
let _ = !1, C = !1;
93-
const g = () => {
94-
_ && (C ? o[o.length - 1] = d(l.subTree) : c.action != i.replaceName ? o.push(d(l.subTree)) : o[o.length - 1] = d(l.subTree));
93+
const P = () => {
94+
_ && (C ? o[o.length - 1] = h(l.subTree) : c.action != i.replaceName ? o.push(h(l.subTree)) : o[o.length - 1] = h(l.subTree));
9595
};
96-
return D(g), H(g), w(() => {
96+
return w(P), D(P), H(() => {
9797
for (const n of o)
9898
F(n);
9999
}), () => {
100100
if (_ = !1, C = !1, !s.default)
101101
return null;
102-
const n = s.default(), t = n[0];
102+
const n = s.default(), a = n[0];
103103
if (n.length > 1)
104104
return n;
105-
if (!K(t) || !(t.shapeFlag & f.STATEFUL_COMPONENT) && !(t.shapeFlag & f.SUSPENSE))
106-
return t;
107-
let a = d(t);
108-
if (a.el && (a = y(a), t.shapeFlag & f.SUSPENSE && (t.ssContent = a)), _ = !0, c.action === i.backName) {
105+
if (!K(a) || !(a.shapeFlag & f.STATEFUL_COMPONENT) && !(a.shapeFlag & f.SUSPENSE))
106+
return a;
107+
let t = h(a);
108+
if (t.el && (t = y(t), a.shapeFlag & f.SUSPENSE && (a.ssContent = t)), _ = !0, c.action === i.backName) {
109109
r("back");
110-
const O = -c.n, T = o[o.length - O - 1];
111-
if (!T || T.key != t.key)
112-
return m(o[o.length - O]), o[o.length - O] = null, o.splice(o.length - O), a.shapeFlag |= f.COMPONENT_SHOULD_KEEP_ALIVE, L(t.type) ? t : a;
113-
a.el = T.el, a.component = T.component, a.transition && j(a, a.transition), a.shapeFlag |= f.COMPONENT_KEPT_ALIVE;
114-
for (let N = o.length - O; N < o.length; N++)
115-
m(o[N]), o[N] = null;
110+
const O = -c.n, d = o[o.length - O - 1];
111+
if (!d || d.key != a.key)
112+
return m(o[o.length - O]), o[o.length - O] = null, o.splice(o.length - O), t.shapeFlag |= f.COMPONENT_SHOULD_KEEP_ALIVE, L(a.type) ? a : t;
113+
t.el = d.el, t.component = d.component, t.transition && j(t, t.transition), t.shapeFlag |= f.COMPONENT_KEPT_ALIVE;
114+
for (let p = o.length - O; p < o.length; p++)
115+
m(o[p]), o[p] = null;
116116
o.splice(o.length - O), C = !0;
117117
} else
118118
r("forward");
119-
return a.shapeFlag |= f.COMPONENT_SHOULD_KEEP_ALIVE, L(t.type) ? t : a;
119+
return t.shapeFlag |= f.COMPONENT_SHOULD_KEEP_ALIVE, L(a.type) ? a : t;
120120
};
121121
}
122122
}), z = (e) => {
123123
const s = e.push.bind(e), r = e.go.bind(e), l = e.replace.bind(e), E = e.back.bind(e), u = e.forward.bind(e);
124-
e.push = (p) => (c.action = i.pushName, s(p)), e.go = (p) => {
125-
c.action = i.goName, p < 0 && (c.action = i.backName, c.n = p), r(p);
126-
}, e.replace = (p) => (c.action = i.replaceName, l(p)), e.back = () => {
124+
e.push = (N) => (c.action = i.pushName, s(N)), e.go = (N) => {
125+
N > 0 && (c.action = i.forwardName), N < 0 && (c.action = i.backName), c.n = N, r(N);
126+
}, e.replace = (N) => (c.action = i.replaceName, l(N)), e.back = () => {
127127
c.action = i.backName, c.n = -1, E();
128128
}, e.forward = () => {
129129
c.action = i.forwardName, u();
@@ -137,16 +137,16 @@ const o = [], q = R({
137137
if (!s)
138138
throw Error("router is required");
139139
let E = null;
140-
s.options.history.listen((u, p, h) => {
141-
E = h;
140+
s.options.history.listen((u, N, T) => {
141+
E = T;
142142
}), s.beforeEach(() => {
143-
E && (E.direction === "back" && r ? r() : E.direction === "forward" && l && l(), E = null);
143+
E && (E.direction === "back" && r ? r(E.delta) : E.direction === "forward" && l && l(E.delta), E = null);
144144
});
145145
}
146-
}, X = () => {
147-
c.n = -1, c.action = i.backName;
148-
}, Y = () => {
149-
c.action = i.forwardName;
146+
}, X = (e) => {
147+
c.n = e, c.action = i.backName;
148+
}, Y = (e) => {
149+
c.n = e, c.action = i.forwardName;
150150
}, W = {
151151
install(e, { router: s }) {
152152
if (!s)

0 commit comments

Comments
 (0)