web登录注册修改
This commit is contained in:
@@ -104,6 +104,27 @@
|
||||
/>
|
||||
<span v-if="item.remark" class="form-item-remark">{{ item.remark }}</span>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 图片上传 -->
|
||||
<el-form-item
|
||||
v-else-if="getRenderType(item) === 'imgupload'"
|
||||
:label="item.configName || item.configKey"
|
||||
:prop="item.configKey"
|
||||
>
|
||||
<el-upload
|
||||
:action="uploadUrl"
|
||||
:headers="uploadHeaders"
|
||||
:show-file-list="true"
|
||||
:limit="1"
|
||||
list-type="picture-card"
|
||||
:on-success="(response: any) => handleUploadSuccess(response, group.groupKey, item.configKey)"
|
||||
:on-remove="() => handleRemove(group.groupKey, item.configKey)"
|
||||
:file-list="getFileList(group.groupKey, item.configKey)"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>
|
||||
</el-upload>
|
||||
<span v-if="item.remark" class="form-item-remark">{{ item.remark }}</span>
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
@@ -125,11 +146,14 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { AdminLayout } from '@/views/admin';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import { configApi } from '@/apis/system';
|
||||
import type { ConfigItem } from '@/types/system/config';
|
||||
import { APP_CONFIG, FILE_DOWNLOAD_URL } from '@/config';
|
||||
import { useStore } from 'vuex';
|
||||
|
||||
defineOptions({
|
||||
name: 'SystemConfigView'
|
||||
@@ -146,6 +170,13 @@ interface ConfigGroup {
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const activeTab = ref('');
|
||||
const store = useStore();
|
||||
|
||||
// 上传配置
|
||||
const uploadUrl = APP_CONFIG.file.uploadUrl;
|
||||
const uploadHeaders = computed(() => ({
|
||||
Authorization: `Bearer ${store.state.auth.token}`
|
||||
}));
|
||||
|
||||
// 配置分组列表
|
||||
const configGroups = ref<ConfigGroup[]>([]);
|
||||
@@ -256,10 +287,13 @@ async function loadConfigs() {
|
||||
|
||||
// 定义分组名称映射
|
||||
const groupNames: Record<string, string> = {
|
||||
basic: '基本配置',
|
||||
email: '邮件配置',
|
||||
storage: '存储配置',
|
||||
system: '系统参数'
|
||||
'基础配置': '基础配置',
|
||||
'爬虫配置': '爬虫配置',
|
||||
'Dify配置': 'Dify配置',
|
||||
'邮件配置': '邮件配置',
|
||||
'短信配置': '短信配置',
|
||||
'存储配置': '存储配置',
|
||||
'系统参数': '系统参数'
|
||||
};
|
||||
|
||||
// 按分组组织配置
|
||||
@@ -329,6 +363,41 @@ async function loadConfigs() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件列表(用于显示已上传的图片)
|
||||
*/
|
||||
function getFileList(groupKey: string, configKey: string): any[] {
|
||||
const fileId = configData[groupKey]?.[configKey];
|
||||
if (fileId) {
|
||||
return [{
|
||||
name: 'image',
|
||||
url: `${FILE_DOWNLOAD_URL}${fileId}`
|
||||
}];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理上传成功
|
||||
*/
|
||||
function handleUploadSuccess(response: any, groupKey: string, configKey: string) {
|
||||
if (response.success && response.data) {
|
||||
// 后端返回的是fileId
|
||||
configData[groupKey][configKey] = response.data;
|
||||
ElMessage.success('图片上传成功');
|
||||
} else {
|
||||
ElMessage.error(response.message || '图片上传失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理删除图片
|
||||
*/
|
||||
function handleRemove(groupKey: string, configKey: string) {
|
||||
configData[groupKey][configKey] = '';
|
||||
ElMessage.success('图片已删除');
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存指定分组的配置
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user