chore(config): 初始化项目配置文件
- 添加 .editorconfig 文件统一代码风格 - 配置 .env.development 环境变量文件 - 创建 .env.example 环境变量示例文件 - 设置 .eslintignore 忽略检查规则 - 配置 .eslintrc.js 代码检查规则 - 添加 .gitignore 文件忽略版本控制 - 设置 .prettierignore 忽略格式化规则 - 新增隐私政策HTML页面文件 - 创建API密钥编辑组件基础结构
This commit is contained in:
135
src/components/SelectFile/index.vue
Normal file
135
src/components/SelectFile/index.vue
Normal file
@@ -0,0 +1,135 @@
|
||||
<template>
|
||||
<a-image-preview-group>
|
||||
<a-space>
|
||||
<template v-for="(item, index) in data" :key="index">
|
||||
<div class="image-upload-item" v-if="isImage(item.url)">
|
||||
<a-image
|
||||
:style="{
|
||||
border: '1px dashed var(--grey-7)',
|
||||
width: width + 'px',
|
||||
height: height + 'px'
|
||||
}"
|
||||
:src="item.url"
|
||||
/>
|
||||
<a class="image-upload-close" @click="onDeleteItem(index)">
|
||||
<CloseOutlined />
|
||||
</a>
|
||||
</div>
|
||||
<div v-else class="image-upload-item">
|
||||
<YoutubeOutlined />
|
||||
<a class="image-upload-close" @click="onDeleteItem(index)">
|
||||
<CloseOutlined />
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
||||
<a-button
|
||||
@click="openEdit"
|
||||
v-if="data?.length < limit"
|
||||
:style="{ width: width + 'px', height: height + 'px' }"
|
||||
class="select-picture-btn ele-text-placeholder"
|
||||
>
|
||||
<PlusOutlined />
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-image-preview-group>
|
||||
|
||||
<!-- 选择弹窗 -->
|
||||
<SelectData
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
:title="placeholder"
|
||||
:type="type"
|
||||
@done="onChange"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined, CloseOutlined, YoutubeOutlined } from '@ant-design/icons-vue';
|
||||
import { ref } from 'vue';
|
||||
import SelectData from './components/select-data.vue';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
import { isImage } from "@/utils/common";
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
value?: any;
|
||||
data?: any[];
|
||||
width?: number;
|
||||
height?: number;
|
||||
type?: string;
|
||||
limit?: number;
|
||||
placeholder?: string;
|
||||
index?: number;
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择数据',
|
||||
width: 80,
|
||||
height: 80,
|
||||
limit: 1
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done', data: FileRecord): void;
|
||||
(e: 'del', index: number): void;
|
||||
(e: 'clear'): void;
|
||||
}>();
|
||||
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 当前编辑数据
|
||||
const current = ref<FileRecord | null>(null);
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: FileRecord) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
const onChange = (row) => {
|
||||
row.index = props.index;
|
||||
emit('done', row);
|
||||
};
|
||||
|
||||
const onDeleteItem = (index: number) => {
|
||||
emit('del', index);
|
||||
};
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.select-picture-btn {
|
||||
background-color: var(--grey-9);
|
||||
border: 1px dashed var(--border-color-base);
|
||||
font-size: 16px;
|
||||
}
|
||||
//.ant-image-img {
|
||||
// width: 100px !important;
|
||||
// height: 100px !important;
|
||||
//}
|
||||
.image-upload-item {
|
||||
position: relative;
|
||||
}
|
||||
.image-upload-close {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
color: rgb(255, 255, 255);
|
||||
font-size: 10px;
|
||||
border-bottom-left-radius: 18px;
|
||||
border-top-right-radius: 2px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
right: 1px;
|
||||
line-height: 1;
|
||||
box-sizing: border-box;
|
||||
padding: 2px 0 0 5px;
|
||||
transition: background-color 0.2s ease-in-out 0s;
|
||||
cursor: pointer;
|
||||
z-index: 2;
|
||||
//display: flex;
|
||||
//justify-content: center;
|
||||
//align-items: center;
|
||||
}
|
||||
.image-upload-close:hover {
|
||||
background-color: var(--red-6);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user