Skip to content

Commit

Permalink
Merge pull request #874 from colinin/fix-multiple-issues
Browse files Browse the repository at this point in the history
Fix multiple issues
  • Loading branch information
colinin authored Sep 19, 2023
2 parents 099d2a8 + 755e4e4 commit 50a6de3
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 28 deletions.
1 change: 1 addition & 0 deletions apps/flutter/dev_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dependencies:
dio: ^5.2.0+1
flutter_easyloading: ^3.0.5
flutter_picker: ^2.1.0
flutter_logs: ^2.1.11
get: ^4.6.5
get_storage: ^2.1.1
rxdart: ^0.27.7
Expand Down
8 changes: 8 additions & 0 deletions apps/vue/src/api/messages/model/notificationsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ export enum NotificationType {
ServiceCallback = 30,
}

export enum NotificationContentType {
Text = 0,
Html = 1,
Markdown = 2,
Json = 3,
}

export enum NotificationSeverity {
Success = 0,
Info = 10,
Expand Down Expand Up @@ -37,6 +44,7 @@ export interface NotificationInfo {
lifetime: NotificationLifetime;
type: NotificationType;
severity: NotificationSeverity;
contentType: NotificationContentType;
}

export interface NotificationGroup {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@
<div>
<div class="description" v-if="item.description">
<a-typography-paragraph
@click="handleContentClick(item)"
style="width: 100%; margin-bottom: 0 !important"
:style="{ cursor: isContentClickable ? 'pointer' : '' }"
:ellipsis="
$props.descRows && $props.descRows > 0
? { rows: $props.descRows, tooltip: !!item.description }
: false
"
:content="item.description"
:content="getContent(item)"
/>
</div>
<div class="datetime">
Expand All @@ -61,6 +63,7 @@
import { ListItem } from './data';
import { useDesign } from '/@/hooks/web/useDesign';
import { List, Avatar, Tag, Typography } from 'ant-design-vue';
import { NotificationContentType } from "/@/api/messages/model/notificationsModel";
import { isNumber } from '/@/utils/is';
export default defineComponent({
components: {
Expand Down Expand Up @@ -95,6 +98,9 @@
onTitleClick: {
type: Function as PropType<(Recordable) => void>,
},
onContentClick: {
type: Function as PropType<(Recordable) => void>,
},
},
emits: ['update:currentPage'],
setup(props, { emit }) {
Expand All @@ -103,22 +109,38 @@
const getData = computed(() => {
const { pageSize, list } = props;
if (pageSize === false) return [];
let size = isNumber(pageSize) ? pageSize : 5;
let size = isNumber(pageSize) ? pageSize : 10;
return list.slice(size * (unref(current) - 1), size * unref(current));
});
const getContent = computed(() => {
return (item: ListItem) => {
switch (item.contentType) {
default:
case NotificationContentType.Text:
return item.description;
case NotificationContentType.Html:
case NotificationContentType.Json:
case NotificationContentType.Markdown:
return item.title;
}
};
});
watch(
() => props.currentPage,
(v) => {
current.value = v;
},
);
const isTitleClickable = computed(() => !!props.onTitleClick);
const isContentClickable = computed(() => !!props.onContentClick);
const getPagination = computed(() => {
const { list, pageSize } = props;
if (pageSize > 0 && list && list.length > pageSize) {
if (pageSize === false) return false;
const size = isNumber(pageSize) ? pageSize : 5;
if (size > 0 && list && list.length > size) {
return {
total: list.length,
pageSize,
pageSize: size,
//size: 'small',
current: unref(current),
onChange(page) {
Expand All @@ -135,7 +157,20 @@
props.onTitleClick && props.onTitleClick(item);
}
return { prefixCls, getPagination, getData, handleTitleClick, isTitleClickable };
function handleContentClick(item: ListItem) {
props.onContentClick && props.onContentClick(item);
}
return {
prefixCls,
getPagination,
getData,
getContent,
handleTitleClick,
isTitleClickable,
handleContentClick,
isContentClickable,
};
},
});
</script>
Expand Down
3 changes: 3 additions & 0 deletions apps/vue/src/layouts/default/header/components/notify/data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { NotificationContentType } from "/@/api/messages/model/notificationsModel";

export interface ListItem {
id: string;
avatar: string;
Expand All @@ -12,6 +14,7 @@ export interface ListItem {
clickClose?: boolean;
extra?: string;
color?: string;
contentType?: NotificationContentType;
}

export interface TabItem {
Expand Down
63 changes: 51 additions & 12 deletions apps/vue/src/layouts/default/header/components/notify/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
<template>
<div :class="prefixCls">
<Popover title="" trigger="click" :overlayClassName="`${prefixCls}__overlay`">
<Badge :count="count" dot :numberStyle="numberStyle">
<BellOutlined @click="showDrawer" />
</Badge>
<Drawer v-model:visible="open" title="" :class="`${prefixCls}__overlay`" placement="right" :closable="false">
<Tabs>
<TabPane :key="notifierRef.key" :tab="notifierRef.name">
<NoticeList :list="notifierRef.list" @title-click="readNotifer" @content-click="handleShowNotifications" />
</TabPane>
<TabPane :key="messageRef.key" :tab="messageRef.name">
<NoticeList :list="messageRef.list">
<template #footer>
<ButtonGroup style="width: 100%">
<Button
:disabled="messageRef.list.length === 0"
style="width: 50%"
type="link"
@click="clearMessage"
>清空消息</Button
>
<Button style="width: 50%" type="link" @click="handleShowMessages"
>查看更多</Button
>
</ButtonGroup>
</template>
</NoticeList>
</TabPane>
<TabPane :key="tasksRef.key" :tab="tasksRef.name">
<NoticeList :list="tasksRef.list" />
</TabPane>
</Tabs>
</Drawer>
<!-- <Popover title="" trigger="click" :overlayClassName="`${prefixCls}__overlay`">
<Badge :count="count" dot :numberStyle="numberStyle">
<BellOutlined />
</Badge>
Expand Down Expand Up @@ -32,12 +63,12 @@
</TabPane>
</Tabs>
</template>
</Popover>
</Popover> -->
</div>
</template>
<script lang="ts">
import { computed, defineComponent } from 'vue';
import { Button, Popover, Tabs, Badge } from 'ant-design-vue';
import { computed, defineComponent, ref } from 'vue';
import { Button, Drawer, Popover, Tabs, Badge } from 'ant-design-vue';
import { BellOutlined } from '@ant-design/icons-vue';
import NoticeList from './NoticeList.vue';
import { useGo } from '/@/hooks/web/usePage';
Expand All @@ -50,6 +81,7 @@
components: {
Button,
ButtonGroup: Button.Group,
Drawer,
Popover,
BellOutlined,
Tabs,
Expand All @@ -60,6 +92,7 @@
setup() {
const { prefixCls } = useDesign('header-notify');
const go = useGo();
const open = ref(false);
const { tasksRef } = useTasks();
const { messageRef, clearMessage } = useMessages();
const { notifierRef, readNotifer } = useNotifications();
Expand All @@ -78,16 +111,30 @@
go('/sys/chat?type=chat-message');
}
function handleShowNotifications() {
console.log('handleShowNotifications');
open.value = false;
go('/messages/notifications');
}
function showDrawer() {
console.log('showDrawer');
open.value = true;
}
return {
prefixCls,
count,
numberStyle: {},
open,
showDrawer,
notifierRef,
readNotifer,
messageRef,
clearMessage,
tasksRef,
handleShowMessages,
handleShowNotifications,
};
},
});
Expand All @@ -98,14 +145,6 @@
.@{prefix-cls} {
padding-top: 2px;
&__overlay {
max-width: 360px;
}
.ant-tabs-content {
width: 300px;
}
.ant-badge {
font-size: 18px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
NotificationInfo,
NotificationSeverity,
NotificationReadState,
NotificationContentType,
} from '/@/api/messages/model/notificationsModel';
import { formatToDateTime } from '/@/utils/dateUtil';
import { TabItem, ListItem as Notification } from './data';
Expand Down Expand Up @@ -79,6 +80,7 @@ export function useNotifications() {
extra: description,
datetime: formatToDateTime(notificationInfo.creationTime, 'YYYY-MM-DD HH:mm:ss'),
type: String(notificationInfo.type),
contentType: notificationInfo.contentType,
};

if (notifer && notificationInfo.type !== NotificationType.ServiceCallback) {
Expand All @@ -95,38 +97,48 @@ export function useNotifications() {


function _notification(notifier: Notification, severity: NotificationSeverity) {
let message = notifier.description;
switch (notifier.contentType) {
default:
case NotificationContentType.Text:
message = notifier.description;
case NotificationContentType.Html:
case NotificationContentType.Json:
case NotificationContentType.Markdown:
message = notifier.title;
}
switch (severity) {
case NotificationSeverity.Error:
case NotificationSeverity.Fatal:
notifier.color = 'red';
notifier.avatar = errorAvatar;
notification['error']({
message: notifier.title,
description: notifier.description,
description: message,
});
break;
case NotificationSeverity.Warn:
notifier.color = 'gold';
notifier.avatar = warningAvatar;
notification['warning']({
message: notifier.title,
description: notifier.description,
description: message,
});
break;
case NotificationSeverity.Info:
notifier.color = 'gold';
notifier.avatar = infoAvatar;
notification['info']({
message: notifier.title,
description: notifier.description,
description: message,
});
break;
case NotificationSeverity.Success:
notifier.color = 'green';
notifier.avatar = successAvatar;
notification['success']({
message: notifier.title,
description: notifier.description,
description: message,
});
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,15 @@ private void ConfigureUrls(IConfiguration configuration)
{
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
options.Applications["STS"].RootUrl = configuration["App:StsUrl"];
var applicationConfiguration = configuration.GetSection("App:Urls:Applications");
foreach (var appConfig in applicationConfiguration.GetChildren())
{
options.Applications[appConfig.Key].RootUrl = appConfig["RootUrl"];
foreach (var urlsConfig in appConfig.GetSection("Urls").GetChildren())
{
options.Applications[appConfig.Key].Urls[urlsConfig.Key] = urlsConfig.Value;
}
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
app.UseCors(DefaultCorsPolicyName);
// 认证
app.UseAuthentication();
// IDS与JWT不匹配可能造成鉴权错误
// TODO: abp在某个更新版本建议移除此中间价
app.UseAbpClaimsMap();
// 多租户
app.UseMultiTenancy();
// 授权
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,28 @@
"tag": "AuthServer.Admin"
},
"App": {
"SelfUrl": "http://127.0.0.1:30015/",
"StsUrl": "http://127.0.0.1:44385/",
"CorsOrigins": "http://127.0.0.1:3100"
"CorsOrigins": "http://127.0.0.1:3100",
"Urls": {
"Applications": {
"MVC": {
"RootUrl": "http://127.0.0.1:44385/",
"Urls": {
"Abp.Account.EmailConfirm": "Account/EmailConfirm",
"Abp.Account.EmailVerifyLogin": "Account/VerifyCode"
}
},
"STS": {
"RootUrl": "http://127.0.0.1:44385/"
},
"VueVbenAdmin": {
"RootUrl": "http://127.0.0.1:3100/",
"Urls": {
"Abp.Account.EmailConfirm": "account/email-confirm",
"Abp.Account.EmailVerifyLogin": "account/verify-code"
}
}
}
}
},
"Auditing": {
"AllEntitiesSelector": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
app.UseCors(DefaultCorsPolicyName);
// 认证
app.UseAuthentication();
// IDS与JWT不匹配可能造成鉴权错误
// TODO: abp在某个更新版本建议移除此中间价
app.UseAbpClaimsMap();
// jwt
app.UseJwtTokenMiddleware();
// 多租户
Expand Down
Loading

0 comments on commit 50a6de3

Please sign in to comment.