fix: code style

This commit is contained in:
dylanmay
2025-11-06 23:23:25 +08:00
parent 500ce9cf7c
commit 007bb2dd26
21 changed files with 116 additions and 105 deletions

View File

@@ -58,7 +58,6 @@
"diagram-js": "catalog:", "diagram-js": "catalog:",
"fast-xml-parser": "catalog:", "fast-xml-parser": "catalog:",
"highlight.js": "catalog:", "highlight.js": "catalog:",
"lodash": "^4.17.21",
"pinia": "catalog:", "pinia": "catalog:",
"steady-xml": "catalog:", "steady-xml": "catalog:",
"tinymce": "catalog:", "tinymce": "catalog:",

View File

@@ -23,10 +23,6 @@ export namespace MpAccountApi {
} }
} }
// 重新导出类型,方便使用
// export type Account = MpAccountApi.Account;
// export type AccountSimple = MpAccountApi.AccountSimple;
/** 查询公众号账号列表 */ /** 查询公众号账号列表 */
export function getAccountPage(params: PageParam) { export function getAccountPage(params: PageParam) {
return requestClient.get<PageResult<MpAccountApi.Account>>( return requestClient.get<PageResult<MpAccountApi.Account>>(

View File

@@ -29,7 +29,7 @@ const account: MpAccountApi.Account = reactive({
const accountList = ref<MpAccountApi.Account[]>([]); const accountList = ref<MpAccountApi.Account[]>([]);
// 查询公众号列表 // 查询公众号列表
const handleQuery = async () => { async function handleQuery() {
accountList.value = await getSimpleAccountList(); accountList.value = await getSimpleAccountList();
if (accountList.value.length === 0) { if (accountList.value.length === 0) {
message.error('未配置公众号,请在【公众号管理 -> 账号管理】菜单,进行配置'); message.error('未配置公众号,请在【公众号管理 -> 账号管理】菜单,进行配置');
@@ -44,16 +44,16 @@ const handleQuery = async () => {
account.name = first.name; account.name = first.name;
emit('change', account.id, account.name); emit('change', account.id, account.name);
} }
}; }
// 切换选中公众号 // 切换选中公众号
const onChanged = (id: SelectValue) => { function onChanged(id: SelectValue) {
const found = accountList.value.find((v) => v.id === id); const found = accountList.value.find((v) => v.id === id);
if (found) { if (found) {
account.name = found.name; account.name = found.name;
emit('change', account.id, account.name); emit('change', account.id, account.name);
} }
}; }
// 初始化 // 初始化
onMounted(handleQuery); onMounted(handleQuery);

View File

@@ -45,11 +45,11 @@ const queryParams = reactive({
pageSize: 10, pageSize: 10,
}); });
const selectMaterialFun = (item: any) => { function selectMaterialFun(item: any) {
emit('selectMaterial', item); emit('selectMaterial', item);
}; }
const getPage = async () => { async function getPage() {
loading.value = true; loading.value = true;
try { try {
if (props.type === 'news' && props.newsType === NewsType.Published) { if (props.type === 'news' && props.newsType === NewsType.Published) {
@@ -65,18 +65,18 @@ const getPage = async () => {
} finally { } finally {
loading.value = false; loading.value = false;
} }
}; }
const getMaterialPageFun = async () => { async function getMaterialPageFun() {
const data = await MpMaterialApi.getMaterialPage({ const data = await MpMaterialApi.getMaterialPage({
...queryParams, ...queryParams,
type: props.type, type: props.type,
}); });
list.value = data.list; list.value = data.list;
total.value = data.total; total.value = data.total;
}; }
const getFreePublishPageFun = async () => { async function getFreePublishPageFun() {
const data = await MpFreePublishApi.getFreePublishPage(queryParams); const data = await MpFreePublishApi.getFreePublishPage(queryParams);
data.list.forEach((item: any) => { data.list.forEach((item: any) => {
const articles = item.content.newsItem; const articles = item.content.newsItem;
@@ -86,9 +86,9 @@ const getFreePublishPageFun = async () => {
}); });
list.value = data.list; list.value = data.list;
total.value = data.total; total.value = data.total;
}; }
const getDraftPageFun = async () => { async function getDraftPageFun() {
const data = await MpDraftApi.getDraftPage(queryParams); const data = await MpDraftApi.getDraftPage(queryParams);
data.list.forEach((draft: any) => { data.list.forEach((draft: any) => {
const articles = draft.content.newsItem; const articles = draft.content.newsItem;
@@ -98,7 +98,7 @@ const getDraftPageFun = async () => {
}); });
list.value = data.list; list.value = data.list;
total.value = data.total; total.value = data.total;
}; }
const voiceColumns = [ const voiceColumns = [
{ {

View File

@@ -18,13 +18,15 @@ const SendFrom = {
User: 1, User: 1,
} as const; } as const;
const getAvatar = (sendFrom: number) => function getAvatar(sendFrom: number) {
sendFrom === SendFrom.User return sendFrom === SendFrom.User
? props.user.avatar ? props.user.avatar
: preferences.app.defaultAvatar; : preferences.app.defaultAvatar;
}
const getNickname = (sendFrom: SendFrom) => function getNickname(sendFrom: SendFrom) {
sendFrom === SendFrom.User ? props.user.nickname : '公众号'; return sendFrom === SendFrom.User ? props.user.nickname : '公众号';
}
</script> </script>
<template> <template>
<div class="execution" v-for="item in props.list" :key="item.id"> <div class="execution" v-for="item in props.list" :key="item.id">

View File

@@ -60,7 +60,7 @@ onMounted(async () => {
}); });
// 执行发送 // 执行发送
const sendMsg = async () => { async function sendMsg() {
if (!unref(reply)) { if (!unref(reply)) {
return; return;
} }
@@ -85,14 +85,14 @@ const sendMsg = async () => {
// 发送后清空数据 // 发送后清空数据
replySelectRef.value?.clear(); replySelectRef.value?.clear();
}; }
const loadMore = () => { function loadMore() {
queryParams.pageNo++; queryParams.pageNo++;
getPage(queryParams, null); getPage(queryParams, null);
}; }
const getPage = async (page: any, params: any = null) => { async function getPage(page: any, params: any = null) {
loading.value = true; loading.value = true;
const dataTemp = await getMessagePage( const dataTemp = await getMessagePage(
Object.assign( Object.assign(
@@ -128,19 +128,19 @@ const getPage = async (page: any, params: any = null) => {
msgDivRef.value.scrollHeight - scrollHeight - 100; msgDivRef.value.scrollHeight - scrollHeight - 100;
} }
} }
}; }
const refreshChange = () => { function refreshChange() {
getPage(queryParams); getPage(queryParams);
}; }
/** 定位到消息底部 */ /** 定位到消息底部 */
const scrollToBottom = async () => { async function scrollToBottom() {
await nextTick(); await nextTick();
if (msgDivRef.value) { if (msgDivRef.value) {
msgDivRef.value.scrollTop = msgDivRef.value.scrollHeight; msgDivRef.value.scrollTop = msgDivRef.value.scrollHeight;
} }
}; }
</script> </script>
<template> <template>

View File

@@ -41,11 +41,12 @@ const uploadData = reactive({
type: 'image', type: 'image',
}); });
const beforeImageUpload = (rawFile: UploadRawFile) => function beforeImageUpload(rawFile: UploadRawFile) {
useBeforeUpload(UploadType.Image, 2)(rawFile); return useBeforeUpload(UploadType.Image, 2)(rawFile);
}
// 自定义上传请求 // 自定义上传请求
const customRequest = async (options: any) => { async function customRequest(options: any) {
const { file, onSuccess, onError } = options; const { file, onSuccess, onError } = options;
const formData = new FormData(); const formData = new FormData();
@@ -82,20 +83,20 @@ const customRequest = async (options: any) => {
message.error('上传失败,请重试'); message.error('上传失败,请重试');
onError(error); onError(error);
} }
}; }
const onDelete = () => { function onDelete() {
reply.value.mediaId = null; reply.value.mediaId = null;
reply.value.url = null; reply.value.url = null;
reply.value.name = null; reply.value.name = null;
}; }
const selectMaterial = (item: any) => { function selectMaterial(item: any) {
showDialog.value = false; showDialog.value = false;
reply.value.mediaId = item.mediaId; reply.value.mediaId = item.mediaId;
reply.value.url = item.url; reply.value.url = item.url;
reply.value.name = item.name; reply.value.name = item.name;
}; }
</script> </script>
<template> <template>

View File

@@ -49,11 +49,12 @@ const uploadData = reactive({
type: 'thumb', // 音乐类型为thumb type: 'thumb', // 音乐类型为thumb
}); });
const beforeImageUpload = (rawFile: UploadRawFile) => function beforeImageUpload(rawFile: UploadRawFile) {
useBeforeUpload(UploadType.Image, 2)(rawFile); return useBeforeUpload(UploadType.Image, 2)(rawFile);
}
// 自定义上传请求 // 自定义上传请求
const customRequest = async (options: any) => { async function customRequest(options: any) {
const { file, onSuccess, onError } = options; const { file, onSuccess, onError } = options;
const formData = new FormData(); const formData = new FormData();
@@ -90,13 +91,13 @@ const customRequest = async (options: any) => {
message.error('上传失败,请重试'); message.error('上传失败,请重试');
onError(error); onError(error);
} }
}; }
const selectMaterial = (item: any) => { function selectMaterial(item: any) {
showDialog.value = false; showDialog.value = false;
reply.value.thumbMediaId = item.mediaId; reply.value.thumbMediaId = item.mediaId;
reply.value.thumbMediaUrl = item.url; reply.value.thumbMediaUrl = item.url;
}; }
</script> </script>
<template> <template>

View File

@@ -30,14 +30,14 @@ const reply = computed<Reply>({
const showDialog = ref(false); const showDialog = ref(false);
const selectMaterial = (item: any) => { function selectMaterial(item: any) {
showDialog.value = false; showDialog.value = false;
reply.value.articles = item.content.newsItem; reply.value.articles = item.content.newsItem;
}; }
const onDelete = () => { function onDelete() {
reply.value.articles = []; reply.value.articles = [];
}; }
</script> </script>
<template> <template>

View File

@@ -50,11 +50,12 @@ const uploadData = reactive({
type: 'video', type: 'video',
}); });
const beforeVideoUpload = (rawFile: UploadRawFile) => function beforeVideoUpload(rawFile: UploadRawFile) {
useBeforeUpload(UploadType.Video, 10)(rawFile); return useBeforeUpload(UploadType.Video, 10)(rawFile);
}
// 自定义上传请求 // 自定义上传请求
const customRequest = async (options: any) => { async function customRequest(options: any) {
const { file, onSuccess, onError } = options; const { file, onSuccess, onError } = options;
const formData = new FormData(); const formData = new FormData();
@@ -91,10 +92,10 @@ const customRequest = async (options: any) => {
message.error('上传失败,请重试'); message.error('上传失败,请重试');
onError(error); onError(error);
} }
}; }
/** 选择素材后设置 */ /** 选择素材后设置 */
const selectMaterial = (item: any) => { function selectMaterial(item: any) {
showDialog.value = false; showDialog.value = false;
reply.value.mediaId = item.mediaId; reply.value.mediaId = item.mediaId;
@@ -108,7 +109,7 @@ const selectMaterial = (item: any) => {
if (item.introduction) { if (item.introduction) {
reply.value.description = item.introduction || ''; reply.value.description = item.introduction || '';
} }
}; }
</script> </script>
<template> <template>

View File

@@ -42,11 +42,12 @@ const uploadData = reactive({
type: 'voice', type: 'voice',
}); });
const beforeVoiceUpload = (rawFile: UploadRawFile) => function beforeVoiceUpload(rawFile: UploadRawFile) {
useBeforeUpload(UploadType.Voice, 10)(rawFile); return useBeforeUpload(UploadType.Voice, 10)(rawFile);
}
// 自定义上传请求 // 自定义上传请求
const customRequest = async (options: any) => { async function customRequest(options: any) {
const { file, onSuccess, onError } = options; const { file, onSuccess, onError } = options;
const formData = new FormData(); const formData = new FormData();
@@ -83,20 +84,20 @@ const customRequest = async (options: any) => {
message.error('上传失败,请重试'); message.error('上传失败,请重试');
onError(error); onError(error);
} }
}; }
const onDelete = () => { function onDelete() {
reply.value.mediaId = null; reply.value.mediaId = null;
reply.value.url = null; reply.value.url = null;
reply.value.name = null; reply.value.name = null;
}; }
const selectMaterial = (item: Reply) => { function selectMaterial(item: Reply) {
showDialog.value = false; showDialog.value = false;
reply.value.mediaId = item.mediaId; reply.value.mediaId = item.mediaId;
reply.value.url = item.url; reply.value.url = item.url;
reply.value.name = item.name; reply.value.name = item.name;
}; }
</script> </script>
<template> <template>

View File

@@ -73,9 +73,9 @@ watch(
); );
/** 清除除了`type`, `accountId`的字段 */ /** 清除除了`type`, `accountId`的字段 */
const clear = () => { function clear() {
reply.value = createEmptyReply(reply); reply.value = createEmptyReply(reply);
}; }
defineExpose({ defineExpose({
clear, clear,

View File

@@ -16,9 +16,9 @@ const props = defineProps<{
const dialogVideo = ref(false); const dialogVideo = ref(false);
const playVideo = () => { function playVideo() {
dialogVideo.value = true; dialogVideo.value = true;
}; }
</script> </script>
<template> <template>

View File

@@ -24,7 +24,7 @@ const playing = ref(false);
const duration = ref<number>(); const duration = ref<number>();
/** 处理点击,播放或暂停 */ /** 处理点击,播放或暂停 */
const playVoice = () => { function playVoice() {
// 情况一:未初始化,则创建 BenzAMRRecorder // 情况一:未初始化,则创建 BenzAMRRecorder
if (amr.value === undefined) { if (amr.value === undefined) {
amrInit(); amrInit();
@@ -36,10 +36,10 @@ const playVoice = () => {
} else { } else {
amrPlay(); amrPlay();
} }
}; }
/** 音频初始化 */ /** 音频初始化 */
const amrInit = () => { function amrInit() {
amr.value = new BenzAMRRecorder(); amr.value = new BenzAMRRecorder();
// 设置播放 // 设置播放
amr.value.initWithUrl(props.url).then(() => { amr.value.initWithUrl(props.url).then(() => {
@@ -50,19 +50,19 @@ const amrInit = () => {
amr.value.onEnded(() => { amr.value.onEnded(() => {
playing.value = false; playing.value = false;
}); });
}; }
/** 音频播放 */ /** 音频播放 */
const amrPlay = () => { function amrPlay() {
playing.value = true; playing.value = true;
amr.value.play(); amr.value.play();
}; }
/** 音频暂停 */ /** 音频暂停 */
const amrStop = () => { function amrStop() {
playing.value = false; playing.value = false;
amr.value.stop(); amr.value.stop();
}; }
</script> </script>
<template> <template>

View File

@@ -38,7 +38,7 @@ const onBeforeUpload =
props.type === UploadType.Image ? beforeImageUpload : beforeVoiceUpload; props.type === UploadType.Image ? beforeImageUpload : beforeVoiceUpload;
/** 自定义上传 */ /** 自定义上传 */
const customRequest: UploadProps['customRequest'] = async (options) => { const customRequest: UploadProps['customRequest'] = async function (options) {
const { file, onError, onSuccess } = options; const { file, onError, onSuccess } = options;
const formData = new FormData(); const formData = new FormData();

View File

@@ -42,9 +42,9 @@ const uploadRules = {
title: [{ message: '请输入标题', required: true, trigger: 'blur' } as const], title: [{ message: '请输入标题', required: true, trigger: 'blur' } as const],
}; };
const handleCancel = () => { function handleCancel() {
emit('update:open', false); emit('update:open', false);
}; }
const fileList = ref<any[]>([]); const fileList = ref<any[]>([]);
@@ -58,17 +58,17 @@ const uploadData: UploadData = reactive({
const uploadFormRef = ref<FormInstance | null>(null); const uploadFormRef = ref<FormInstance | null>(null);
const uploadVideoRef = ref<any>(null); const uploadVideoRef = ref<any>(null);
const submitVideo = async () => { async function submitVideo() {
try { try {
await uploadFormRef.value?.validate(); await uploadFormRef.value?.validate();
uploadVideoRef.value?.submit(); uploadVideoRef.value?.submit();
} catch { } catch {
// Validation failed // Validation failed
} }
}; }
/** 自定义上传 */ /** 自定义上传 */
const customRequest: UploadProps['customRequest'] = async (options) => { const customRequest: UploadProps['customRequest'] = async function (options) {
const { file, onError, onSuccess } = options; const { file, onError, onSuccess } = options;
const formData = new FormData(); const formData = new FormData();

View File

@@ -49,9 +49,9 @@ const columns = [
]; ];
// 下载文件 // 下载文件
const handleDownload = (url: string) => { function handleDownload(url: string) {
window.open(url, '_blank'); window.open(url, '_blank');
}; }
</script> </script>
<template> <template>

View File

@@ -41,9 +41,9 @@ const columns = [
}, },
]; ];
const handleDownload = (url: string) => { function handleDownload(url: string) {
window.open(url, '_blank'); window.open(url, '_blank');
}; }
</script> </script>
<template> <template>

View File

@@ -17,17 +17,23 @@ interface UploadData {
type: UploadType; type: UploadType;
} }
const beforeImageUpload: UploadProps['beforeUpload'] = ( const beforeImageUpload: UploadProps['beforeUpload'] = function (
rawFile: UploadRawFile, rawFile: UploadRawFile,
) => useBeforeUpload(UploadType.Image, 2)(rawFile); ) {
return useBeforeUpload(UploadType.Image, 2)(rawFile);
};
const beforeVoiceUpload: UploadProps['beforeUpload'] = ( const beforeVoiceUpload: UploadProps['beforeUpload'] = function (
rawFile: UploadRawFile, rawFile: UploadRawFile,
) => useBeforeUpload(UploadType.Voice, 2)(rawFile); ) {
return useBeforeUpload(UploadType.Voice, 2)(rawFile);
};
const beforeVideoUpload: UploadProps['beforeUpload'] = ( const beforeVideoUpload: UploadProps['beforeUpload'] = function (
rawFile: UploadRawFile, rawFile: UploadRawFile,
) => useBeforeUpload(UploadType.Video, 10)(rawFile); ) {
return useBeforeUpload(UploadType.Video, 10)(rawFile);
};
export { export {
beforeImageUpload, beforeImageUpload,

View File

@@ -47,15 +47,15 @@ const queryParams = reactive({
const showCreateVideo = ref(false); // 是否新建视频的弹窗 const showCreateVideo = ref(false); // 是否新建视频的弹窗
/** 侦听公众号变化 */ /** 侦听公众号变化 */
const onAccountChanged = (id: number) => { function onAccountChanged(id: number) {
accountId.value = id; accountId.value = id;
queryParams.accountId = id; queryParams.accountId = id;
queryParams.pageNo = 1; queryParams.pageNo = 1;
getList(); getList();
}; }
/** 查询列表 */ /** 查询列表 */
const getList = async () => { async function getList() {
loading.value = true; loading.value = true;
try { try {
const data = await MpMaterialApi.getMaterialPage({ const data = await MpMaterialApi.getMaterialPage({
@@ -67,25 +67,25 @@ const getList = async () => {
} finally { } finally {
loading.value = false; loading.value = false;
} }
}; }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { function handleQuery() {
queryParams.pageNo = 1; queryParams.pageNo = 1;
getList(); getList();
}; }
/** 处理 tab 切换 */ /** 处理 tab 切换 */
const onTabChange = () => { function onTabChange() {
// 提前清空数据,避免 tab 切换后显示垃圾数据 // 提前清空数据,避免 tab 切换后显示垃圾数据
list.value = []; list.value = [];
total.value = 0; total.value = 0;
// 从第一页开始查询 // 从第一页开始查询
handleQuery(); handleQuery();
}; }
/** 处理删除操作 */ /** 处理删除操作 */
const handleDelete = async (id: number) => { async function handleDelete(id: number) {
Modal.confirm({ Modal.confirm({
content: '此操作将永久删除该文件, 是否继续?', content: '此操作将永久删除该文件, 是否继续?',
title: '提示', title: '提示',
@@ -95,7 +95,7 @@ const handleDelete = async (id: number) => {
await getList(); await getList();
}, },
}); });
}; }
</script> </script>
<template> <template>

View File

@@ -18,7 +18,9 @@ const props = withDefaults(
loading?: boolean; loading?: boolean;
}>(), }>(),
{ {
list: () => [], list() {
return [];
},
loading: false, loading: false,
}, },
); );
@@ -33,7 +35,9 @@ const columns: TableColumnsType = [
dataIndex: 'createTime', dataIndex: 'createTime',
width: 180, width: 180,
align: 'center', align: 'center',
customRender: ({ record }) => formatDate2(record.createTime), customRender({ record }) {
return formatDate2(record.createTime);
},
}, },
{ {
title: '消息类型', title: '消息类型',