Skip to content

Commit f5ce9b4

Browse files
committed
feat: enhance ColorPicker and plugin form
1 parent e714f30 commit f5ce9b4

File tree

6 files changed

+36
-23
lines changed

6 files changed

+36
-23
lines changed

frontend/src/components/ColorPicker/index.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<script lang="ts" setup>
22
import { useTemplateRef } from 'vue'
33
4-
const model = defineModel<string>({ default: '#000' })
4+
interface Props {
5+
disabled?: boolean
6+
}
7+
8+
const props = withDefaults(defineProps<Props>(), {
9+
disabled: false,
10+
})
11+
12+
const model = defineModel<string>({ default: '#000000' })
513
614
const emit = defineEmits(['change'])
715
@@ -13,14 +21,20 @@ const onChange = (v: Event) => {
1321
}
1422
1523
const pick = () => {
16-
inputRef.value?.click()
24+
!props.disabled && inputRef.value?.click()
1725
}
1826
</script>
1927

2028
<template>
2129
<div
22-
:class="{ 'pl-8': $slots.prefix, 'pr-8': $slots.suffix }"
23-
class="gui-color-picker rounded-full inline-flex items-center overflow-hidden cursor-pointer duration-200"
30+
@click="pick"
31+
:class="{
32+
'pl-8': $slots.prefix,
33+
'pr-8': $slots.suffix,
34+
'cursor-not-allowed': disabled,
35+
'cursor-pointer': !disabled,
36+
}"
37+
class="gui-color-picker rounded-full inline-flex items-center overflow-hidden duration-200"
2438
>
2539
<div v-if="$slots.prefix" class="flex items-center line-clamp-1 break-all">
2640
<slot name="prefix" v-bind="{ pick }"></slot>
@@ -29,6 +43,7 @@ const pick = () => {
2943
ref="inputRef"
3044
v-model="model"
3145
@change="(e) => onChange(e)"
46+
:class="{ 'pointer-events-none': disabled }"
3247
type="color"
3348
class="w-26 h-28 flex justify-center items-center border-0 bg-transparent cursor-pointer"
3449
/>

frontend/src/components/Select/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const displayLabel = computed(() => {
4848
if (selected.length === 0) {
4949
return props.placeholder ?? 'common.none'
5050
}
51-
return selected.map((item) => optionsValueLabelMapping.value[item] ?? item).join('')
51+
return selected.map((item) => t(optionsValueLabelMapping.value[item] ?? item)).join('')
5252
}
5353
const label = props.options.find((v) => v.value === model.value)?.label ?? (model.value as string)
5454
return (label || props.placeholder) ?? 'common.none'

frontend/src/lang/locale/zh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ export default {
484484
version: '版本号',
485485
description: '描述',
486486
url: '远程地址',
487-
install: '需要安装',
487+
install: '是否需要安装',
488488
installed: '已安装',
489489
path: '保存路径',
490490
type: '类型',

frontend/src/types/app.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export interface PluginConfiguration {
115115
| 'Select'
116116
| 'MultipleSelect'
117117
| 'Switch'
118+
| 'ColorPicker'
118119
| ''
119120
value: any
120121
options: any[]

frontend/src/views/PluginsView/components/PluginForm.vue

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const componentList = [
5757
'Select',
5858
'MultipleSelect',
5959
'Switch',
60+
'ColorPicker',
6061
] as const
6162
6263
type ComponentType = (typeof componentList)[number]
@@ -130,6 +131,10 @@ const onComponentChange = (component: ComponentType, index: number) => {
130131
plugin.value.configuration[index]!.value = ''
131132
break
132133
}
134+
case 'ColorPicker': {
135+
plugin.value.configuration[index]!.value = '#000000'
136+
break
137+
}
133138
case 'KeyValueEditor': {
134139
plugin.value.configuration[index]!.value = {}
135140
break
@@ -202,21 +207,9 @@ defineExpose({ modalSlots })
202207
]"
203208
/>
204209
</div>
205-
<div class="form-item">
206-
{{ t('plugin.install') }}
207-
<Switch v-model="plugin.install" />
208-
</div>
209210
<div class="form-item">
210211
<div class="mr-8">{{ t('plugin.trigger') }}</div>
211-
<CheckBox v-model="plugin.triggers" :options="PluginsTriggerOptions.slice(0, 3)" />
212-
</div>
213-
<div class="form-item">
214-
<div class="name"></div>
215-
<CheckBox v-model="plugin.triggers" :options="PluginsTriggerOptions.slice(3, 7)" />
216-
</div>
217-
<div class="form-item">
218-
<div class="name"></div>
219-
<CheckBox v-model="plugin.triggers" :options="PluginsTriggerOptions.slice(7)" />
212+
<MultipleSelect v-model="plugin.triggers" :options="PluginsTriggerOptions" clearable />
220213
</div>
221214
<div class="form-item">
222215
{{ t('plugin.name') }} *
@@ -262,6 +255,10 @@ defineExpose({ modalSlots })
262255
</Button>
263256
</Divider>
264257
<div v-show="showMore" class="pb-8">
258+
<div class="form-item">
259+
{{ t('plugin.install') }}
260+
<Switch v-model="plugin.install" />
261+
</div>
265262
<div class="form-item">
266263
{{ t('plugin.hasUI') }}
267264
<Switch v-model="plugin.hasUI" />

frontend/src/views/SettingsView/components/components/PersonalizationSettings.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ const handleOpenLocalesFolder = async () => {
4343
<div class="flex items-center">
4444
<div v-if="appSettings.app.color === Color.Custom" class="flex items-center mr-4">
4545
<ColorPicker v-model="appSettings.app.primaryColor">
46-
<template #suffix="{ pick }">
47-
<div @click="pick" class="text-12">{{ $t('settings.color.primary') }}</div>
46+
<template #suffix>
47+
<div class="text-12">{{ $t('settings.color.primary') }}</div>
4848
</template>
4949
</ColorPicker>
5050
<ColorPicker v-model="appSettings.app.secondaryColor">
51-
<template #suffix="{ pick }">
52-
<div @click="pick" class="text-12">{{ $t('settings.color.secondary') }}</div>
51+
<template #suffix>
52+
<div class="text-12">{{ $t('settings.color.secondary') }}</div>
5353
</template>
5454
</ColorPicker>
5555
</div>

0 commit comments

Comments
 (0)