refactor: 整理demo页面+自动引入

This commit is contained in:
Burt 2024-01-22 11:41:45 +08:00
parent e0d0e79975
commit 6aec85e58d
18 changed files with 41 additions and 44 deletions

View File

@ -1,12 +1,25 @@
<template> <template>
<view class="bg-slate-100"> <view class="bg-slate-100">
<view class="bg-slate-100 w-full"> <view class="bg-slate-100 w-full">
<view v-for="item in list" :key="item.url" class="mt-3"> <view class="font-800 mt-4">基本功能</view>
<view v-for="item in baseDemos" :key="item.path" class="mt-3">
<view <view
class="flex bg-white items-center justify-between p-3 mb-2" class="flex bg-white items-center justify-between p-3 mb-2"
@click="goDetailPage(item.url)" @click="goDetailPage(item.path)"
> >
<text class="flex-1 text-4 text-dark">{{ item.name }}</text> <text class="flex-1 text-4 text-dark">{{ item.title }}</text>
<text class="i-carbon-chevron-right"></text>
</view>
</view>
</view>
<view class="bg-slate-100 w-full">
<view class="font-800 mt-4">页面功能</view>
<view v-for="item in pageDemos" :key="item.path" class="mt-3">
<view
class="flex bg-white items-center justify-between p-3 mb-2"
@click="goDetailPage(item.path)"
>
<text class="flex-1 text-4 text-dark">{{ item.title }}</text>
<text class="i-carbon-chevron-right"></text> <text class="i-carbon-chevron-right"></text>
</view> </view>
</view> </view>
@ -15,49 +28,26 @@
</template> </template>
<script setup lang="ts" name="TestIndex"> <script setup lang="ts" name="TestIndex">
import { ref } from 'vue' import pagesJson from '@/pages.json'
console.log(pagesJson)
/** 基本功能 */
const baseDemos = pagesJson.pages
.filter((e) => e.path.startsWith('pages/demo/base'))
.map((e) => ({
title: e.style?.navigationBarTitleText || '默认页面标题',
path: e.path,
}))
/** 页面功能 */
const pageDemos = pagesJson.pages
.filter((e) => e.path.startsWith('pages/demo/page'))
.map((e) => ({
title: e.style?.navigationBarTitleText || '默认页面标题',
path: e.path,
}))
// TODO: pages.json path navigationBarTitleText
const list = ref([
{
name: 'UnoCSS',
url: 'unocss',
},
{
name: 'UnoCSS Icons',
url: 'unocss-icons',
},
{
name: 'UniUI',
url: 'uni-ui',
},
{
name: 'UniUI Icons',
url: 'uni-ui-icons',
},
{
name: 'Pinia+持久化',
url: 'pinia',
},
{
name: '微信分享',
url: 'mp-weixin-share',
},
{
name: '自定义导航栏',
url: 'navbar',
},
{
name: '自定义导航栏渐变',
url: 'throughout',
},
{
name: '请求封装+请求拦截器',
url: 'request',
},
])
const goDetailPage = (path: string) => { const goDetailPage = (path: string) => {
const url = `/pages/demo/demo/${path}` const url = `/${path}`
uni.navigateTo({ uni.navigateTo({
url, url,
}) })

View File

@ -1,3 +1,10 @@
<route lang="json5">
{
layout: 'default',
style: { navigationBarTitleText: '页面悬浮球' },
}
</route>
<template> <template>
<view> <view>
<movable-area class="movable-area"> <movable-area class="movable-area">