diff --git a/spug_api/apps/setting/views.py b/spug_api/apps/setting/views.py index 40745be..6c75e11 100644 --- a/spug_api/apps/setting/views.py +++ b/spug_api/apps/setting/views.py @@ -55,14 +55,16 @@ def email_test(request): if error is None: try: if form.port == 465: - server = smtplib.SMTP_SSL(form.server, form.port) + server = smtplib.SMTP_SSL(form.server, form.port, timeout=3) else: - server = smtplib.SMTP(form.server, form.port) + server = smtplib.SMTP(form.server, form.port, timeout=3) server.login(form.username, form.password) - return json_response() + return json_response() + except Exception as e: - error = e.smtp_error.decode('utf-8') + error = f'{e}' return json_response(error=error) + return json_response(error=error) diff --git a/spug_web/src/components/AuthCard.js b/spug_web/src/components/AuthCard.js index 94ed861..5a3d4e6 100644 --- a/spug_web/src/components/AuthCard.js +++ b/spug_web/src/components/AuthCard.js @@ -4,14 +4,13 @@ * Released under the AGPL-3.0 License. */ import React from 'react'; -import {Card} from 'antd'; -import { hasPermission } from 'libs'; +import { hasPermission } from "../libs"; +import PageWrapper from './PageWrapper'; - -export default function AuthCard(props) { +export default function AuthDiv(props) { let disabled = props.disabled === undefined ? false : props.disabled; if (props.auth && !hasPermission(props.auth)) { disabled = true; } - return disabled ? null : {props.children} + return disabled ? null : (props.auth.indexOf('add')===-1?
{props.children}
:
{props.children}
) } diff --git a/spug_web/src/components/AuthDiv.js b/spug_web/src/components/AuthDiv.js index 8d7fbad..5a3d4e6 100644 --- a/spug_web/src/components/AuthDiv.js +++ b/spug_web/src/components/AuthDiv.js @@ -5,12 +5,12 @@ */ import React from 'react'; import { hasPermission } from "../libs"; - +import PageWrapper from './PageWrapper'; export default function AuthDiv(props) { let disabled = props.disabled === undefined ? false : props.disabled; if (props.auth && !hasPermission(props.auth)) { disabled = true; } - return disabled ? null :
{props.children}
+ return disabled ? null : (props.auth.indexOf('add')===-1?
{props.children}
:
{props.children}
) } diff --git a/spug_web/src/components/PageWrapper.js b/spug_web/src/components/PageWrapper.js new file mode 100644 index 0000000..0ddb21b --- /dev/null +++ b/spug_web/src/components/PageWrapper.js @@ -0,0 +1,75 @@ +import React from 'react'; +import { Breadcrumb } from 'antd'; +import menus from '../menus'; +import styles from './index.module.css'; + +export default class extends React.Component { + constructor(props) { + super(props); + this.lastPath = window.location.pathname; + const breadInfo = this.assembleMenu(this.lastPath); + this.state = {breadInfo}; + } + + assembleMenu(currentPath) { + const menu = [] + if (Array.isArray(menu)) { + menus.forEach(item => { + if (!item) return false; + if (item.path === currentPath) { + menu.push({ + title: item.title + }) + } else { + if (Array.isArray(item.child)) { + item.child.forEach(itemChild => { + if (itemChild.path === currentPath) { + menu.push({ + title: item.title + }, { + title: itemChild.title + }) + } + }) + } + } + }) + } + return menu + } + + componentDidUpdate() { + const currentPath = window.location.pathname; + if (this.lastPath !== currentPath) { + const breadInfo = this.assembleMenu(currentPath) + this.setState({breadInfo}); + } + } + + render() { + const { breadcrumbs, children } = this.props; + const { breadInfo } = this.state; + return ( +
+ {(!!breadInfo.length || (breadcrumbs && breadcrumbs.length > 0)) && ( +
+ + { + (breadcrumbs ? breadcrumbs : breadInfo).map(item => { + return ( + + { + item.href ? ({item.title}) : item.title + } + + ) + }) + } + +
+ )} +
{children}
+
+ ) + } +} \ No newline at end of file diff --git a/spug_web/src/components/index.module.css b/spug_web/src/components/index.module.css index 4555710..d773178 100644 --- a/spug_web/src/components/index.module.css +++ b/spug_web/src/components/index.module.css @@ -36,3 +36,17 @@ top: 0; right: 0; } + +.breadWrapper .router { + padding: 24px 24px 0; +} + +.breadStyle { + width: 100%; + height: 54px; + overflow: hidden; + background: #fff; + padding: 16px 32px 0; + border-bottom: 1px solid #e8e8e8; + z-index: 1; +} \ No newline at end of file diff --git a/spug_web/src/layout/layout.module.css b/spug_web/src/layout/layout.module.css index 651b7c4..a218d44 100644 --- a/spug_web/src/layout/layout.module.css +++ b/spug_web/src/layout/layout.module.css @@ -15,10 +15,13 @@ display: flex; flex-direction: column; justify-content: space-between; - padding: 24px 24px 0; overflow-y: scroll; } +.content .router { + padding: 24px 24px 0; +} + .trigger { font-size: 20px; line-height: 64px; diff --git a/spug_web/src/pages/config/app/Table.js b/spug_web/src/pages/config/app/Table.js index d266056..0701893 100644 --- a/spug_web/src/pages/config/app/Table.js +++ b/spug_web/src/pages/config/app/Table.js @@ -41,7 +41,7 @@ class ComTable extends React.Component { store.showRel(info)}>依赖 - 配置 + 配置 ) }]; diff --git a/spug_web/src/pages/config/service/Table.js b/spug_web/src/pages/config/service/Table.js index 05327e7..64ae318 100644 --- a/spug_web/src/pages/config/service/Table.js +++ b/spug_web/src/pages/config/service/Table.js @@ -40,7 +40,7 @@ class ComTable extends React.Component { this.handleDelete(info)}>删除 - 配置 + 配置 ) }]; diff --git a/spug_web/src/pages/config/setting/index.js b/spug_web/src/pages/config/setting/index.js index 7d64c68..b7522ee 100644 --- a/spug_web/src/pages/config/setting/index.js +++ b/spug_web/src/pages/config/setting/index.js @@ -60,10 +60,16 @@ class Index extends React.Component { }) }; + chooseBread() { + const currentPath = window.location.pathname; + if (currentPath.indexOf('src') !== -1) return [{title:'配置中心'}, {title:'服务配置'}, {title:this.props.location.state.title}]; + if (currentPath.indexOf('app') !== -1) return [{title:'配置中心'}, {title:'应用配置'}, {title:this.props.location.state.title}]; + } + render() { const {view} = this.state; return ( - +
))} }> - + @@ -164,7 +164,7 @@ class Ext1Index extends React.Component { ))}
}> - + ))}