feat: 初始化项目配置和文档- 添加 .editorconfig 文件,配置代码编辑规范
- 添加 .env 及相关文件,配置环境变量 - 添加 .eslintignore 和 .eslintrc.js 文件,配置 ESLint 规则 - 添加 .gitignore 文件,配置 Git忽略项 - 添加 .prettierignore 文件,配置 Prettier 忽略项 - 添加隐私政策文档,详细说明用户数据的收集和使用
This commit is contained in:
274
src/views/cms/cmsLink/components/cmsLinkEdit.vue
Normal file
274
src/views/cms/cmsLink/components/cmsLinkEdit.vue
Normal file
@@ -0,0 +1,274 @@
|
||||
<!-- 链接编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="460"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '修改链接' : '添加链接'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 5, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="名称" name="name">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="50"
|
||||
placeholder="链接名称"
|
||||
v-model:value="form.name"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="网址" name="url">
|
||||
<a-input
|
||||
v-model:value="form.url"
|
||||
placeholder="websoft.top"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="before" style="width: 90px">
|
||||
<a-select-option value="https://">https://</a-select-option>
|
||||
<a-select-option value="http://">http://</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="选择栏目" name="categoryId">-->
|
||||
<!-- <a-tree-select-->
|
||||
<!-- allow-clear-->
|
||||
<!-- :tree-data="navigationList"-->
|
||||
<!-- tree-default-expand-all-->
|
||||
<!-- placeholder="请选择栏目"-->
|
||||
<!-- :value="form.categoryId || undefined"-->
|
||||
<!-- :dropdown-style="{ maxHeight: '360px', overflow: 'auto' }"-->
|
||||
<!-- @update:value="(value?: number) => (form.categoryId = value)"-->
|
||||
<!-- @change="onCategoryId"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<a-form-item label="图标" name="icon">
|
||||
<SelectFile
|
||||
:placeholder="`请选择图标`"
|
||||
:limit="1"
|
||||
:data="images"
|
||||
:width="50"
|
||||
:height="50"
|
||||
@done="chooseFile"
|
||||
@del="onDeleteItem"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序" name="sortNumber">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:max="99999"
|
||||
class="ele-fluid"
|
||||
placeholder="请输入排序号"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { addCmsLink, updateCmsLink } from '@/api/cms/cmsLink';
|
||||
import type { CmsLink } from '@/api/cms/cmsLink/model';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
|
||||
import {getLang} from "@/utils/common";
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: CmsLink | null;
|
||||
navigationList?: CmsNavigation[];
|
||||
}>();
|
||||
|
||||
//
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 已上传数据
|
||||
const images = ref<ItemType[]>([]);
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
const before = ref<string>('https://');
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<CmsLink>({
|
||||
id: undefined,
|
||||
name: '',
|
||||
url: '',
|
||||
sortNumber: 100,
|
||||
lang: getLang(),
|
||||
categoryId: undefined,
|
||||
comments: undefined
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
url: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入正确的URL',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (item: any) => {
|
||||
const { file } = item;
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: data.url,
|
||||
status: 'done'
|
||||
});
|
||||
form.icon = data.url;
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandler = (file: File) => {
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (file.size / 1024 / 1024 > 1) {
|
||||
message.error('大小不能超过 1MB');
|
||||
return;
|
||||
}
|
||||
onUpload(item);
|
||||
};
|
||||
|
||||
const chooseFile = (data: FileRecord) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: data.path,
|
||||
status: 'done'
|
||||
});
|
||||
form.icon = data.path;
|
||||
};
|
||||
|
||||
const onDeleteItem = (index: number) => {
|
||||
images.value.splice(index, 1);
|
||||
form.icon = '';
|
||||
};
|
||||
|
||||
// 选择栏目
|
||||
const onCategoryId = (id: number) => {
|
||||
form.categoryId = id;
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
console.log(form,'fff>');
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const saveOrUpdate = isUpdate.value ? updateCmsLink : addCmsLink;
|
||||
form.url = `${before.value}${form.url}`;
|
||||
saveOrUpdate(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignFields(props.data);
|
||||
images.value = [];
|
||||
if (props.data.icon) {
|
||||
images.value.push({
|
||||
uid: 1,
|
||||
url: props.data.icon,
|
||||
status: 'done'
|
||||
});
|
||||
}
|
||||
if(props.data.url?.startsWith('https://')){
|
||||
before.value = 'https://';
|
||||
form.url = props.data.url.replace('https://', '');
|
||||
}
|
||||
if(props.data.url?.startsWith('http://')){
|
||||
before.value = 'http://';
|
||||
form.url = props.data.url.replace('http://', '');
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
images.value = [];
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
199
src/views/cms/cmsLink/components/linkUpdate.vue
Normal file
199
src/views/cms/cmsLink/components/linkUpdate.vue
Normal file
@@ -0,0 +1,199 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="600"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="'批量更新'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 3, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 24, sm: 24, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item>
|
||||
<a-alert :message="'提示:每次最多修改 50000 条数据'" banner />
|
||||
</a-form-item>
|
||||
<a-form-item label="选择栏目">
|
||||
<a-tree-select
|
||||
allow-clear
|
||||
:tree-data="navigationList"
|
||||
tree-default-expand-all
|
||||
style="width: 400px"
|
||||
placeholder="请选择栏目"
|
||||
:value="form.categoryId || undefined"
|
||||
:dropdown-style="{ maxHeight: '360px', overflow: 'auto' }"
|
||||
@update:value="(value?: number) => (form.categoryId = value)"
|
||||
@change="onCategoryId"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { FormInstance, RuleObject } from 'ant-design-vue/es/form';
|
||||
import { CmsNavigation } from "@/api/cms/cmsNavigation/model";
|
||||
import {updateBatchCmsLink} from "@/api/cms/cmsLink";
|
||||
import {CmsLink} from "@/api/cms/cmsLink/model";
|
||||
|
||||
// 是否是修改
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 表格选中数据
|
||||
selection?: CmsLink[];
|
||||
// 栏目数据
|
||||
navigationList?: CmsNavigation[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const content = ref('');
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<CmsLink>({
|
||||
// 自增ID
|
||||
id: undefined,
|
||||
// 链接名称
|
||||
name: undefined,
|
||||
// 图标
|
||||
icon: undefined,
|
||||
// 链接地址
|
||||
url: undefined,
|
||||
// 链接分类
|
||||
categoryId: undefined,
|
||||
// 应用ID
|
||||
appId: undefined,
|
||||
// 用户ID
|
||||
userId: undefined,
|
||||
// 语言
|
||||
lang: undefined,
|
||||
// 是否推荐
|
||||
recommend: undefined,
|
||||
// 备注
|
||||
comments: undefined,
|
||||
// 排序(数字越小越靠前)
|
||||
sortNumber: undefined,
|
||||
// 是否删除, 0否, 1是
|
||||
deleted: undefined,
|
||||
// 状态, 0正常, 1待确认
|
||||
status: undefined,
|
||||
// 租户id
|
||||
tenantId: undefined,
|
||||
// 创建时间
|
||||
createTime: undefined,
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
title: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择文章标题',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
categoryId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择栏目',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
content: [
|
||||
{
|
||||
required: true,
|
||||
type: "string",
|
||||
message: "请输入文章内容",
|
||||
trigger: "blur",
|
||||
validator: async (_rule: RuleObject, value: string) => {
|
||||
if (content.value == "") {
|
||||
return Promise.reject("请输入文字内容");
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
// 选择栏目
|
||||
const onCategoryId = (id: number) => {
|
||||
console.log(id);
|
||||
form.categoryId = id;
|
||||
};
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
props.selection?.map(d => d.id)
|
||||
updateBatchCmsLink({
|
||||
ids: props.selection?.map(d => d.id),
|
||||
data: {
|
||||
categoryId: form.categoryId
|
||||
}
|
||||
}).then((msg) => {
|
||||
message.success(msg);
|
||||
loading.value = false;
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
97
src/views/cms/cmsLink/components/search.vue
Normal file
97
src/views/cms/cmsLink/components/search.vue
Normal file
@@ -0,0 +1,97 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
:disabled="selection?.length === 0"
|
||||
@click="updateBatch"
|
||||
>
|
||||
移动
|
||||
</a-button>
|
||||
<a-tree-select
|
||||
allow-clear
|
||||
:tree-data="navigationList"
|
||||
tree-default-expand-all
|
||||
style="width: 280px"
|
||||
:listHeight="700"
|
||||
placeholder="请选择栏目"
|
||||
:value="where.categoryId || undefined"
|
||||
:dropdown-style="{ overflow: 'auto' }"
|
||||
@update:value="(value?: number) => (where.categoryId = value)"
|
||||
@change="onCategoryId"
|
||||
/>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入关键词"
|
||||
style="width: 280px"
|
||||
v-model:value="where.keywords"
|
||||
@search="reload"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import type { GradeParam } from '@/api/user/grade/model';
|
||||
import { watch } from 'vue';
|
||||
import {CmsNavigation} from "@/api/cms/cmsNavigation/model";
|
||||
import useSearch from "@/utils/use-search";
|
||||
import {CmsLinkParam} from "@/api/cms/cmsLink/model";
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
navigationList?: CmsNavigation[];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
// 网站ID
|
||||
const websiteId = localStorage.getItem('WebsiteId')
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: GradeParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<CmsLinkParam>({
|
||||
id: undefined,
|
||||
categoryId: undefined,
|
||||
keywords: '',
|
||||
userId: undefined
|
||||
});
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量更新
|
||||
const updateBatch = () => {
|
||||
emit('batchMove');
|
||||
}
|
||||
|
||||
// 按分类查询
|
||||
const onCategoryId = (id: number) => {
|
||||
where.categoryId = id;
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
Reference in New Issue
Block a user