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