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:",
"fast-xml-parser": "catalog:",
"highlight.js": "catalog:",
"lodash": "^4.17.21",
"pinia": "catalog:",
"steady-xml": "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) {
return requestClient.get<PageResult<MpAccountApi.Account>>(

View File

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

View File

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

View File

@@ -18,13 +18,15 @@ const SendFrom = {
User: 1,
} as const;
const getAvatar = (sendFrom: number) =>
sendFrom === SendFrom.User
function getAvatar(sendFrom: number) {
return sendFrom === SendFrom.User
? props.user.avatar
: preferences.app.defaultAvatar;
}
const getNickname = (sendFrom: SendFrom) =>
sendFrom === SendFrom.User ? props.user.nickname : '公众号';
function getNickname(sendFrom: SendFrom) {
return sendFrom === SendFrom.User ? props.user.nickname : '公众号';
}
</script>
<template>
<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)) {
return;
}
@@ -85,14 +85,14 @@ const sendMsg = async () => {
// 发送后清空数据
replySelectRef.value?.clear();
};
}
const loadMore = () => {
function loadMore() {
queryParams.pageNo++;
getPage(queryParams, null);
};
}
const getPage = async (page: any, params: any = null) => {
async function getPage(page: any, params: any = null) {
loading.value = true;
const dataTemp = await getMessagePage(
Object.assign(
@@ -128,19 +128,19 @@ const getPage = async (page: any, params: any = null) => {
msgDivRef.value.scrollHeight - scrollHeight - 100;
}
}
};
}
const refreshChange = () => {
function refreshChange() {
getPage(queryParams);
};
}
/** 定位到消息底部 */
const scrollToBottom = async () => {
async function scrollToBottom() {
await nextTick();
if (msgDivRef.value) {
msgDivRef.value.scrollTop = msgDivRef.value.scrollHeight;
}
};
}
</script>
<template>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -38,7 +38,7 @@ const onBeforeUpload =
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 formData = new FormData();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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