当前用户 #52
@@ -59,6 +59,8 @@
|
||||
'web.assets_backend': [
|
||||
'college/static/src/scss/college_theme.scss',
|
||||
'college/static/src/js/hide_company_menu.js',
|
||||
'college/static/src/js/portal_indicator.js',
|
||||
'college/static/src/xml/portal_indicator.xml',
|
||||
],
|
||||
'web.assets_web_dark': [
|
||||
'college/static/src/scss/college_theme_dark.scss',
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/** @odoo-module **/
|
||||
import { registry } from "@web/core/registry";
|
||||
import { user } from "@web/core/user";
|
||||
import { Component, onWillStart, useState } from "@odoo/owl";
|
||||
|
||||
export class PortalIndicator extends Component {
|
||||
static template = "college.PortalIndicator";
|
||||
|
||||
setup() {
|
||||
this.state = useState({ label: "" });
|
||||
onWillStart(async () => {
|
||||
// 顺序:管理员 -> 老师 -> 学生(高权限优先)
|
||||
if (await user.hasGroup("base.group_system")) {
|
||||
this.state.label = "管理员端";
|
||||
} else if (await user.hasGroup("college.group_teacher")) {
|
||||
this.state.label = "教师端";
|
||||
} else if (await user.hasGroup("college.group_student")) {
|
||||
this.state.label = "学生端";
|
||||
} else {
|
||||
this.state.label = "用户端";
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// sequence 越小越靠右(user_menu 是 0)。想贴最右边用负数。
|
||||
registry.category("systray").add(
|
||||
"college.PortalIndicator",
|
||||
{ Component: PortalIndicator },
|
||||
{ sequence: 1}
|
||||
);
|
||||
@@ -275,3 +275,18 @@
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
|
||||
// 角色提示徽章:避免被 Odoo 导航栏 .badge 通知样式影响
|
||||
.o_college_portal_indicator {
|
||||
align-self: center; // 在 systray 中垂直居中,不被拉伸/裁切
|
||||
}
|
||||
|
||||
.o_portal_badge {
|
||||
display: inline-block;
|
||||
padding: 0.2em 0.7em;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.2;
|
||||
color: #fff;
|
||||
white-space: nowrap; // 不换行
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<div t-name="college.PortalIndicator"
|
||||
class="o_college_portal_indicator d-flex align-items-center ms-2">
|
||||
<span class="o_portal_badge" t-esc="state.label"/>
|
||||
</div>
|
||||
</templates>
|
||||
Reference in New Issue
Block a user