chore: 整理
All checks were successful
CI / cache-and-install (push) Successful in 1m7s

This commit is contained in:
2024-08-13 23:02:51 +08:00
parent 9ecbb42312
commit fcff296d4e
13 changed files with 127 additions and 362 deletions

View File

@ -2,72 +2,12 @@
import { router } from '@/router';
definePage({
alias: '/'
alias: '/',
});
const testButtons = [
{
text: 'Page1 -> Page2',
onClick: async () => {
console.clear();
console.debug('⚙️ 预期结果:', ['Page1', 'Page2']);
await router.push({ name: 'Page1' });
await router.push({ name: 'Page2' });
}
},
{
text: 'A -> (B) -> C',
onClick: async () => {
console.clear();
console.debug('⚙️ 预期结果: ', ['Page1', 'Page3']);
await router.push({ name: 'Page1' });
await router.push({ name: 'Page2' });
await router.push({ name: 'Page3', replace: true });
}
},
{
text: 'A -> B -> C -> go(-2)',
onClick: async () => {
console.clear();
console.debug('⚙️ 预期结果: ', ['/', '/Page1📍', '/Page2', '/Page3']);
await router.push({ name: 'Page1' });
await router.push({ name: 'Page2' });
await router.push({ name: 'Page3' });
router.go(-2);
}
},
{
text: 'A -> B -> C -> go(-1) -> (D)',
onClick: async () => {
console.clear();
console.debug('⚙️ 预期结果: ', ['/', 'Page1', 'Page4📍', 'Page3']);
await router.push({ name: 'Page1' });
await router.push({ name: 'Page2' });
await router.push({ name: 'Page3' });
router.go(-1);
function popStateListener() {
console.debug('back执行完成, 替换"Page2"为"Page4"');
router.replace({ name: 'Page4' });
window.removeEventListener('popstate', popStateListener);
}
window.addEventListener('popstate', popStateListener);
}
}
];
</script>
<template>
<div class="flex flex-col gap-2 items-start">
<div class="flex gap-2">
<t-button @click="$router.push({ name: 'Page1' })">ToPage1</t-button>
<t-button @click="$router.push({ name: 'Page2' })">ToPage2</t-button>
<t-button @click="$router.push({ name: 'Page3' })">ToPage3</t-button>
</div>
<template v-for="btn in testButtons" :key="btn.text">
<t-button theme="primary" @click="btn.onClick">{{ btn.text }}</t-button>
</template>
<div>
<h1>Index Page</h1>
</div>
</template>