chore(config): 添加项目配置文件和隐私协议

- 新增 .editorconfig 文件统一代码风格配置
- 新增 .env 环境变量配置文件
- 添加开发和生产环境的环境变量配置
- 配置 ESLint 忽略规则文件
- 设置代码检查配置文件 .eslintrc.js
- 添加 Git 忽略文件规则
- 创建 Prettier 格式化忽略规则
- 添加隐私政策和服务协议HTML文件
- 实现访问密钥编辑组件基础结构
This commit is contained in:
2026-02-07 16:33:13 +08:00
commit 92a6a32868
1384 changed files with 224513 additions and 0 deletions

View File

@@ -0,0 +1,299 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? `【${form.formUserName}】给你发送的消息` : '发送消息'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
:ok-button-props="{ disabled: isUpdate }"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<template v-if="isUpdate">
<a-form-item label="消息类型" name="type">
<span class="ele-text-secondary">文本</span>
</a-form-item>
<a-form-item label="消息内容" name="content">
<div class="ele-text-secondary">
<byte-md-viewer :value="form.content" :plugins="plugins" />
</div>
</a-form-item>
<a-form-item label="发送时间" name="type">
<div class="ele-text-secondary">{{ form.createTime }}</div>
</a-form-item>
</template>
<template v-else>
<a-form-item label="接收对象" name="toUserIds" v-if="!isUpdate">
<SelectUser
:placeholder="`选择用户`"
v-model:value="form.toUserName"
@done="onToUser"
/>
</a-form-item>
<a-form-item label="消息类型" name="type">
<DictSelect
dict-code="chatMessageType"
:placeholder="`选择消息类型`"
v-model:value="form.type"
:disabled="true"
@done="chooseType"
/>
</a-form-item>
<a-form-item label="消息内容" name="content">
<!-- 编辑器 -->
<byte-md-editor
v-model:value="content"
placeholder="请描述您的问题,支持图片粘贴"
mode="tab"
height="300px"
:locale="zh_Hans"
:plugins="plugins"
maxLength="500"
:editorConfig="{ lineNumbers: true }"
/>
</a-form-item>
</template>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject } from 'ele-admin-pro';
import {
addBatchChatMessage,
addChatMessage,
updateChatMessage
} from '@/api/system/chatMessage';
import { ChatMessage } from '@/api/system/chatMessage/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance, RuleObject } from 'ant-design-vue/es/form';
import 'bytemd/dist/index.min.css';
import 'github-markdown-css/github-markdown-light.css';
// // 链接、删除线、复选框、表格等的插件
import gfm from '@bytemd/plugin-gfm';
// // 插件的中文语言文件
import zh_HansGfm from '@bytemd/plugin-gfm/locales/zh_Hans.json';
// 中文语言文件
import zh_Hans from 'bytemd/locales/zh_Hans.json';
import 'bytemd/dist/index.min.css';
import highlight from '@bytemd/plugin-highlight-ssr';
import 'highlight.js/styles/default.css';
import { MerchantAccount } from '@/api/shop/merchantAccount/model';
import { User } from '@/api/system/user/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ChatMessage | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
const content = ref('');
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
const merchantAccount = ref<MerchantAccount[]>([]);
const formDataBatch = ref<ChatMessage[]>([]);
// 用户信息
const form = reactive<ChatMessage>({
formUserId: undefined,
toUserId: undefined,
toUserIds: undefined,
type: 'text',
content: '',
sideTo: undefined,
sideFrom: undefined,
withdraw: undefined,
fileInfo: undefined,
hasContact: undefined,
status: 0,
formUserName: '',
createTime: ''
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
toUserIds: [
{
required: true,
type: 'any',
message: '请选择用户',
trigger: 'blur'
}
],
type: [
{
required: true,
type: 'string',
message: '请选择消息类型',
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 plugins = ref([
gfm({
locale: zh_HansGfm
}),
highlight()
]);
const onToUser = (item: User) => {
form.toUserIds = [item.phone];
form.toUserName = [item.phone];
console.log(form);
// form.toUserId = item.userId;
// form.toUserName = item.nickname;
};
const chooseType = (item: any) => {
form.type = 'text';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
if (!isUpdate.value) {
merchantAccount.value.map((d) => {
formDataBatch.value.push({
toUserId: d.userId,
type: form.type,
content: content.value
});
});
addBatchChatMessage(formDataBatch.value)
.then((msg) => {
loading.value = false;
form.toUserIds = [];
formDataBatch.value = [];
merchantAccount.value = [];
form.toUserName = undefined;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
return;
}
const formData = {
...form,
status: isUpdate.value ? 1 : 0,
content: content.value
};
const saveOrUpdate = isUpdate.value
? updateChatMessage
: addChatMessage;
saveOrUpdate(formData)
.then(() => {
loading.value = false;
form.toUserName = undefined;
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
content.value = '';
if (props.data) {
assignObject(form, props.data);
// 标记已读
updateChatMessage({ id: props.data.id, status: 1 });
emit('done');
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>
<style lang="less" scoped>
.user-content {
max-width: 100%;
border-radius: 8px !important;
background-color: #a2ec71;
border: none;
}
.admin-content {
border-radius: 8px !important;
border: 3px solid #f1f1f1;
}
</style>

View File

@@ -0,0 +1,69 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button
type="primary"
class="ele-btn-icon"
@click="add"
v-any-role="['superAdmin', 'merchant']"
>
<template #icon>
<PlusOutlined />
</template>
<span>发消息</span>
</a-button>
<a-input-search
allow-clear
placeholder="请输入关键词"
v-model:value="where.keywords"
@pressEnter="search"
@search="search"
/>
</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 useSearch from '@/utils/use-search';
import { ChatMessageParam } from '@/api/system/chat/model';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 表单数据
const { where } = useSearch<ChatMessageParam>({
keywords: '',
formUserId: undefined
});
/* 搜索 */
const search = () => {
emit('search', {
...where
});
};
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,243 @@
<template>
<a-page-header :title="title" @back="() => $router.go(-1)">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="chatMessageId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'content'">
<span v-if="record.type === 'card'" class="ele-text-placeholder"
>[卡片]</span
>
<span
v-else-if="record.type === 'text'"
v-html="record.content"
@click="openEdit(record)"
></span>
<span v-else class="ele-text-placeholder">[其他]</span>
</template>
<template v-if="column.key === 'status'">
<a-badge dot v-if="record.status === 0" status="error" />
<a-badge dot v-else status="default" />
</template>
<template v-if="column.key === 'action'">
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ChatMessageEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</a-page-header>
</template>
<script lang="ts" setup>
import { createVNode, ref, watch } from 'vue';
import { message, Modal } from 'ant-design-vue';
import {
ExclamationCircleOutlined,
NotificationOutlined
} from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ChatMessageEdit from './components/chatMessageEdit.vue';
import {
pageChatMessage,
removeChatMessage,
removeBatchChatMessage
} from '@/api/system/chatMessage';
import type {
ChatMessage,
ChatMessageParam
} from '@/api/system/chatMessage/model';
import { useRouter } from 'vue-router';
const { currentRoute } = useRouter();
import { getPageTitle, getUserId } from '@/utils/common';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ChatMessage[]>([]);
// 当前编辑数据
const current = ref<ChatMessage | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 页面标题
const title = getPageTitle();
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
where.toUserId = getUserId();
return pageChatMessage({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '未/已读',
dataIndex: 'status',
key: 'status',
align: 'center',
width: 90
},
{
title: '消息内容',
dataIndex: 'content',
key: 'content'
},
{
title: '发送人',
dataIndex: 'formUserName',
key: 'formUserName',
width: 180,
align: 'center'
},
{
title: '发送时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 180,
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
},
{
title: '操作',
key: 'action',
width: 120,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ChatMessageParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ChatMessage) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ChatMessage) => {
const hide = message.loading('请求中..', 0);
removeChatMessage(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchChatMessage(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 自定义行属性 */
const customRow = (record: ChatMessage) => {
return {
// 行点击事件
onClick: () => {
// openEdit(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
watch(
currentRoute,
() => {
reload();
},
{ immediate: true }
);
</script>
<script lang="ts">
export default {
name: 'ChatMessage'
};
</script>
<style lang="less" scoped></style>