|
1 | 1 | <template> |
2 | | - <van-nav-bar title="mock 指南" left-arrow @click-left="onClickLeft"/> |
| 2 | + <van-nav-bar title="💿 mock 指南" left-arrow @click-left="onClickLeft"/> |
| 3 | + |
3 | 4 | <div class="container"> |
4 | | - <span style="margin-bottom: 10px;">这是请求的数据</span> |
5 | | - <span>{{ projects.dataSource.name }}</span> |
| 5 | + <div class="data-label"> 来自异步请求的数据 </div> |
| 6 | + <div class="data-content"> |
| 7 | + <div v-if="messages">{{ messages }}</div> |
| 8 | + <van-empty v-else description="暂无数据" /> |
| 9 | + </div> |
| 10 | + |
| 11 | + <van-button round block type="primary" @click="pull">请求</van-button> |
| 12 | + <van-button round block type="default" @click="reset">清空</van-button> |
6 | 13 | </div> |
7 | 14 | </template> |
8 | 15 |
|
9 | 16 | <script setup lang="ts"> |
10 | | -import { useFetchData } from '@/utils/hooks/useFetchData' |
11 | | -import { queryProjectNotice } from '@/api' |
| 17 | +import { ref } from 'vue' |
| 18 | +import { queryProse } from '@/api' |
12 | 19 |
|
13 | | -const onClickLeft = () => history.back() |
| 20 | +const messages = ref<string>('') |
14 | 21 |
|
15 | | -const { context: projects } = useFetchData(() => { |
16 | | - return queryProjectNotice().then(res => { |
17 | | - return { |
18 | | - data: res |
19 | | - } |
| 22 | +const pull = () => { |
| 23 | + queryProse().then(res => { |
| 24 | + messages.value = res.prose |
20 | 25 | }) |
21 | | -}) |
| 26 | +} |
| 27 | +
|
| 28 | +// reset data |
| 29 | +const reset = () => messages.value = '' |
| 30 | +
|
| 31 | +// back |
| 32 | +const onClickLeft = () => history.back() |
22 | 33 |
|
23 | 34 | </script> |
24 | 35 |
|
25 | 36 | <style lang="less" scoped> |
26 | 37 | .container { |
27 | 38 | width: 100vw; |
28 | 39 | height: 100vh; |
29 | | - display: flex; |
30 | | - flex-direction: column; |
31 | | - align-items: center; |
32 | | - justify-content: center; |
33 | | - position: relative; |
| 40 | + overflow: hidden; |
| 41 | + padding: 30px; |
| 42 | +
|
| 43 | + .data-label { |
| 44 | + color: #969799; |
| 45 | + font-weight: 400; |
| 46 | + font-size: 14px; |
| 47 | + line-height: 16px; |
| 48 | + } |
| 49 | +
|
| 50 | + .data-content { |
| 51 | + height: 300px; |
| 52 | + padding: 20px; |
| 53 | + line-height: 30px; |
| 54 | + background: #fff; |
| 55 | + margin-top: 20px; |
| 56 | + border-radius: 15px; |
| 57 | + display: flex; |
| 58 | + align-items: center; |
| 59 | + justify-content: center; |
| 60 | + } |
| 61 | +} |
| 62 | +
|
| 63 | +[data-theme='dark'] { |
| 64 | + .data-content { |
| 65 | + background: #222; |
| 66 | + color: #fff; |
| 67 | + } |
| 68 | +} |
| 69 | +
|
| 70 | +.van-button--block { |
| 71 | + margin-top: 15px; |
34 | 72 | } |
35 | 73 | </style> |
0 commit comments