更改推送日志功能
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<Modal v-model="show" :mask-closable="false" width="680" title="推送设置" @on-visible-change="onVisibleChange">
|
<Modal v-model="show" :mask-closable="false" width="680" title="推送设置" @on-visible-change="onVisibleChange">
|
||||||
<div v-if="loading" class="loading-tip">加载中...</div>
|
<div v-if="loading" class="loading-tip">加载中...</div>
|
||||||
<Form v-else :label-width="110" class="push-setting-form">
|
<Form v-else ref="formRef" :model="form" :rules="rules" :label-width="110" autocomplete="off" class="push-setting-form">
|
||||||
<FormItem label="应用">
|
<FormItem label="应用">
|
||||||
<span>{{ appName || '-' }}</span>
|
<span>{{ appName || '-' }}</span>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -9,28 +9,24 @@
|
|||||||
<i-switch v-model="form.pushEnabled" />
|
<i-switch v-model="form.pushEnabled" />
|
||||||
<span class="switch-tip">{{ form.pushEnabled ? '开启' : '关闭' }}</span>
|
<span class="switch-tip">{{ form.pushEnabled ? '开启' : '关闭' }}</span>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="推送地址" required>
|
<FormItem label="推送地址" prop="pushBaseUrl">
|
||||||
<Input v-model="form.pushBaseUrl" placeholder="如 http://host/notice/api/base/(不含接口后缀)" />
|
<Input v-model="form.pushBaseUrl" placeholder="如 http://host/notice/api/base/(不含接口后缀)" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="订阅接口" required>
|
<FormItem label="订阅接口" prop="pushEventTypes">
|
||||||
<Select v-model="form.pushEventTypes" multiple filterable placeholder="请选择要订阅的接口(必选)">
|
<Select v-model="form.pushEventTypes" multiple filterable transfer placeholder="请选择要订阅的接口(必选)">
|
||||||
<Option v-for="opt in interfaceOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</Option>
|
<Option v-for="opt in interfaceOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</Option>
|
||||||
</Select>
|
</Select>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="关联学校">
|
<FormItem label="关联学校">
|
||||||
<Select v-model="form.pushSchoolIds" multiple filterable placeholder="留空=全局(监听所有学校变化)">
|
<Select v-model="form.pushSchoolIds" multiple filterable transfer placeholder="留空=全局(监听所有学校变化)">
|
||||||
<Option v-for="opt in schoolOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</Option>
|
<Option v-for="opt in schoolOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</Option>
|
||||||
</Select>
|
</Select>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="推送角色">
|
<FormItem label="推送角色">
|
||||||
<Select v-model="form.pushRoleIds" multiple filterable placeholder="留空=全部角色">
|
<Select v-model="form.pushRoleIds" multiple filterable transfer placeholder="留空=全部角色">
|
||||||
<Option v-for="opt in roleOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</Option>
|
<Option v-for="opt in roleOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</Option>
|
||||||
</Select>
|
</Select>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="签名密钥">
|
|
||||||
<Input v-model="form.pushSecret" type="password" password placeholder="留空=复用应用密钥 appSecret;清空则改为复用" />
|
|
||||||
<p class="field-tip">不修改请保持原值;清空输入框表示改用应用密钥。</p>
|
|
||||||
</FormItem>
|
|
||||||
</Form>
|
</Form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="push-setting-footer">
|
<div class="push-setting-footer">
|
||||||
@@ -67,6 +63,8 @@ const show = computed({
|
|||||||
set: val => emit('update:modelValue', val),
|
set: val => emit('update:modelValue', val),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const formRef = ref<any>(null);
|
||||||
|
|
||||||
const interfaceOptions = [
|
const interfaceOptions = [
|
||||||
{ value: 'group/AddGroup', label: '添加组' },
|
{ value: 'group/AddGroup', label: '添加组' },
|
||||||
{ value: 'group/UpdateGroup', label: '更新组' },
|
{ value: 'group/UpdateGroup', label: '更新组' },
|
||||||
@@ -86,6 +84,11 @@ const roleOptions = [
|
|||||||
{ value: 7, label: '管理员' },
|
{ value: 7, label: '管理员' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const rules = {
|
||||||
|
pushBaseUrl: [{ required: true, message: '请填写推送地址', trigger: 'blur' }],
|
||||||
|
pushEventTypes: [{ required: true, type: 'array', message: '请至少选择一个订阅接口', trigger: 'change' }],
|
||||||
|
};
|
||||||
|
|
||||||
const schoolOptions = ref<{ value: number; label: string }[]>([]);
|
const schoolOptions = ref<{ value: number; label: string }[]>([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const saving = ref(false);
|
const saving = ref(false);
|
||||||
@@ -98,9 +101,7 @@ const form = ref({
|
|||||||
pushEventTypes: [] as string[],
|
pushEventTypes: [] as string[],
|
||||||
pushSchoolIds: [] as number[],
|
pushSchoolIds: [] as number[],
|
||||||
pushRoleIds: [] as number[],
|
pushRoleIds: [] as number[],
|
||||||
pushSecret: '',
|
|
||||||
});
|
});
|
||||||
const originalSecret = ref<string>('');
|
|
||||||
|
|
||||||
function flattenSchools(nodes: any[], prefix = ''): { value: number; label: string }[] {
|
function flattenSchools(nodes: any[], prefix = ''): { value: number; label: string }[] {
|
||||||
const out: { value: number; label: string }[] = [];
|
const out: { value: number; label: string }[] = [];
|
||||||
@@ -140,8 +141,6 @@ async function loadSettings() {
|
|||||||
form.value.pushRoleIds = d.pushRoleIds
|
form.value.pushRoleIds = d.pushRoleIds
|
||||||
? String(d.pushRoleIds).split(',').filter(Boolean).map(Number)
|
? String(d.pushRoleIds).split(',').filter(Boolean).map(Number)
|
||||||
: [];
|
: [];
|
||||||
form.value.pushSecret = d.pushSecret || '';
|
|
||||||
originalSecret.value = d.pushSecret || '';
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
Message.error(e?.message || '加载推送设置失败');
|
Message.error(e?.message || '加载推送设置失败');
|
||||||
} finally {
|
} finally {
|
||||||
@@ -163,15 +162,10 @@ function onVisibleChange(val: boolean) {
|
|||||||
if (!val) emit('update:modelValue', false);
|
if (!val) emit('update:modelValue', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSave() {
|
async function handleSave() {
|
||||||
if (!form.value.pushBaseUrl.trim()) {
|
const valid = await formRef.value?.validate();
|
||||||
Message.error('请填写推送地址');
|
if (!valid) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!form.value.pushEventTypes.length) {
|
|
||||||
Message.error('请至少选择一个订阅接口');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
saving.value = true;
|
saving.value = true;
|
||||||
const data: any = {
|
const data: any = {
|
||||||
pushBaseUrl: form.value.pushBaseUrl.trim(),
|
pushBaseUrl: form.value.pushBaseUrl.trim(),
|
||||||
@@ -179,8 +173,8 @@ function handleSave() {
|
|||||||
pushEventTypes: form.value.pushEventTypes.join(','),
|
pushEventTypes: form.value.pushEventTypes.join(','),
|
||||||
pushSchoolIds: form.value.pushSchoolIds.length ? form.value.pushSchoolIds.join(',') : null,
|
pushSchoolIds: form.value.pushSchoolIds.length ? form.value.pushSchoolIds.join(',') : null,
|
||||||
pushRoleIds: form.value.pushRoleIds.length ? form.value.pushRoleIds.join(',') : null,
|
pushRoleIds: form.value.pushRoleIds.length ? form.value.pushRoleIds.join(',') : null,
|
||||||
// 与原值相同=不修改(传 null 保留);清空=复用应用密钥(传 "")
|
// 清空单独签名密钥,统一复用应用 appSecret
|
||||||
pushSecret: form.value.pushSecret === originalSecret.value ? null : form.value.pushSecret,
|
pushSecret: '',
|
||||||
};
|
};
|
||||||
(Apis as any)
|
(Apis as any)
|
||||||
.AppSettings.savePushSetting({
|
.AppSettings.savePushSetting({
|
||||||
@@ -243,12 +237,6 @@ function doSync(interfacePath: string, loadingRef: Ref<boolean>, name: string):
|
|||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
color: #808695;
|
color: #808695;
|
||||||
}
|
}
|
||||||
|
|
||||||
.field-tip {
|
|
||||||
margin: 4px 0 0;
|
|
||||||
color: #999;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-tip {
|
.loading-tip {
|
||||||
@@ -270,6 +258,7 @@ function doSync(interfacePath: string, loadingRef: Ref<boolean>, name: string):
|
|||||||
.footer-right {
|
.footer-right {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
<div class="main-wrapper">
|
<div class="main-wrapper">
|
||||||
<div class="main-container">
|
<div class="main-container">
|
||||||
<div class="search-wrap fix">
|
<div class="search-wrap fix">
|
||||||
<Select v-model="dataParams.appKey" class="ml-12" clearable filterable placeholder="应用" style="width: 180px"
|
<Select v-model="dataParams.appKey" class="ml-12" clearable filterable placeholder="应用"
|
||||||
@on-change="handleSearch">
|
style="width: 180px" @on-change="handleSearch">
|
||||||
<Option v-for="opt in appOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</Option>
|
<Option v-for="opt in appOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</Option>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ const tableHeight = ref($utils.useTableHeight({ isOperat: false, isPage: true, i
|
|||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ type: 'index', title: '序号', width: 70, align: 'center' },
|
{ type: 'index', title: '序号', width: 70, align: 'center' },
|
||||||
{ title: '应用', key: 'appName', width: 160, ellipsis: true, tooltip: true },
|
{ title: '应用', key: 'appName', ellipsis: true, tooltip: true },
|
||||||
{
|
{
|
||||||
title: '接口',
|
title: '接口',
|
||||||
key: 'interfaceLabel',
|
key: 'interfaceLabel',
|
||||||
@@ -138,7 +138,7 @@ const columns = [
|
|||||||
{
|
{
|
||||||
title: '日志时间',
|
title: '日志时间',
|
||||||
key: 'createdAt',
|
key: 'createdAt',
|
||||||
width: 170,
|
width: 200,
|
||||||
render: (h: any, { row }: any) =>
|
render: (h: any, { row }: any) =>
|
||||||
h('span', row.createdAt ? Utils.dateFormat(row.createdAt, 'yyyy-MM-dd HH:mm:ss') : '-'),
|
h('span', row.createdAt ? Utils.dateFormat(row.createdAt, 'yyyy-MM-dd HH:mm:ss') : '-'),
|
||||||
},
|
},
|
||||||
@@ -163,7 +163,7 @@ const columns = [
|
|||||||
align: 'left',
|
align: 'left',
|
||||||
render: (h: any, { row }: any) => {
|
render: (h: any, { row }: any) => {
|
||||||
const actions = [
|
const actions = [
|
||||||
h('a', { style: { color: '#577afb', marginRight: '12px' }, onClick: () => openDetail(row) }, '详情'),
|
h('a', { style: { color: '#577afb', marginRight: '12px' }, onClick: () => openDetail(row) }, '查看详情'),
|
||||||
];
|
];
|
||||||
if (row.success !== 1) {
|
if (row.success !== 1) {
|
||||||
actions.push(
|
actions.push(
|
||||||
@@ -211,6 +211,7 @@ loadApps();
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.search-wrap {
|
.search-wrap {
|
||||||
|
|
||||||
.ivu-select,
|
.ivu-select,
|
||||||
.ivu-input-wrapper,
|
.ivu-input-wrapper,
|
||||||
.ivu-date-picker {
|
.ivu-date-picker {
|
||||||
|
|||||||
Reference in New Issue
Block a user