refactor(ui): 优化

This commit is contained in:
廖彦棋 2024-03-08 09:12:39 +08:00
parent 9796a841d9
commit bfa0208692
9 changed files with 72 additions and 55 deletions

View File

@ -33,9 +33,9 @@ const formData = computed({
}); });
const searchColumns = computed(() => { const searchColumns = computed(() => {
return props.columns?.filter( return props.columns?.filter((item) => item.dataIndex && item.search) as (SearchColumns & {
(item) => item.dataIndex && item.search dataIndex: string;
) as (SearchColumns & { dataIndex: string })[]; })[];
}); });
const optionsEvent = { const optionsEvent = {
@ -60,7 +60,7 @@ const optionsEvent = {
@submit="optionsEvent.onSearch" @submit="optionsEvent.onSearch"
> >
<AGrid <AGrid
:cols="{ md: 1, lg: 2, xl: 3, xxl: 5 }" :cols="{ md: 1, lg: 3, xl: 4, xxl: 5 }"
:row-gap="12" :row-gap="12"
:col-gap="12" :col-gap="12"
:collapsed="collapsed" :collapsed="collapsed"
@ -70,14 +70,11 @@ const optionsEvent = {
:key="item.dataIndex" :key="item.dataIndex"
style="transition: all 0.3s ease-in-out" style="transition: all 0.3s ease-in-out"
> >
<AFormItem :field="item.dataIndex" :label="(item.title as string)"> <AFormItem :field="item.dataIndex" :label="item.title as string">
<slot :name="item.search.slotsName"> <slot :name="item.search.slotsName">
<component <component
v-model="formData[item.dataIndex]" v-model="formData[item.dataIndex]"
:is=" :is="ValueType[item.search.valueType ?? 'input'] ?? item.search.render"
ValueType[item.search.valueType ?? 'input'] ??
item.search.render
"
v-bind="useComponentConfig(size, item)" v-bind="useComponentConfig(size, item)"
/> />
</slot> </slot>
@ -86,20 +83,11 @@ const optionsEvent = {
<AGridItem suffix> <AGridItem suffix>
<ASpace class="flex-end"> <ASpace class="flex-end">
<slot name="search-options" :option="optionsEvent"> <slot name="search-options" :option="optionsEvent">
<AButton <AButton type="primary" html-type="submit" :size="size" :loading="submitting">
type="primary"
html-type="submit"
:size="size"
:loading="submitting"
>
<icon-search /> <icon-search />
<span>查询</span> <span>查询</span>
</AButton> </AButton>
<AButton <AButton :size="size" @click="optionsEvent.onReset" :loading="submitting">
:size="size"
@click="optionsEvent.onReset"
:loading="submitting"
>
<icon-refresh /> <icon-refresh />
<span>重置</span> <span>重置</span>
</AButton> </AButton>

View File

@ -3,6 +3,9 @@ import {
IconDashboard, IconDashboard,
IconOrderedList, IconOrderedList,
IconCalendar, IconCalendar,
IconHeartFill,
IconCodeSquare,
IconMessage,
IconSettings, IconSettings,
IconUserGroup, IconUserGroup,
IconLock, IconLock,
@ -80,16 +83,25 @@ const menu = [
name: "Reward", name: "Reward",
meta: { meta: {
title: "众筹管理", title: "众筹管理",
icon: IconCalendar, icon: IconHeartFill,
}, },
component: () => import("@/views/Reward/RewardContainer.vue"), component: () => import("@/views/Reward/RewardContainer.vue"),
}, },
{
path: "/functions",
name: "Functions",
meta: {
title: "函数管理",
icon: IconCodeSquare,
},
component: () => import("@/views/Functions/FunctionsContainer.vue"),
},
{ {
path: "/chats", path: "/chats",
name: "Chats", name: "Chats",
meta: { meta: {
title: "对话管理", title: "对话管理",
icon: IconCalendar, icon: IconMessage,
}, },
component: () => import("@/views/Chats/ChatsContainer.vue"), component: () => import("@/views/Chats/ChatsContainer.vue"),
}, },

View File

@ -55,8 +55,13 @@ const handleRemove = async (id, reload) => {
}; };
</script> </script>
<template> <template>
<a-button type="primary" @click="openFormModal">新增</a-button>
<SimpleTable :request="getList" :columns="columns" :pagination="false"> <SimpleTable :request="getList" :columns="columns" :pagination="false">
<template #header="{ reload }">
<a-button @click="openFormModal(reload, {})">
<template #icon> <icon-plus /> </template>
新增
</a-button>
</template>
<template #switch="{ record, column }"> <template #switch="{ record, column }">
<ConfirmSwitch <ConfirmSwitch
v-model="record[column.dataIndex]" v-model="record[column.dataIndex]"

View File

@ -28,7 +28,7 @@ const rules = {
}; };
const generateToken = async () => { const generateToken = async () => {
const { data } = await token(); const { data } = await token({});
Message.success("生成 Token 成功"); Message.success("生成 Token 成功");
formData.token = data; formData.token = data;
}; };
@ -64,15 +64,14 @@ defineExpose({
<a-input v-model="formData.action" placeholder="该函数实现的API地址可以是第三方服务API" /> <a-input v-model="formData.action" placeholder="该函数实现的API地址可以是第三方服务API" />
</a-form-item> </a-form-item>
<a-form-item field="token" label="API Token"> <a-form-item field="token" label="API Token">
<a-input v-model="formData.token" placeholder="API授权Token"> <a-input-group style="width: 100%">
<template #append> <a-input v-model="formData.token" placeholder="API授权Token" />
<a-tooltip <a-tooltip
content="只有本地服务才可以使用自动生成Token第三方服务请填写第三方服务API Token" content="只有本地服务才可以使用自动生成Token第三方服务请填写第三方服务API Token"
> >
<a-button type="text" @click="generateToken">生成Token</a-button> <a-button type="primary" @click="generateToken">生成Token</a-button>
</a-tooltip> </a-tooltip>
</template> </a-input-group>
</a-input>
</a-form-item> </a-form-item>
<a-form-item field="enabled" label="启用状态"> <a-form-item field="enabled" label="启用状态">
<a-switch v-model="formData.enabled" /> <a-switch v-model="formData.enabled" />

View File

@ -38,7 +38,7 @@ onMounted(async () => {
}); });
</script> </script>
<template> <template>
<a-form ref="formRef" :model="system" :rules="rules" auto-laba-width> <a-form ref="formRef" :model="system" :rules="rules" auto-label-width>
<a-form-item label="网站标题" field="title"> <a-form-item label="网站标题" field="title">
<a-input v-model="system['title']" /> <a-input v-model="system['title']" />
</a-form-item> </a-form-item>
@ -73,10 +73,12 @@ onMounted(async () => {
/> />
</a-form-item> </a-form-item>
<a-form-item label="开放注册" field="enabled_register"> <a-form-item label="开放注册" field="enabled_register">
<a-switch v-model="system['enabled_register']" /> <a-space>
<a-tooltip content="关闭注册之后只能通过管理后台添加用户" position="right"> <a-switch v-model="system['enabled_register']" />
<icon-info-circle-fill size="18" /> <a-tooltip content="关闭注册之后只能通过管理后台添加用户" position="right">
</a-tooltip> <icon-info-circle-fill size="18" />
</a-tooltip>
</a-space>
</a-form-item> </a-form-item>
<a-form-item label="注册方式" field="register_ways"> <a-form-item label="注册方式" field="register_ways">
<a-checkbox-group v-model="system['register_ways']"> <a-checkbox-group v-model="system['register_ways']">
@ -85,10 +87,12 @@ onMounted(async () => {
</a-checkbox-group> </a-checkbox-group>
</a-form-item> </a-form-item>
<a-form-item label="启用众筹功能" field="enabled_reward"> <a-form-item label="启用众筹功能" field="enabled_reward">
<a-switch v-model="system['enabled_reward']" /> <a-space>
<a-tooltip content="如果关闭次功能将不在用户菜单显示众筹二维码" position="right"> <a-switch v-model="system['enabled_reward']" />
<icon-info-circle-fill size="18" /> <a-tooltip content="如果关闭次功能将不在用户菜单显示众筹二维码" position="right">
</a-tooltip> <icon-info-circle-fill size="18" />
</a-tooltip>
</a-space>
</a-form-item> </a-form-item>
<template v-if="system['enabled_reward']"> <template v-if="system['enabled_reward']">
<a-form-item label="单次对话价格" field="chat_call_price"> <a-form-item label="单次对话价格" field="chat_call_price">

View File

@ -46,7 +46,7 @@ const reload = async () => {
onMounted(reload); onMounted(reload);
</script> </script>
<template> <template>
<a-form ref="formRef" :model="chat" :rules="rules" auto-laba-width> <a-form ref="formRef" :model="chat" :rules="rules" auto-label-width>
<a-form-item label="开启聊天上下文"> <a-form-item label="开启聊天上下文">
<a-switch v-model="chat['enable_context']" /> <a-switch v-model="chat['enable_context']" />
</a-form-item> </a-form-item>

View File

@ -12,9 +12,17 @@ const tabsList = [
const activeKey = ref(tabsList[0].key); const activeKey = ref(tabsList[0].key);
</script> </script>
<template> <template>
<a-tabs v-model:active-key="activeKey" lazy-load> <a-tabs v-model:active-key="activeKey" lazy-load justify>
<a-tab-pane v-for="item in tabsList" :key="item.key" :title="item.title"> <a-tab-pane v-for="item in tabsList" :key="item.key" :title="item.title">
<component :is="item.components" /> <div class="system-config-wrapper">
<component :is="item.components" />
</div>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</template> </template>
<style scoped>
.system-config-wrapper {
height: 100%;
overflow-y: auto;
}
</style>

View File

@ -56,7 +56,7 @@ const onUploadImg = (files, callback) => {
onMounted(reload); onMounted(reload);
</script> </script>
<template> <template>
<a-form ref="formRef" :model="formData" auto-laba-width> <a-form ref="formRef" :model="formData" auto-label-width>
<md-editor v-model="formData.content" @on-upload-img="onUploadImg" /> <md-editor v-model="formData.content" @on-upload-img="onUploadImg" />
<a-form-item> <a-form-item>
<a-button type="primary" :loading="submitting" @click="handleSave">提交</a-button> <a-button type="primary" :loading="submitting" @click="handleSave">提交</a-button>

View File

@ -23,14 +23,15 @@ const handleChange = (_, file: FileItem) => {
</script> </script>
<template> <template>
<a-space> <a-space>
<a-input :model-value="modelValue" :placeholder="placeholder" readonly> <a-input-group>
<template #append> <a-input :model-value="modelValue" :placeholder="placeholder" readonly />
<a-upload v-bind="uploadProps" @change="handleChange"> <a-upload v-bind="uploadProps" @change="handleChange">
<template #upload-button> <template #upload-button>
<icon-upload /> <a-button type="primary">
</template> <icon-cloud />
</a-upload> </a-button>
</template> </template>
</a-input> </a-upload>
</a-input-group>
</a-space> </a-space>
</template> </template>