Merge pull request '当前用户' (#52) from qtb into master

Reviewed-on: #52
This commit was merged in pull request #52.
This commit is contained in:
qitangbo
2026-09-22 16:40:27 +08:00
4 changed files with 55 additions and 0 deletions
+2
View File
@@ -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',
+31
View File
@@ -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>