|
1 | 1 | <template>
|
2 | 2 | <PageWrapper title="引导页" content="用于给用户的指引操作">
|
3 |
| - <a-button type="primary" @click="handleStart">开始</a-button> |
| 3 | + <a-button type="primary" @click="handleOpen(true)">开始</a-button> |
| 4 | + <Tour v-model:current="current" :open="open" :steps="steps" @close="handleOpen(false)" /> |
4 | 5 | </PageWrapper>
|
5 | 6 | </template>
|
6 | 7 | <script lang="ts" setup>
|
7 | 8 | import { PageWrapper } from '@/components/Page';
|
8 | 9 | import { useDesign } from '@/hooks/web/useDesign';
|
9 |
| - import { driver } from 'driver.js'; |
10 |
| - import 'driver.js/dist/driver.css'; |
| 10 | + import { ref } from 'vue'; |
| 11 | + import { Tour, TourProps } from 'ant-design-vue'; |
11 | 12 |
|
| 13 | + const open = ref<boolean>(false); |
12 | 14 | const { prefixVar } = useDesign('');
|
13 | 15 |
|
14 |
| - function handleStart() { |
15 |
| - driver({ |
16 |
| - showProgress: true, |
17 |
| - steps: [ |
18 |
| - { |
19 |
| - popover: { |
20 |
| - title: 'Welcome', |
21 |
| - description: 'Hello World! 👋', |
22 |
| - }, |
23 |
| - }, |
24 |
| - { |
25 |
| - element: `.${prefixVar}-layout-header-trigger`, |
26 |
| - popover: { |
27 |
| - title: 'Collapse Button', |
28 |
| - description: 'This is the menu collapse button.', |
29 |
| - }, |
30 |
| - }, |
31 |
| - { |
32 |
| - element: `.${prefixVar}-layout-header-action`, |
33 |
| - popover: { |
34 |
| - title: 'User Action', |
35 |
| - description: 'This is the user function area.', |
36 |
| - }, |
37 |
| - }, |
38 |
| - ], |
39 |
| - }).drive(); |
40 |
| - } |
| 16 | + const current = ref(0); |
| 17 | + const steps: TourProps['steps'] = [ |
| 18 | + { |
| 19 | + title: 'Welcome', |
| 20 | + description: 'Hello World! 👋', |
| 21 | + }, |
| 22 | + { |
| 23 | + title: 'Collapse Button', |
| 24 | + description: 'This is the menu collapse button.', |
| 25 | + target: () => document.querySelector(`.${prefixVar}-layout-header-trigger`) as HTMLElement, |
| 26 | + }, |
| 27 | + { |
| 28 | + title: 'User Action', |
| 29 | + description: 'This is the user function area.', |
| 30 | + target: () => document.querySelector(`.${prefixVar}-layout-header-action`) as HTMLElement, |
| 31 | + }, |
| 32 | + ]; |
| 33 | +
|
| 34 | + const handleOpen = (val: boolean): void => { |
| 35 | + current.value = 0; |
| 36 | + open.value = val; |
| 37 | + }; |
41 | 38 | </script>
|
0 commit comments