This commit is contained in:
parent
8ac08ece08
commit
1cfc9e0841
@ -9,3 +9,7 @@ export const ListPushers = (query) => {
|
||||
export const AddPusher = (opt)=>{
|
||||
return pushers.post(opt)
|
||||
}
|
||||
|
||||
export const ListPusherOptions = ()=>{
|
||||
return pushers.get('options')
|
||||
}
|
@ -1,10 +1,4 @@
|
||||
export const PUSHER = {
|
||||
ANPUSHER: 1,
|
||||
EMAIL:2
|
||||
}
|
||||
|
||||
export const WEBSITE_OPTIONS = [
|
||||
{
|
||||
label: 'anPush',
|
||||
value: PUSHER.ANPUSHER
|
||||
}
|
||||
]
|
@ -13,10 +13,7 @@
|
||||
<a-table :dataSource="data.list" :columns="columns" :pagination="false">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'type'">
|
||||
<span>{{WEBSITE_OPTIONS.find(w => w.value === record.type).label}}</span>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'updatedAt'">
|
||||
<span>{{moment(record.updatedAt).format('YYYY-MM-DD HH:mm:ss')}}</span>
|
||||
<span>{{options.find(opt => opt.type === record.type).title}}</span>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'option'">
|
||||
<span>{{record.option}}</span>
|
||||
@ -30,21 +27,25 @@
|
||||
<a-modal v-model:open="addModal.visible" title="添加推送通知" @ok="handleOk" >
|
||||
<a-spin :spinning="addModal.loading" :indicator="indicator">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="addModal.data"
|
||||
:label-col="{ span: 4 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
autocomplete="off"
|
||||
@finish="closeAddModal"
|
||||
@finishFailed="closeAddModal"
|
||||
@finish="cleanAddModal"
|
||||
@finishFailed="cleanAddModal"
|
||||
>
|
||||
<a-form-item label="名称" name="name" :rules="[{ required: true, message: '请填写推送名称' }]">
|
||||
<a-input v-model:value="addModal.data.name" />
|
||||
</a-form-item>
|
||||
<a-form-item label="token" name="option.token" :rules="[{ required: false, message: '请填写token' }]">
|
||||
<a-input v-model:value="addModal.data.option.token" />
|
||||
<a-form-item label="类型" name="type" :rules="[{ required: true, message: '请选择推送类型' }]">
|
||||
<a-select v-model:value="addModal.data.type" @select="onSelectType">
|
||||
<a-select-option v-for="opt in options" :value="opt.type">{{opt.title}}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="channel" name="option.channel" :rules="[{ required: false, message: '请填写channel' }]">
|
||||
<a-input v-model:value="addModal.data.option.channel" />
|
||||
<a-form-item v-for="item in addModal.formItems" :name="'option.' + item.param" :label="item.param">
|
||||
<a-input v-if="item.type === 'string'" v-model:value="addModal.data.option[item.param]"></a-input>
|
||||
<a-input-number v-else-if="item.type.startsWith('int')" v-model:value="addModal.data.option[item.param]"></a-input-number>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注" name="remark">
|
||||
<a-textarea v-model:value="addModal.data.remark" />
|
||||
@ -56,17 +57,17 @@
|
||||
<script setup>
|
||||
|
||||
import {h, onMounted, reactive, ref} from "vue";
|
||||
import {WEBSITE_OPTIONS} from "@/constants/website.js";
|
||||
import moment from "moment/moment.js";
|
||||
import {LoadingOutlined} from "@ant-design/icons-vue";
|
||||
import {AddPusher, ListPushers} from "@/api/pusher.js";
|
||||
import {PUSHER} from "@/constants/pusher.js";
|
||||
import {AddPusher, ListPusherOptions, ListPushers} from "@/api/pusher.js";
|
||||
import {message} from "ant-design-vue";
|
||||
import {clone} from "radash";
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
onMounted(()=>{
|
||||
list()
|
||||
listOptions()
|
||||
})
|
||||
|
||||
|
||||
@ -100,39 +101,46 @@ const list = ()=>{
|
||||
const addModal = reactive({
|
||||
visible: false,
|
||||
data: {
|
||||
type:PUSHER.ANPUSHER,
|
||||
type:null,
|
||||
name:'',
|
||||
remark:'',
|
||||
option:{
|
||||
token:'',
|
||||
channel: ''
|
||||
}
|
||||
option: {}
|
||||
},
|
||||
formItems: [],
|
||||
loading: false
|
||||
})
|
||||
|
||||
const closeAddModal = ()=>{
|
||||
addModal.visible = false
|
||||
const formRef = ref()
|
||||
const cleanAddModal=()=>{
|
||||
addModal.data = {
|
||||
type:PUSHER.ANPUSHER,
|
||||
type:null,
|
||||
name:'',
|
||||
remark:'',
|
||||
option:{
|
||||
token:'',
|
||||
channel: ''
|
||||
}
|
||||
option: {}
|
||||
}
|
||||
addModal.formItems = []
|
||||
formRef.value.clearValidate()
|
||||
}
|
||||
|
||||
|
||||
const onSelectType = (value, option)=>{
|
||||
addModal.formItems = options.value.find(o => o.type === value).formItems
|
||||
}
|
||||
|
||||
|
||||
const handleOk = ()=>{
|
||||
AddPusher(addModal.data).then(res=>{
|
||||
formRef.value.validateFields().then(res=>{
|
||||
const data = clone(addModal.data)
|
||||
data.option = JSON.stringify(data.option)
|
||||
AddPusher(data).then(res=>{
|
||||
message.success("添加成功")
|
||||
}).catch(err => {
|
||||
message.error("添加失败")
|
||||
console.log(err)
|
||||
}).finally(()=>{
|
||||
list(false)
|
||||
closeAddModal()
|
||||
cleanAddModal()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -141,22 +149,19 @@ const columns = [
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 300
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
width: 300
|
||||
},
|
||||
{
|
||||
title: '配置',
|
||||
dataIndex: 'option',
|
||||
key: 'option',
|
||||
},
|
||||
{
|
||||
title: '更新时间',
|
||||
dataIndex: 'updatedAt',
|
||||
key: 'updatedAt',
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'remark',
|
||||
@ -171,6 +176,18 @@ const indicator = h(LoadingOutlined, {
|
||||
spin: true,
|
||||
});
|
||||
|
||||
|
||||
const options = ref()
|
||||
|
||||
const listOptions = ()=>{
|
||||
ListPusherOptions().then(res=>{
|
||||
options.value = res.options
|
||||
}).catch(err=>{
|
||||
message.error("获取配置失败")
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
@ -29,6 +29,20 @@ export default defineConfig({
|
||||
secure: false,
|
||||
ws: true,
|
||||
},
|
||||
'/api/v1/push': {
|
||||
target: 'https://ht-dev.timerzz.com:20443/',
|
||||
// target: 'http://192.168.31.55:2280/',
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
ws: true,
|
||||
},
|
||||
'/api/v1/pushers': {
|
||||
target: 'https://ht-dev.timerzz.com:20443/',
|
||||
// target: 'http://192.168.31.55:2280/',
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
ws: true,
|
||||
},
|
||||
'/api/v1': {
|
||||
target: 'https://ht.timerzz.com:20443/',
|
||||
// target: 'http://192.168.31.55:2280/',
|
||||
|
Loading…
Reference in New Issue
Block a user