Skip to content

Commit

Permalink
!141 发布 vue 版本 5.2.2 与 cloud 版本 2.2.1
Browse files Browse the repository at this point in the history
Merge pull request !141 from 疯狂的狮子Li/dev
  • Loading branch information
JavaLionLi authored and gitee-org committed Aug 26, 2024
2 parents ba24afc + 3c2d910 commit 1606dbd
Show file tree
Hide file tree
Showing 22 changed files with 132 additions and 280 deletions.
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ VITE_APP_RSA_PRIVATE_KEY = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAmc3C
# 客户端id
VITE_APP_CLIENT_ID = 'e5cd7e4891bf95d1d19206ce24a7b32e'

# websocket 开关
VITE_APP_WEBSOCKET = true
# websocket 开关 默认使用sse推送
VITE_APP_WEBSOCKET = false
4 changes: 2 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ VITE_APP_RSA_PRIVATE_KEY = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAmc3C
# 客户端id
VITE_APP_CLIENT_ID = 'e5cd7e4891bf95d1d19206ce24a7b32e'

# websocket 开关
VITE_APP_WEBSOCKET = true
# websocket 开关 默认使用sse推送
VITE_APP_WEBSOCKET = false
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ruoyi-vue-plus",
"version": "5.2.1",
"version": "5.2.2",
"description": "RuoYi-Vue-Plus多租户管理系统",
"author": "LionLi",
"license": "MIT",
Expand Down Expand Up @@ -30,7 +30,7 @@
"diagram-js": "12.3.0",
"didi": "9.0.2",
"echarts": "5.5.0",
"element-plus": "2.7.5",
"element-plus": "2.7.8",
"file-saver": "2.0.5",
"fuse.js": "7.0.0",
"highlight.js": "11.9.0",
Expand All @@ -40,7 +40,7 @@
"nprogress": "0.2.0",
"pinia": "2.1.7",
"screenfull": "6.0.2",
"vue": "3.4.25",
"vue": "3.4.34",
"vue-cropper": "1.1.1",
"vue-i18n": "9.10.2",
"vue-router": "4.3.2",
Expand Down Expand Up @@ -81,7 +81,7 @@
"unplugin-icons": "0.18.5",
"unplugin-vue-components": "0.26.0",
"unplugin-vue-setup-extend-plus": "1.0.1",
"vite": "5.2.10",
"vite": "5.2.12",
"vite-plugin-compression": "0.5.1",
"vite-plugin-svg-icons": "2.0.1",
"vitest": "1.5.0",
Expand Down
4 changes: 4 additions & 0 deletions src/api/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export function register(data: any) {
* 注销
*/
export function logout() {
request({
url: '/resource/sse/close',
method: 'get'
});
return request({
url: '/auth/logout',
method: 'post'
Expand Down
63 changes: 0 additions & 63 deletions src/api/workflow/nodeConfig/index.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/layout/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const dynamicTenantEvent = async (tenantId: string) => {
dynamic.value = true;
proxy?.$tab.closeAllPage();
proxy?.$router.push('/');
proxy?.$tab.refreshPage();
}
};
Expand All @@ -136,6 +137,7 @@ const dynamicClearEvent = async () => {
dynamic.value = false;
proxy?.$tab.closeAllPage();
proxy?.$router.push('/');
proxy?.$tab.refreshPage();
};
/** 租户列表 */
Expand Down
5 changes: 5 additions & 0 deletions src/layout/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { AppMain, Navbar, Settings, TagsView } from './components';
import useAppStore from '@/store/modules/app';
import useSettingsStore from '@/store/modules/settings';
import { initWebSocket } from '@/utils/websocket';
import { initSSE } from "@/utils/sse";
const settingsStore = useSettingsStore();
const theme = computed(() => settingsStore.theme);
Expand Down Expand Up @@ -71,6 +72,10 @@ onMounted(() => {
initWebSocket(protocol + window.location.host + import.meta.env.VITE_APP_BASE_API + '/resource/websocket');
});
onMounted(() => {
initSSE(import.meta.env.VITE_APP_BASE_API + '/resource/sse')
});
const handleClickOutside = () => {
useAppStore().closeSideBar({ withoutAnimation: false });
};
Expand Down
1 change: 1 addition & 0 deletions src/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ router.beforeEach(async (to, from, next) => {
router.addRoute(route); // 动态添加可访问路由表
}
});
// @ts-ignore
next({ path: to.path, replace: true, params: to.params, query: to.query, hash: to.hash, name: to.name as string }); // hack方法 确保addRoutes已完成
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/tab.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import router from '@/router';
import { RouteLocationMatched, RouteLocationNormalized } from 'vue-router';
import {RouteLocationMatched, RouteLocationNormalized, RouteLocationRaw} from 'vue-router';
import useTagsViewStore from '@/store/modules/tagsView';

export default {
Expand Down Expand Up @@ -41,7 +41,7 @@ export default {
});
},
// 关闭当前tab页签,打开新页签
closeOpenPage(obj: RouteLocationNormalized): void {
closeOpenPage(obj: RouteLocationRaw): void {
useTagsViewStore().delView(router.currentRoute.value);
if (obj !== undefined) {
router.push(obj);
Expand Down
2 changes: 1 addition & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const dynamicRoutes: RouteRecordRaw[] = [
path: 'index/:tableId(\\d+)',
component: () => import('@/views/tool/gen/editTable.vue'),
name: 'GenEdit',
meta: { title: '修改生成配置', activeMenu: '/tool/gen', icon: '' }
meta: { title: '修改生成配置', activeMenu: '/tool/gen', icon: '', noCache: true }
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions src/store/modules/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export const usePermissionStore = defineStore('permission', () => {
const sidebarRouters = ref<RouteRecordRaw[]>([]);

const getRoutes = (): RouteRecordRaw[] => {
return routes.value;
return routes.value as RouteRecordRaw[];
};
const getSidebarRoutes = (): RouteRecordRaw[] => {
return sidebarRouters.value;
return sidebarRouters.value as RouteRecordRaw[];
};
const getTopbarRoutes = (): RouteRecordRaw[] => {
return topbarRouters.value;
return topbarRouters.value as RouteRecordRaw[];
};

const setRoutes = (newRoutes: RouteRecordRaw[]): void => {
Expand Down
22 changes: 11 additions & 11 deletions src/store/modules/tagsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const useTagsViewStore = defineStore('tagsView', () => {
const iframeViews = ref<RouteLocationNormalized[]>([]);

const getVisitedViews = (): RouteLocationNormalized[] => {
return visitedViews.value;
return visitedViews.value as RouteLocationNormalized[];
};
const getIframeViews = (): RouteLocationNormalized[] => {
return iframeViews.value;
return iframeViews.value as RouteLocationNormalized[];
};
const getCachedViews = (): string[] => {
return cachedViews.value;
Expand All @@ -31,7 +31,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
const delIframeView = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
iframeViews.value = iframeViews.value.filter((item: RouteLocationNormalized) => item.path !== view.path);
resolve([...iframeViews.value]);
resolve([...iframeViews.value as RouteLocationNormalized[]]);
});
};
const addVisitedView = (view: RouteLocationNormalized): void => {
Expand All @@ -54,7 +54,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
delCachedView(view);
}
resolve({
visitedViews: [...visitedViews.value],
visitedViews: [...visitedViews.value as RouteLocationNormalized[]],
cachedViews: [...cachedViews.value]
});
});
Expand All @@ -68,7 +68,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
break;
}
}
resolve([...visitedViews.value]);
resolve([...visitedViews.value as RouteLocationNormalized[]]);
});
};
const delCachedView = (view?: RouteLocationNormalized): Promise<string[]> => {
Expand All @@ -92,7 +92,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
delOthersVisitedViews(view);
delOthersCachedViews(view);
resolve({
visitedViews: [...visitedViews.value],
visitedViews: [...visitedViews.value as RouteLocationNormalized[]],
cachedViews: [...cachedViews.value]
});
});
Expand All @@ -103,7 +103,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
visitedViews.value = visitedViews.value.filter((v: RouteLocationNormalized) => {
return v.meta?.affix || v.path === view.path;
});
resolve([...visitedViews.value]);
resolve([...visitedViews.value as RouteLocationNormalized[]]);
});
};
const delOthersCachedViews = (view: RouteLocationNormalized): Promise<string[]> => {
Expand All @@ -124,15 +124,15 @@ export const useTagsViewStore = defineStore('tagsView', () => {
delAllVisitedViews();
delAllCachedViews();
resolve({
visitedViews: [...visitedViews.value],
visitedViews: [...visitedViews.value as RouteLocationNormalized[]],
cachedViews: [...cachedViews.value]
});
});
};
const delAllVisitedViews = (): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
visitedViews.value = visitedViews.value.filter((tag: RouteLocationNormalized) => tag.meta?.affix);
resolve([...visitedViews.value]);
resolve([...visitedViews.value as RouteLocationNormalized[]]);
});
};

