Skip to content

Commit

Permalink
[Improve] notify message improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfboys committed Aug 5, 2024
1 parent fba5d75 commit 45437b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ public void onFinish(PipeSnapshot snapshot, BuildResult result) {
app.getJobName().concat(" release failed"),
Utils.stringifyException(snapshot.error().exception()),
NoticeType.EXCEPTION);
messageService.save(message);
app.setRelease(ReleaseState.FAILED.get());
app.setOptionState(OptionState.NONE.getValue());
app.setBuild(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,17 @@
</div>
</template>
<script lang="ts">
import { computed, defineComponent, ref, unref, watch, h } from 'vue';
import { computed, defineComponent, ref, unref, h } from 'vue';
import { Popover, Tabs, Badge, Spin } from 'ant-design-vue';
import { BellOutlined } from '@ant-design/icons-vue';
import NoticeList from './NoticeList.vue';
import { useDesign } from '/@/hooks/web/useDesign';
import { fetchNotify, fetchNotifyDelete } from '/@/api/system/notify';
import { NotifyItem } from '/@/api/system/model/notifyModel';
import { useWebSocket } from '@vueuse/core';
import { useUserStoreWithOut } from '/@/store/modules/user';
import { useMessage } from '/@/hooks/web/useMessage';
import { isObject } from '/@/utils/is';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
export interface TabItem {
key: number;
name: string;
Expand All @@ -58,8 +55,7 @@
components: { Popover, BellOutlined, Tabs, TabPane: Tabs.TabPane, Badge, NoticeList, Spin },
setup() {
const { prefixCls } = useDesign('header-notify');
const userStore = useUserStoreWithOut();
const { createMessage, createConfirm } = useMessage();
const { createConfirm } = useMessage();
const notifyType = ref(1);
const currentPage = ref(1);
const notifyVisible = ref(false);
Expand All @@ -75,6 +71,7 @@
}
return count;
});
/* View notification messages */
async function handleNotifyInfo(record: NotifyItem) {
notifyVisible.value = false;
Expand Down Expand Up @@ -112,6 +109,7 @@
notifyLoading.value = false;
}
}
/* Process notification message data */
function handleNotifyMessage(type: number, data: NotifyItem[]) {
/* The abnormal alarm */
Expand All @@ -122,36 +120,8 @@
}
}
const wbSocketUrl = `${window.location.origin}${
import.meta.env.VITE_GLOB_API_URL + (import.meta.env.VITE_GLOB_API_URL_PREFIX || '')
}/websocket/${userStore.getUserInfo.userId}`;
setInterval(() => getNotifyList(1), 5000);
const { data } = useWebSocket(wbSocketUrl.replace(/http/, 'ws'), {
autoReconnect: {
retries: 3,
delay: 1000,
onFailed() {
createMessage.warning('Message server connection failed!');
},
},
});
watch([data, currentPage], ([newData]: [NotifyItem], [newPage]) => {
if (newData && isObject(newData)) {
/* The abnormal alarm */
if (unref(notifyType) === 1) {
listData.value[0].list.push(newData);
} else {
listData.value[1].list.push(newData);
}
handleNotifyInfo(newData);
}
if (newPage) {
getNotifyList(unref(notifyType));
}
});
getNotifyList(1);
getNotifyList(2);
return {
prefixCls,
listData,
Expand Down

0 comments on commit 45437b1

Please sign in to comment.