潘志宝
6 天以前 ca22cdd5550cfa0defb0f430c538698182cdaec1
提交 | 用户 | 时间
820397 1 <template>
H 2   <div class="tab-bar">
3     <!-- 表单 -->
4     <el-form :model="formData" label-width="80px">
5       <el-form-item label="主题" prop="theme">
6         <el-select v-model="formData!.theme" @change="handleThemeChange">
7           <el-option
8             v-for="(theme, index) in THEME_LIST"
9             :key="index"
10             :label="theme.name"
11             :value="theme.id"
12           >
13             <template #default>
14               <div class="flex items-center justify-between">
15                 <Icon :icon="theme.icon" :color="theme.color" />
16                 <span>{{ theme.name }}</span>
17               </div>
18             </template>
19           </el-option>
20         </el-select>
21       </el-form-item>
22       <el-form-item label="默认颜色">
23         <ColorInput v-model="formData!.style.color" />
24       </el-form-item>
25       <el-form-item label="选中颜色">
26         <ColorInput v-model="formData!.style.activeColor" />
27       </el-form-item>
28       <el-form-item label="导航背景">
29         <el-radio-group v-model="formData!.style.bgType">
9259c2 30           <el-radio-button value="color">纯色</el-radio-button>
H 31           <el-radio-button value="img">图片</el-radio-button>
820397 32         </el-radio-group>
H 33       </el-form-item>
34       <el-form-item label="选择颜色" v-if="formData!.style.bgType === 'color'">
35         <ColorInput v-model="formData!.style.bgColor" />
36       </el-form-item>
37       <el-form-item label="选择图片" v-if="formData!.style.bgType === 'img'">
38         <UploadImg v-model="formData!.style.bgImg" width="100%" height="50px" class="min-w-200px">
39           <template #tip> 建议尺寸 375 * 50 </template>
40         </UploadImg>
41       </el-form-item>
42
43       <el-text tag="p">图标设置</el-text>
44       <el-text type="info" size="small"> 拖动左上角的小圆点可对其排序, 图标建议尺寸 44*44 </el-text>
45       <Draggable v-model="formData.items" :limit="5">
46         <template #default="{ element }">
47           <div class="m-b-8px flex items-center justify-around">
48             <div class="flex flex-col items-center justify-between">
49               <UploadImg
50                 v-model="element.iconUrl"
51                 width="40px"
52                 height="40px"
53                 :show-delete="false"
54                 :show-btn-text="false"
55               />
56               <el-text size="small">未选中</el-text>
57             </div>
58             <div>
59               <UploadImg
60                 v-model="element.activeIconUrl"
61                 width="40px"
62                 height="40px"
63                 :show-delete="false"
64                 :show-btn-text="false"
65               />
66               <el-text>已选中</el-text>
67             </div>
68           </div>
69           <el-form-item prop="text" label="文字" label-width="48px" class="m-b-8px!">
70             <el-input v-model="element.text" placeholder="请输入文字" />
71           </el-form-item>
72           <el-form-item prop="url" label="链接" label-width="48px" class="m-b-0!">
73             <AppLinkInput v-model="element.url" />
74           </el-form-item>
75         </template>
76       </Draggable>
77     </el-form>
78   </div>
79 </template>
80
81 <script setup lang="ts">
9259c2 82 import { TabBarProperty, component, THEME_LIST } from './config'
820397 83 import { usePropertyForm } from '@/components/DiyEditor/util'
H 84 // 底部导航栏
85 defineOptions({ name: 'TabBarProperty' })
86
87 const props = defineProps<{ modelValue: TabBarProperty }>()
88 const emit = defineEmits(['update:modelValue'])
89 const { formData } = usePropertyForm(props.modelValue, emit)
90
9259c2 91 // 将数据库的值更新到右侧属性栏
H 92 component.property.items = formData.value.items
93
820397 94 // 要的主题
H 95 const handleThemeChange = () => {
96   const theme = THEME_LIST.find((theme) => theme.id === formData.value.theme)
97   if (theme?.color) {
98     formData.value.style.activeColor = theme.color
99   }
100 }
101 </script>
102
103 <style lang="scss" scoped></style>