Expand Down Expand Up @@ -167,7 +167,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
}
return false;
});
resolve([...visitedViews.value]);
resolve([...visitedViews.value as RouteLocationNormalized[]]);
});
};
const delLeftTags = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
Expand All @@ -186,7 +186,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
}
return false;
});
resolve([...visitedViews.value]);
resolve([...visitedViews.value as RouteLocationNormalized[]]);
});
};

Expand Down
45 changes: 45 additions & 0 deletions src/utils/sse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { getToken } from '@/utils/auth';
import { ElNotification } from 'element-plus';
import useNoticeStore from '@/store/modules/notice';

let message = '';

// 初始化
export const initSSE = (url: any) => {
url = url + '?Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID
const {
data,
error
} = useEventSource(url, [], {
autoReconnect: {
retries: 10,
delay: 3000,
onFailed() {
console.log('Failed to connect after 10 retries')
},
}
});

watch(error, () => {
console.log('SSE connection error:', error.value)
error.value = null;
});

watch(data, () => {
if (!data.value) return;
useNoticeStore().addNotice({
message: data.value,
read: false,
time: new Date().toLocaleString()
});
ElNotification({
title: '消息',
message: data.value,
type: 'success',
duration: 3000
});
data.value = null;
});
};


Loading

0 comments on commit 1606dbd

Please sign in to comment.