features: 1.公告国际化 2.默认菜单展开

This commit is contained in:
luoja 2025-03-17 11:33:55 +08:00
parent 3f8c6ad096
commit 2f57b5557d
8 changed files with 86 additions and 28 deletions

View File

@ -2,12 +2,12 @@ from server import app
from dash.dependencies import Input, Output, State
import feffery_antd_components as fac
from dash_components import Table
from uuid import uuid4
import dash
from dash import set_props
from dash_components import MessageManager
import time
from feffery_dash_utils.style_utils import style
from i18n import t__notification
def get_table_data():
@ -20,8 +20,8 @@ def get_table_data():
'create_by': announcement.name,
'enable': {
'checked': announcement.status,
'checkedChildren': '',
'unCheckedChildren': '',
'checkedChildren': 'open',
'unCheckedChildren': 'close',
'custom': announcement.announcement,
},
}
@ -39,17 +39,17 @@ def init_table(timeoutCount):
return [
fac.AntdModal(
id='announcement-table-add-modal',
title='新增公告',
title=t__notification('新增公告'),
renderFooter=True,
okClickClose=False,
),
Table(
id='announcement-table',
columns=[
{'title': '创建人', 'dataIndex': 'create_by', 'width': 'calc(100% / 5)'},
{'title': '内容', 'dataIndex': 'content', 'width': 'calc(100% * 2 / 5)'},
{'title': '发布时间', 'dataIndex': 'create_datetime', 'width': 'calc(100% / 5)'},
{'title': '启用', 'dataIndex': 'enable', 'renderOptions': {'renderType': 'switch'}, 'width': 'calc(100% / 5)'},
{'title': t__notification('创建人'), 'dataIndex': 'create_by', 'width': 'calc(100% / 5)'},
{'title': t__notification('内容'), 'dataIndex': 'content', 'width': 'calc(100% * 2 / 5)'},
{'title': t__notification('发布时间'), 'dataIndex': 'create_datetime', 'width': 'calc(100% / 5)'},
{'title': t__notification('启用'), 'dataIndex': 'enable', 'renderOptions': {'renderType': 'switch'}, 'width': 'calc(100% / 5)'},
],
rowSelectionType='checkbox',
data=get_table_data(),
@ -69,14 +69,14 @@ def handle_delete(confirmCounts, selectedRows):
# 若当前无已选中行
if not selectedRows:
MessageManager.warning(content='请先选择要删除的行')
MessageManager.warning(content=t__notification('请先选择要删除的行'))
return dash.no_update
# 删除选中行
from database.sql_db.dao import dao_announcement
dao_announcement.delete_announcement([row['content'] for row in selectedRows])
MessageManager.success(content='选中行删除成功')
MessageManager.success(content=t__notification('选中行删除成功'))
# 重置选中行
set_props('announcement-table', {'selectedRows': []})
@ -111,7 +111,7 @@ def refresh_add_modal(visible):
[
fac.AntdFormItem(
fac.AntdInput(id='announcement-content'),
label='发布内容',
label=t__notification('发布内容'),
),
],
)
@ -133,11 +133,11 @@ def handle_add_data(okCounts, value):
op_user_name = get_menu_access(only_get_user_name=True)
from database.sql_db.dao import dao_announcement
MessageManager.success(content='数据新增成功')
MessageManager.success(content=t__notification('数据新增成功'))
dao_announcement.add_announcement(user_name=op_user_name, announcement=value)
return get_table_data()
MessageManager.success(content='数据填写不完整')
MessageManager.success(content=t__notification('数据填写不完整'))
return dash.no_update
@ -158,7 +158,7 @@ def handle_enable_eow(recentlySwitchDataIndex, recentlySwitchStatus, recentlySwi
content = recentlySwitchRow['enable']['custom']
dao_announcement.update_announcement_status(content, status)
if status:
MessageManager.success(content='公告打开成功')
MessageManager.success(content=t__notification('公告打开成功'))
else:
MessageManager.success(content='公告关闭成功')
MessageManager.success(content=t__notification('公告关闭成功'))
return dash.no_update

View File

@ -1,14 +1,11 @@
from common.utilities.util_menu_access import MenuAccess
from typing import List
import feffery_antd_components as fac
import feffery_utils_components as fuc
from common.utilities.util_logger import Log
from dash import html
from dash_components import Card
from dash import dcc
from database.sql_db.dao import dao_user
import dash_callback.application.notification_.announcement_c # noqa: F401
from i18n import t__person, t__default, t__access
from i18n import t__notification, translator
# 二级菜单的标题、图标和显示顺序
@ -32,19 +29,20 @@ def render_content(menu_access: MenuAccess, **kwargs):
[
fac.AntdButton(
id='announcement-button-add',
children='新增公告',
children=t__notification('新增公告'),
type='primary',
icon=fac.AntdIcon(icon='antd-plus'),
),
fac.AntdPopconfirm(
fac.AntdButton(
'删除选中',
t__notification('删除选中'),
type='primary',
danger=True,
icon=fac.AntdIcon(icon='antd-close'),
),
id='announcement-button-delete',
title='确认删除选中行吗?',
title=t__notification('确认删除选中行吗?'),
locale=translator.get_current_locale(),
),
]
),

View File

@ -27,7 +27,7 @@ def render_aside_content(menu_access: MenuAccess):
'fontWeight': 'bold',
'color': 'rgb(245,245,245)',
},
style={'display': 'None'},
# style={'display': 'None'},
),
]
),
@ -64,8 +64,9 @@ def render_aside_content(menu_access: MenuAccess):
'.ant-menu-submenu-title:hover': {'color': '#fff'},
'.ant-menu-item-selected': {
'backgroundColor': 'rgba(0,0,0,0)',
'borderRight': '2px solid rgb(64,143,201)',
'borderRadius': '0.8em',
# 'border': '1px solid rgba(64,143,201,0.4)',
'borderRight': '4px solid rgb(64,143,201)',
'borderRadius': '0em',
'color': 'rgb(64,143,201)',
},
},

