|
@@ -24,12 +24,18 @@ import WujieVue from 'wujie-vue3';
|
|
|
import LayoutExperience from './layout/LayoutExperience.vue';
|
|
import LayoutExperience from './layout/LayoutExperience.vue';
|
|
|
import ContentContainer from './layout/ContentContainer.vue';
|
|
import ContentContainer from './layout/ContentContainer.vue';
|
|
|
|
|
|
|
|
|
|
+import useLogout from './account/use-logout';
|
|
|
|
|
+
|
|
|
import { useCurrentUserStore } from '../base/store/use-current-user';
|
|
import { useCurrentUserStore } from '../base/store/use-current-user';
|
|
|
|
|
|
|
|
import { getConfigField } from '../config/index';
|
|
import { getConfigField } from '../config/index';
|
|
|
|
|
|
|
|
|
|
+import { hasPermission } from '../utils/permission';
|
|
|
|
|
+
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
+const logout = useLogout();
|
|
|
|
|
+
|
|
|
const { bus } = WujieVue;
|
|
const { bus } = WujieVue;
|
|
|
|
|
|
|
|
const props = defineProps({});
|
|
const props = defineProps({});
|
|
@@ -47,6 +53,41 @@ const containerStyle = {
|
|
|
padding: 0
|
|
padding: 0
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 获取小数返回按钮的链接
|
|
|
|
|
+ * 返回一个合法的路由字符串,例如 /chat/qa
|
|
|
|
|
+ * 或者
|
|
|
|
|
+ * 一个空字符串,表示无任何可用的路由
|
|
|
|
|
+ * @returns {String}
|
|
|
|
|
+ */
|
|
|
|
|
+function getXiaoshuBackUrl() {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 系统资源
|
|
|
|
|
+ */
|
|
|
|
|
+ const sys_resource_list = {
|
|
|
|
|
+ 'system:menu:conversation': '/chat/qa', // 会话
|
|
|
|
|
+ 'system:conversation:qa': '/chat/qa', // 会话进行中
|
|
|
|
|
+ 'system:conversation:hisroty': '/chat/history', // 会话,历史记录
|
|
|
|
|
+ 'system:conversation:board': '/chat/board', // 会话,智能体大全
|
|
|
|
|
+ 'system:menu:intelligent': '/intelligent', // 智能体
|
|
|
|
|
+ 'system:menu:knowledge': '/knowledge' // 知识库管理
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ let back_route = ''; // 返回的地址
|
|
|
|
|
+
|
|
|
|
|
+ for (let key in sys_resource_list) {
|
|
|
|
|
+ const has_permission = hasPermission(key);
|
|
|
|
|
+
|
|
|
|
|
+ if (has_permission) {
|
|
|
|
|
+ // 有权限
|
|
|
|
|
+ back_route = sys_resource_list[key];
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return back_route;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
const currentUser = useCurrentUserStore();
|
|
const currentUser = useCurrentUserStore();
|
|
|
|
|
|
|
@@ -56,6 +97,9 @@ onMounted(() => {
|
|
|
const info_val = { userName: user_name, token: token };
|
|
const info_val = { userName: user_name, token: token };
|
|
|
const info_str = JSON.stringify(info_val);
|
|
const info_str = JSON.stringify(info_val);
|
|
|
|
|
|
|
|
|
|
+ // 小数菜单下方,返回 按钮对应的链接
|
|
|
|
|
+ const back_url = getXiaoshuBackUrl();
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 插入到小数项目中的脚本
|
|
* 插入到小数项目中的脚本
|
|
|
*/
|
|
*/
|
|
@@ -65,23 +109,75 @@ onMounted(() => {
|
|
|
window.ASSETS_BASE_URL = '${xiaoshu_assets_url}';
|
|
window.ASSETS_BASE_URL = '${xiaoshu_assets_url}';
|
|
|
|
|
|
|
|
localStorage.setItem('xintongxiaoshu', '${info_str}');
|
|
localStorage.setItem('xintongxiaoshu', '${info_str}');
|
|
|
|
|
+
|
|
|
|
|
+ const observer = new MutationObserver((mutationsList) => {
|
|
|
|
|
+ mutationsList.forEach((mutation) => {
|
|
|
|
|
+ if (mutation.type === "childList") {
|
|
|
|
|
+ // console.log("A child node has been added or removed.");
|
|
|
|
|
+ // console.log(mutation);
|
|
|
|
|
+
|
|
|
|
|
+ if(mutation.addedNodes.length > 0){
|
|
|
|
|
+ // console.log('新节点被添加', mutation.addedNodes);
|
|
|
|
|
+ // console.log(mutation);
|
|
|
|
|
+
|
|
|
|
|
+ const addedNodes = mutation.addedNodes;
|
|
|
|
|
+ addedNodes.forEach((item, index) => {
|
|
|
|
|
+ const klass_name = item.className;
|
|
|
|
|
+ if(klass_name === 'arco-trigger-popup arco-trigger-position-rt arco-popover'){
|
|
|
|
|
+ // popover
|
|
|
|
|
+ // 可能是用户名,账号
|
|
|
|
|
+ const box = item.querySelector('.xiaoshu-aside-left-menus-pop-container');
|
|
|
|
|
+
|
|
|
|
|
+ const div = document.createElement('div');
|
|
|
|
|
+ div.setAttribute('class', 'xiaoshu-aside-left-menus-logout-btn');
|
|
|
|
|
+ const span = document.createElement('span');
|
|
|
|
|
+ span.innerText = '退出登录'
|
|
|
|
|
+ div.appendChild(span);
|
|
|
|
|
+ box.appendChild(div);
|
|
|
|
|
+ div.addEventListener('click', () => {
|
|
|
|
|
+ window.$wujie?.bus.$emit("xiaoshuAsideLogout");
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(mutation.removedNodes.length > 0){
|
|
|
|
|
+ // console.log('节点被移除', mutation.removedNodes);
|
|
|
|
|
+ // console.log(mutation);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (mutation.type === "attributes") {
|
|
|
|
|
+ // console.log('属性被修改了');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // console.log('其他');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ observer.observe(document.body, {childList: true, subtree: true})
|
|
|
`;
|
|
`;
|
|
|
|
|
|
|
|
- // TODO: 根据权限判断是否有 返回 按钮
|
|
|
|
|
- const insert_script_after_str = `
|
|
|
|
|
- const box = document.querySelector('.xiaoshu-aside-left-menus-container');
|
|
|
|
|
|
|
+ // 根据权限判断是否有 返回 按钮
|
|
|
|
|
+ let insert_script_after_str = '';
|
|
|
|
|
|
|
|
- if(box){
|
|
|
|
|
- const btn = document.createElement('div');
|
|
|
|
|
- box.appendChild(btn);
|
|
|
|
|
|
|
+ if (back_url) {
|
|
|
|
|
+ // 有返回链接
|
|
|
|
|
+ insert_script_after_str = `
|
|
|
|
|
+ const box = document.querySelector('.xiaoshu-aside-left-menus-container');
|
|
|
|
|
|
|
|
- btn.innerHTML = '<span class="xiaoshu-aside-left-back-btn">返回</span>';
|
|
|
|
|
|
|
+ if(box){
|
|
|
|
|
+ const btn = document.createElement('div');
|
|
|
|
|
+ box.appendChild(btn);
|
|
|
|
|
|
|
|
- btn.addEventListener('click', () => {
|
|
|
|
|
- window.$wujie?.bus.$emit("xiaoshuAsideBack");
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- `;
|
|
|
|
|
|
|
+ btn.innerHTML = '<span class="xiaoshu-aside-left-back-btn">返回</span>';
|
|
|
|
|
+
|
|
|
|
|
+ btn.addEventListener('click', () => {
|
|
|
|
|
+ window.$wujie?.bus.$emit("xiaoshuAsideBack");
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ `;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 无返回按钮
|
|
|
|
|
+ insert_script_after_str = `console.log('cant back');`;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
const insert_style_str = `
|
|
const insert_style_str = `
|
|
|
.xiaoshu-aside-left-back-btn{
|
|
.xiaoshu-aside-left-back-btn{
|
|
@@ -106,13 +202,28 @@ onMounted(() => {
|
|
|
padding-bottom: 0;
|
|
padding-bottom: 0;
|
|
|
border-bottom: none;
|
|
border-bottom: none;
|
|
|
}
|
|
}
|
|
|
|
|
+ .xiaoshu-aside-left-menus-logout-btn{
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ text-align: center;
|
|
|
|
|
+ margin-top: 10px;
|
|
|
|
|
+ }
|
|
|
`;
|
|
`;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 监听子系统的事件
|
|
* 监听子系统的事件
|
|
|
*/
|
|
*/
|
|
|
bus.$on('xiaoshuAsideBack', function () {
|
|
bus.$on('xiaoshuAsideBack', function () {
|
|
|
- router.push('/chat/qa');
|
|
|
|
|
|
|
+ if (back_url) {
|
|
|
|
|
+ // 有返回链接
|
|
|
|
|
+ router.push(back_url);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 监听子系统的退出登录事件
|
|
|
|
|
+ */
|
|
|
|
|
+ bus.$on('xiaoshuAsideLogout', function () {
|
|
|
|
|
+ logout();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
plugins.value = [
|
|
plugins.value = [
|