feat:增加 wot 集成(额外),参考 unibest 3.X 代码
This commit is contained in:
@@ -4,7 +4,7 @@ import { tabBar } from './src/tabbar/config'
|
||||
export default defineUniPages({
|
||||
globalStyle: {
|
||||
navigationStyle: 'default',
|
||||
navigationBarTitleText: 'unibest',
|
||||
navigationBarTitleText: '芋道管理系统',
|
||||
navigationBarBackgroundColor: '#f8f8f8',
|
||||
navigationBarTextStyle: 'black',
|
||||
backgroundColor: '#FFFFFF',
|
||||
@@ -13,9 +13,9 @@ export default defineUniPages({
|
||||
autoscan: true,
|
||||
custom: {
|
||||
'^fg-(.*)': '@/components/fg-$1/fg-$1.vue',
|
||||
'^wd-(.*)': 'wot-design-uni/components/wd-$1/wd-$1.vue',
|
||||
'^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)':
|
||||
'z-paging/components/z-paging$1/z-paging$1.vue',
|
||||
'^wd-(.*)': 'wot-design-uni/components/wd-$1/wd-$1.vue',
|
||||
},
|
||||
},
|
||||
// tabbar 的配置统一在 “./src/tabbar/config.ts” 文件中
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useThemeStore } from '@/store'
|
||||
import FgTabbar from '@/tabbar/index.vue'
|
||||
import { isPageTabbar } from './tabbar/store'
|
||||
import { currRoute } from './utils'
|
||||
|
||||
const themeStore = useThemeStore()
|
||||
|
||||
const isCurrentPageTabbar = ref(true)
|
||||
onShow(() => {
|
||||
console.log('App.ku.vue onShow', currRoute())
|
||||
@@ -28,7 +31,7 @@ defineExpose({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<wd-config-provider :theme-vars="themeStore.themeVars" :theme="themeStore.theme">
|
||||
<!-- 这个先隐藏了,知道这样用就行 -->
|
||||
<view class="hidden text-center">
|
||||
{{ helloKuRoot }},这里可以配置全局的东西
|
||||
@@ -37,5 +40,7 @@ defineExpose({
|
||||
<KuRootView />
|
||||
|
||||
<FgTabbar v-if="isCurrentPageTabbar" />
|
||||
</view>
|
||||
<wd-toast />
|
||||
<wd-message-box />
|
||||
</wd-config-provider>
|
||||
</template>
|
||||
|
||||
42
src/store/theme.ts
Normal file
42
src/store/theme.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import type { ConfigProviderThemeVars } from 'wot-design-uni'
|
||||
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useThemeStore = defineStore(
|
||||
'theme-store',
|
||||
() => {
|
||||
/** 主题 */
|
||||
const theme = ref<'light' | 'dark'>('light')
|
||||
|
||||
/** 主题变量 */
|
||||
const themeVars = ref<ConfigProviderThemeVars>({
|
||||
// colorTheme: 'red',
|
||||
// buttonPrimaryBgColor: '#07c160',
|
||||
// buttonPrimaryColor: '#07c160',
|
||||
})
|
||||
|
||||
/** 设置主题变量 */
|
||||
const setThemeVars = (partialVars: Partial<ConfigProviderThemeVars>) => {
|
||||
themeVars.value = { ...themeVars.value, ...partialVars }
|
||||
}
|
||||
|
||||
/** 切换主题 */
|
||||
const toggleTheme = () => {
|
||||
theme.value = theme.value === 'light' ? 'dark' : 'light'
|
||||
}
|
||||
|
||||
return {
|
||||
/** 设置主题变量 */
|
||||
setThemeVars,
|
||||
/** 切换主题 */
|
||||
toggleTheme,
|
||||
/** 主题变量 */
|
||||
themeVars,
|
||||
/** 主题 */
|
||||
theme,
|
||||
}
|
||||
},
|
||||
{
|
||||
persist: true,
|
||||
},
|
||||
)
|
||||
@@ -108,7 +108,7 @@ function getImageByIndex(index: number, item: CustomTabBarItem) {
|
||||
<!-- 如:<wd-icon name="home" /> (https://wot-design-uni.cn/component/icon.html) -->
|
||||
<!-- 如:<uv-icon name="home" /> (https://www.uvui.cn/components/icon.html) -->
|
||||
<!-- 如:<sar-icon name="image" /> (https://sard.wzt.zone/sard-uniapp-docs/components/icon)(sar没有home图标^_^) -->
|
||||
<!-- <wd-icon :name="item.icon" size="20" /> -->
|
||||
<wd-icon :name="item.icon" size="20" />
|
||||
</template>
|
||||
<template v-if="item.iconType === 'unocss' || item.iconType === 'iconfont'">
|
||||
<view :class="item.icon" class="text-20px" />
|
||||
@@ -146,7 +146,7 @@ function getImageByIndex(index: number, item: CustomTabBarItem) {
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1000;
|
||||
|
||||
|
||||
border-top: 1px solid #eee;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
import Uni from '@uni-helper/plugin-uni'
|
||||
import Components from '@uni-helper/vite-plugin-uni-components'
|
||||
import { WotResolver } from '@uni-helper/vite-plugin-uni-components/resolvers'
|
||||
// @see https://uni-helper.js.org/vite-plugin-uni-layouts
|
||||
import UniLayouts from '@uni-helper/vite-plugin-uni-layouts'
|
||||
// @see https://github.com/uni-helper/vite-plugin-uni-manifest
|
||||
@@ -71,7 +72,12 @@ export default defineConfig(({ command, mode }) => {
|
||||
exclude: ['**/components/**/**.*'],
|
||||
// pages 目录为 src/pages,分包目录不能配置在pages目录下!!
|
||||
// 是个数组,可以配置多个,但是不能为pages里面的目录!!
|
||||
subPackages: [],
|
||||
subPackages: [
|
||||
'src/pages-fg', // 这个是相对必要的路由,尽量留着(登录页、注册页、404页等)
|
||||
'src/pages-system', // “系统管理”模块
|
||||
'src/pages-infra', // “基础设施”模块
|
||||
'src/pages-bpm', // “工作流程”模块
|
||||
],
|
||||
dts: 'src/types/uni-pages.d.ts',
|
||||
}),
|
||||
// Optimization 插件需要 page.json 文件,故应在 UniPages 插件之后执行
|
||||
@@ -146,6 +152,13 @@ export default defineConfig(({ command, mode }) => {
|
||||
},
|
||||
),
|
||||
syncManifestPlugin(),
|
||||
Components({
|
||||
resolvers: [WotResolver()],
|
||||
extensions: ['vue'],
|
||||
deep: true, // 是否递归扫描子目录,
|
||||
directoryAsNamespace: false, // 是否把目录名作为命名空间前缀,true 时组件名为 目录名+组件名,
|
||||
dts: 'src/types/components.d.ts', // 自动生成的组件类型声明文件路径(用于 TypeScript 支持)
|
||||
}),
|
||||
// 自动打开开发者工具插件 (必须修改 .env 文件中的 VITE_WX_APPID)
|
||||
openDevTools(),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user