View File

@ -15,7 +15,7 @@ def render_head_content(menu_access: MenuAccess):
# 页首左侧折叠按钮区域
fac.AntdCol(
fac.AntdButton(
fac.AntdIcon(id='btn-menu-collapse-sider-menu-icon', icon='antd-menu-unfold'),
fac.AntdIcon(id='btn-menu-collapse-sider-menu-icon', icon='antd-menu-fold'),
id='btn-menu-collapse-sider-menu',
type='text',
shape='circle',

View File

@ -18,9 +18,10 @@ def render_content(menu_access: MenuAccess):
fac.AntdCol(
fac.AntdSider(
render_aside_content(menu_access),
collapsed=True,
collapsible=False,
collapsed=False,
collapsible=True,
collapsedWidth=60,
width=225,
trigger=None,
id='menu-collapse-sider',
),

View File

@ -17,4 +17,5 @@ t__default = partial(translator.t)
t__access = partial(translator.t, locale_topic='access')
t__dashboard = partial(translator.t, locale_topic='dashboard')
t__person = partial(translator.t, locale_topic='person')
t__notification = partial(translator.t, locale_topic='notification')
t__other = partial(translator.t, locale_topic='other')

View File

@ -260,6 +260,15 @@
"您确定要删除角色 ": {
"en-us": "Are you sure to delete role "
},
"通知管理": {
"en-us": "Notification Mgmt"
},
"公告管理": {
"en-us": "Announcement"
},
"公告管理-页面": {
"en-us": "Notification Mgmt"
},
"应用案例": {
"en-us": "App Example"
},

View File

@ -0,0 +1,48 @@
{
"root_locale": "zh-cn",
"topic": "notification",
"contents": {
"新增公告": {
"en-us": "Add Notification"
},
"删除选中": {
"en-us": "Delete Selected"
},
"确认删除选中行吗?": {
"en-us": "Are you sure to delete the selected rows?"
},
"创建人": {
"en-us": "Creator"
},
"内容": {
"en-us": "Content"
},
"发布时间": {
"en-us": "Publish Time"
},
"启用": {
"en-us": "Enable"
},
"请先选择要删除的行": {
"en-us": "Please select the rows to delete first"
},
"选中行删除成功": {
"en-us": "Selected rows deleted successfully"
},
"发布内容": {
"en-us": "Publish Content"
},
"数据新增成功": {
"en-us": "Data added successfully"
},
"数据填写不完整": {
"en-us": "Incomplete data"
},
"公告打开成功": {
"en-us": "Notification opened successfully"
},
"公告关闭成功": {
"en-us": "Notification closed successfully"
}
}
}