升级Vue3,iView替换ElementPlus

- 删除babel配置、更新依赖与入口初始化
- 全量替换UI组件、样式适配,新增迁移文档与标签/过滤器自动化替换脚本
This commit is contained in:
lifenlong
2026-06-05 17:49:43 +08:00
parent 615ee91511
commit 832fda813b
322 changed files with 25693 additions and 24453 deletions

View File

@@ -0,0 +1,110 @@
import { createApp, h, onMounted, onUnmounted } from "vue";
let activeMenu = null;
function destroyMenu() {
if (!activeMenu) return;
activeMenu.app.unmount();
if (activeMenu.el?.parentNode) {
activeMenu.el.parentNode.removeChild(activeMenu.el);
}
activeMenu = null;
}
function normalizeOptions(options) {
if (Array.isArray(options)) {
return { items: options };
}
return options || { items: [] };
}
function showContextmenu(options) {
destroyMenu();
const {
items = [],
event,
x = 0,
y = 0,
customClass = "",
zIndex = 3000,
minWidth = 120,
} = normalizeOptions(options);
const left = event?.clientX ?? x;
const top = event?.clientY ?? y;
const el = document.createElement("div");
document.body.appendChild(el);
const app = createApp({
setup() {
const close = () => destroyMenu();
onMounted(() => {
document.addEventListener("click", close);
document.addEventListener("contextmenu", close);
document.addEventListener("wheel", close, { passive: true });
});
onUnmounted(() => {
document.removeEventListener("click", close);
document.removeEventListener("contextmenu", close);
document.removeEventListener("wheel", close);
});
return () =>
h(
"div",
{
class: ["im-contextmenu", customClass].filter(Boolean),
style: {
position: "fixed",
left: `${left}px`,
top: `${top}px`,
zIndex,
minWidth: `${minWidth}px`,
},
onContextmenu: (e) => e.preventDefault(),
},
items.flatMap((item, index) => {
const nodes = [];
if (item.divided && index > 0) {
nodes.push(h("div", { class: "im-contextmenu-divider" }));
}
nodes.push(renderMenuItem(item, close));
return nodes;
})
);
},
});
activeMenu = { app, el };
app.mount(el);
}
function renderMenuItem(item, close) {
return h(
"div",
{
class: [
"im-contextmenu-item",
item.customClass,
item.disabled ? "is-disabled" : "",
].filter(Boolean),
onClick: (e) => {
e.stopPropagation();
if (item.disabled) return;
item.onClick?.();
close();
},
},
[
item.icon ? h("i", { class: item.icon }) : null,
h("span", item.label),
]
);
}
export function setupContextmenu(app) {
app.config.globalProperties.$contextmenu = showContextmenu;
}

10
im/src/plugins/element.js Normal file
View File

@@ -0,0 +1,10 @@
import ElementPlus from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import "element-plus/dist/index.css";
export function setupElementPlus(app) {
app.use(ElementPlus, {
locale: zhCn,
size: "default",
});
}

View File

@@ -1,4 +1,4 @@
import { Notification, MessageBox } from "element-ui";
import { ElNotification, ElMessageBox } from "element-plus";
let wsSignIn; // ws 是否是掉线状态
import store from "@/store";
class WsSocket {
@@ -84,7 +84,7 @@ class WsSocket {
store.commit('SET_WS_STATUS',true);
wsSignIn.close();
Notification({
ElNotification({
title: "成功",
message: "重连成功",
type: "success",
@@ -125,7 +125,7 @@ class WsSocket {
* 长时间挂载页面中并且重连次数为空的时候进行提示
*/
if (this.config.reconnect.number == 0) {
MessageBox("当前对话链接已失效,请从关闭重新进入。", "提示", {
ElMessageBox("当前对话链接已失效,请从关闭重新进入。", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
closeOnPressEscape: false,
@@ -134,7 +134,7 @@ class WsSocket {
})
.then(() => {
window.close();
Notification({
ElNotification({
title: "对话链接已失效提示",
message: "请手动关闭当前页面",
type: "error",
@@ -142,7 +142,7 @@ class WsSocket {
});
})
.catch(() => {
Notification({
ElNotification({
title: "对话链接已失效提示",
message: "请手动关闭当前页面",
type: "error",
@@ -152,7 +152,7 @@ class WsSocket {
return false;
}
// 掉线重连提示
wsSignIn = Notification({
wsSignIn = ElNotification({
title: "掉线重连接提示",
message: `网络连接已断开,正在尝试重新连接......`,
type: "error",