Commit fc88fa2f by Lin

fix: 文件修改更新

1 parent 89ef67dd
<script setup lang="ts">
import type { GlobalState } from '../qiankun';
import type { GlobalState } from "../qiankun";
import { onMounted, onUnmounted, reactive } from 'vue';
import { onMounted, onUnmounted, reactive } from "vue";
import { broadcast, communicationManager } from '../qiankun';
import { broadcast, communicationManager } from "../qiankun";
// 全局状态
const state = reactive<GlobalState>({
user: null,
theme: {
mode: 'light',
primaryColor: '#1890ff',
},
notifications: [],
config: {
apiBaseUrl: '',
timeout: 5000,
},
currentMenu: null,
user: null,
theme: {
mode: "light",
primaryColor: "#1890ff",
},
notifications: [],
config: {
apiBaseUrl: "",
timeout: 5000,
},
currentMenu: null,
});
// 通知表单
const notificationForm = reactive({
type: 'info' as 'error' | 'info' | 'success' | 'warning',
title: '',
message: '',
type: "info" as "error" | "info" | "success" | "warning",
title: "",
message: "",
});
// 配置表单
const configForm = reactive({
apiBaseUrl: '',
timeout: 5000,
apiBaseUrl: "",
timeout: 5000,
});
// 颜色选项
const colorOptions = [
{ name: '拂晓蓝', value: '#1890ff' },
{ name: '薄暮', value: '#f5222d' },
{ name: '火山', value: '#fa541c' },
{ name: '日暮', value: '#faad14' },
{ name: '极光绿', value: '#52c41a' },
{ name: '明青', value: '#13c2c2' },
{ name: '极客蓝', value: '#2f54eb' },
{ name: '酱紫', value: '#722ed1' },
{ name: "拂晓蓝", value: "#1890ff" },
{ name: "薄暮", value: "#f5222d" },
{ name: "火山", value: "#fa541c" },
{ name: "日暮", value: "#faad14" },
{ name: "极光绿", value: "#52c41a" },
{ name: "明青", value: "#13c2c2" },
{ name: "极客蓝", value: "#2f54eb" },
{ name: "酱紫", value: "#722ed1" },
];
// 切换用户
const switchUser = (role: string) => {
const users: Record<
const users: Record<
string,
{
avatar: string;
......@@ -57,400 +57,402 @@ const switchUser = (role: string) => {
role: string;
}
> = {
admin: {
id: '001',
name: '张三',
avatar: '👨‍💼',
role: 'admin',
permissions: ['read', 'write', 'delete', 'admin'],
},
user: {
id: '002',
name: '李四',
avatar: '👤',
role: 'user',
permissions: ['read', 'write'],
},
guest: {
id: '003',
name: '访客',
avatar: '👥',
role: 'guest',
permissions: ['read'],
},
admin: {
id: "001",
name: "张三",
avatar: "👨‍💼",
role: "admin",
permissions: [ "read", "write", "delete", "admin" ],
},
user: {
id: "002",
name: "李四",
avatar: "👤",
role: "user",
permissions: [ "read", "write" ],
},
guest: {
id: "003",
name: "访客",
avatar: "👥",
role: "guest",
permissions: [ "read" ],
},
};
const user = users[role];
communicationManager.updateUser(user);
const user = users[role];
communicationManager.updateUser(user);
broadcast('success', '用户切换', `已切换到: ${user.name} (${user.role})`);
broadcast("success", "用户切换", `已切换到: ${user.name} (${user.role})`);
};
// 切换主题模式
const toggleThemeMode = () => {
const newMode = state.theme.mode === 'light' ? 'dark' : 'light';
communicationManager.updateTheme({ mode: newMode });
broadcast(
'info',
'主题切换',
`已切换到${newMode === 'light' ? '浅色' : '深色'}模式`,
);
const newMode = state.theme.mode === "light" ? "dark" : "light";
communicationManager.updateTheme({ mode: newMode });
broadcast(
"info",
"主题切换",
`已切换到${newMode === "light" ? "浅色" : "深色"}模式`,
);
};
// 改变主色调
const changeColor = (color: string) => {
communicationManager.updateTheme({ primaryColor: color });
communicationManager.updateTheme({ primaryColor: color });
broadcast('info', '主题颜色', `主色调已更新为 ${color}`);
broadcast("info", "主题颜色", `主色调已更新为 ${color}`);
};
// 发送通知
const sendNotification = () => {
if (!notificationForm.title || !notificationForm.message) {
alert('请填写标题和内容');
return;
}
broadcast(
notificationForm.type,
notificationForm.title,
notificationForm.message,
);
// 清空表单
notificationForm.title = '';
notificationForm.message = '';
if (!notificationForm.title || !notificationForm.message) {
return;
}
broadcast(
notificationForm.type,
notificationForm.title,
notificationForm.message,
);
// 清空表单
notificationForm.title = "";
notificationForm.message = "";
};
// 快速发送通知
const sendQuickNotification = (
type: 'error' | 'info' | 'success' | 'warning',
type: "error" | "info" | "success" | "warning",
) => {
const messages = {
success: { title: '操作成功', message: '数据已成功保存到服务器' },
warning: { title: '警告提示', message: '您的会话即将过期,请注意保存数据' },
error: { title: '操作失败', message: '网络连接失败,请检查您的网络设置' },
info: {
title: '系统提示',
message: '系统将在今晚23:00进行维护,预计持续1小时',
},
};
const msg = messages[type];
broadcast(type, msg.title, msg.message);
const messages = {
success: { title: "操作成功", message: "数据已成功保存到服务器" },
warning: { title: "警告提示", message: "您的会话即将过期,请注意保存数据" },
error: { title: "操作失败", message: "网络连接失败,请检查您的网络设置" },
info: {
title: "系统提示",
message: "系统将在今晚23:00进行维护,预计持续1小时",
},
};
const msg = messages[type];
broadcast(type, msg.title, msg.message);
};
// 更新配置
const updateConfig = () => {
communicationManager.updateConfig(configForm);
broadcast('success', '配置更新', '系统配置已更新');
communicationManager.updateConfig(configForm);
broadcast("success", "配置更新", "系统配置已更新");
};
// 监听全局状态变化
let unsubscribe: (() => void) | null = null;
onMounted(() => {
// 初始化状态
const currentState = communicationManager.getGlobalState();
Object.assign(state, currentState);
// 初始化配置表单
configForm.apiBaseUrl = currentState.config.apiBaseUrl;
configForm.timeout = currentState.config.timeout;
// 监听状态变化
unsubscribe = communicationManager.onStateChange((newState) => {
Object.assign(state, newState);
});
// 初始化状态
const currentState = communicationManager.getGlobalState();
Object.assign(state, currentState);
// 初始化配置表单
configForm.apiBaseUrl = currentState.config.apiBaseUrl;
configForm.timeout = currentState.config.timeout;
// 监听状态变化
unsubscribe = communicationManager.onStateChange((newState) => {
Object.assign(state, newState);
});
});
onUnmounted(() => {
if (unsubscribe) {
unsubscribe();
}
if (unsubscribe) {
unsubscribe();
}
});
</script>
<template>
<div class="communication-demo">
<div class="page-header">
<h1>📡 微前端通信示例</h1>
<p class="subtitle">演示基座与子应用之间的数据通信</p>
</div>
<div class="demo-container">
<!-- 用户信息管理 -->
<div class="demo-section">
<div class="section-header">
<h2>👤 用户信息管理</h2>
<span class="tag">全局状态共享</span>
</div>
<div class="section-content">
<div class="current-user">
<h3>当前用户信息</h3>
<div v-if="state.user" class="user-display">
<div class="info-row">
<span class="label">用户头像:</span>
<span class="value avatar">{{ state.user.avatar }}</span>
</div>
<div class="info-row">
<span class="label">用户名:</span>
<span class="value">{{ state.user.name }}</span>
</div>
<div class="info-row">
<span class="label">用户ID:</span>
<span class="value">{{ state.user.id }}</span>
</div>
<div class="info-row">
<span class="label">角色:</span>
<span class="value">{{ state.user.role }}</span>
</div>
<div class="info-row">
<span class="label">权限:</span>
<span class="value">{{
state.user.permissions.join(', ')
}}</span>
</div>
</div>
</div>
<div class="user-actions">
<h3>切换用户</h3>
<div class="button-group">
<button @click="switchUser('admin')" class="btn btn-primary">
切换到管理员
</button>
<button @click="switchUser('user')" class="btn btn-secondary">
切换到普通用户
</button>
<button @click="switchUser('guest')" class="btn btn-secondary">
切换到访客
</button>
</div>
<p class="hint">💡 切换用户后,子应用会实时接收到新的用户信息</p>
</div>
<div class="communication-demo">
<div class="page-header">
<h1>📡 微前端通信示例</h1>
<p class="subtitle">
演示基座与子应用之间的数据通信
</p>
</div>
</div>
<!-- 主题管理 -->
<div class="demo-section">
<div class="section-header">
<h2>🎨 主题管理</h2>
<span class="tag">全局状态共享</span>
</div>
<div class="section-content">
<div class="theme-display">
<h3>当前主题</h3>
<div class="info-row">
<span class="label">模式:</span>
<span class="value">{{
state.theme.mode === 'light' ? '🌞 浅色' : '🌙 深色'
}}</span>
</div>
<div class="info-row">
<span class="label">主色调:</span>
<span class="value">
<span
class="color-preview"
:style="{ backgroundColor: state.theme.primaryColor }"
></span>
{{ state.theme.primaryColor }}
</span>
</div>
</div>
<div class="theme-actions">
<h3>切换主题</h3>
<div class="button-group">
<button @click="toggleThemeMode" class="btn btn-primary">
切换{{ state.theme.mode === 'light' ? '深色' : '浅色' }}模式
</button>
</div>
<div class="color-picker">
<label>选择主色调:</label>
<div class="color-options">
<button
v-for="color in colorOptions"
:key="color.value"
:style="{ backgroundColor: color.value }"
class="color-btn"
:class="[
{ active: state.theme.primaryColor === color.value },
]"
@click="changeColor(color.value)"
:title="color.name"
></button>
</div>
<div class="demo-container">
<!-- 用户信息管理 -->
<div class="demo-section">
<div class="section-header">
<h2>👤 用户信息管理</h2>
<span class="tag">全局状态共享</span>
</div>
<div class="section-content">
<div class="current-user">
<h3>当前用户信息</h3>
<div v-if="state.user" class="user-display">
<div class="info-row">
<span class="label">用户头像:</span>
<span class="value avatar">{{ state.user.avatar }}</span>
</div>
<div class="info-row">
<span class="label">用户名:</span>
<span class="value">{{ state.user.name }}</span>
</div>
<div class="info-row">
<span class="label">用户ID:</span>
<span class="value">{{ state.user.id }}</span>
</div>
<div class="info-row">
<span class="label">角色:</span>
<span class="value">{{ state.user.role }}</span>
</div>
<div class="info-row">
<span class="label">权限:</span>
<span class="value">
{{
state.user.permissions.join(', ')
}}
</span>
</div>
</div>
</div>
<div class="user-actions">
<h3>切换用户</h3>
<div class="button-group">
<button class="btn btn-primary" @click="switchUser('admin')">
切换到管理员
</button>
<button class="btn btn-secondary" @click="switchUser('user')">
切换到普通用户
</button>
<button class="btn btn-secondary" @click="switchUser('guest')">
切换到访客
</button>
</div>
<p class="hint">
💡 切换用户后,子应用会实时接收到新的用户信息
</p>
</div>
</div>
</div>
<p class="hint">💡 主题变化会同步到所有子应用</p>
</div>
</div>
</div>
<!-- 消息通知 -->
<div class="demo-section">
<div class="section-header">
<h2>📢 消息通知</h2>
<span class="tag">基座向子应用广播</span>
</div>
<div class="section-content">
<div class="notification-form">
<h3>发送通知</h3>
<div class="form-group">
<label>通知类型:</label>
<select v-model="notificationForm.type" class="form-control">
<option value="success">✅ 成功</option>
<option value="warning">⚠️ 警告</option>
<option value="error">❌ 错误</option>
<option value="info">ℹ️ 信息</option>
</select>
</div>
<div class="form-group">
<label>标题:</label>
<input
v-model="notificationForm.title"
type="text"
class="form-control"
placeholder="请输入通知标题"
/>
</div>
<div class="form-group">
<label>内容:</label>
<textarea
v-model="notificationForm.message"
class="form-control"
rows="3"
placeholder="请输入通知内容"
></textarea>
<!-- 主题管理 -->
<div class="demo-section">
<div class="section-header">
<h2>🎨 主题管理</h2>
<span class="tag">全局状态共享</span>
</div>
<div class="section-content">
<div class="theme-display">
<h3>当前主题</h3>
<div class="info-row">
<span class="label">模式:</span>
<span class="value">
{{
state.theme.mode === 'light' ? '🌞 浅色' : '🌙 深色'
}}
</span>
</div>
<div class="info-row">
<span class="label">主色调:</span>
<span class="value">
<span class="color-preview"
:style="{ backgroundColor: state.theme.primaryColor }">
</span>
{{ state.theme.primaryColor }}
</span>
</div>
</div>
<div class="theme-actions">
<h3>切换主题</h3>
<div class="button-group">
<button class="btn btn-primary" @click="toggleThemeMode">
切换{{ state.theme.mode === 'light' ? '深色' : '浅色' }}模式
</button>
</div>
<div class="color-picker">
<label>选择主色调:</label>
<div class="color-options">
<button v-for="color in colorOptions"
:key="color.value"
class="color-btn"
:class="[
{ active: state.theme.primaryColor === color.value },
]"
:style="{ backgroundColor: color.value }"
:title="color.name"
@click="changeColor(color.value)">
</button>
</div>
</div>
<p class="hint">
💡 主题变化会同步到所有子应用
</p>
</div>
</div>
</div>
<button @click="sendNotification" class="btn btn-primary btn-block">
发送通知
</button>
<p class="hint">
💡 发送的通知会显示在右上角的通知中心,所有应用都能看到
</p>
</div>
<div class="quick-actions">
<h3>快速测试</h3>
<div class="button-group">
<button
@click="sendQuickNotification('success')"
class="btn btn-success"
>
成功消息
</button>
<button
@click="sendQuickNotification('warning')"
class="btn btn-warning"
>
警告消息
</button>
<button
@click="sendQuickNotification('error')"
class="btn btn-danger"
>
错误消息
</button>
<button
@click="sendQuickNotification('info')"
class="btn btn-info"
>
信息消息
</button>
</div>
</div>
</div>
</div>
<!-- 系统配置 -->
<div class="demo-section">
<div class="section-header">
<h2>⚙️ 系统配置</h2>
<span class="tag">全局配置共享</span>
</div>
<div class="section-content">
<div class="config-display">
<h3>当前配置</h3>
<div class="info-row">
<span class="label">API 地址:</span>
<span class="value code">{{ state.config.apiBaseUrl }}</span>
<!-- 消息通知 -->
<div class="demo-section">
<div class="section-header">
<h2>📢 消息通知</h2>
<span class="tag">基座向子应用广播</span>
</div>
<div class="section-content">
<div class="notification-form">
<h3>发送通知</h3>
<div class="form-group">
<label>通知类型:</label>
<select v-model="notificationForm.type" class="form-control">
<option value="success">
✅ 成功
</option>
<option value="warning">
⚠️ 警告
</option>
<option value="error">
❌ 错误
</option>
<option value="info">
ℹ️ 信息
</option>
</select>
</div>
<div class="form-group">
<label>标题:</label>
<input v-model="notificationForm.title"
class="form-control"
placeholder="请输入通知标题"
type="text" />
</div>
<div class="form-group">
<label>内容:</label>
<textarea v-model="notificationForm.message"
class="form-control"
placeholder="请输入通知内容"
rows="3">
</textarea>
</div>
<button class="btn btn-primary btn-block" @click="sendNotification">
发送通知
</button>
<p class="hint">
💡 发送的通知会显示在右上角的通知中心,所有应用都能看到
</p>
</div>
<div class="quick-actions">
<h3>快速测试</h3>
<div class="button-group">
<button class="btn btn-success"
@click="sendQuickNotification('success')">
成功消息
</button>
<button class="btn btn-warning"
@click="sendQuickNotification('warning')">
警告消息
</button>
<button class="btn btn-danger"
@click="sendQuickNotification('error')">
错误消息
</button>
<button class="btn btn-info"
@click="sendQuickNotification('info')">
信息消息
</button>
</div>
</div>
</div>
</div>
<div class="info-row">
<span class="label">请求超时:</span>
<span class="value">{{ state.config.timeout }}ms</span>
</div>
</div>
<div class="config-actions">
<h3>更新配置</h3>
<div class="form-group">
<label>API 地址:</label>
<input
v-model="configForm.apiBaseUrl"
type="text"
class="form-control"
/>
</div>
<div class="form-group">
<label>请求超时 (ms):</label>
<input
v-model.number="configForm.timeout"
type="number"
class="form-control"
/>
<!-- 系统配置 -->
<div class="demo-section">
<div class="section-header">
<h2>⚙️ 系统配置</h2>
<span class="tag">全局配置共享</span>
</div>
<div class="section-content">
<div class="config-display">
<h3>当前配置</h3>
<div class="info-row">
<span class="label">API 地址:</span>
<span class="value code">{{ state.config.apiBaseUrl }}</span>
</div>
<div class="info-row">
<span class="label">请求超时:</span>
<span class="value">{{ state.config.timeout }}ms</span>
</div>
</div>
<div class="config-actions">
<h3>更新配置</h3>
<div class="form-group">
<label>API 地址:</label>
<input v-model="configForm.apiBaseUrl"
class="form-control"
type="text" />
</div>
<div class="form-group">
<label>请求超时 (ms):</label>
<input v-model.number="configForm.timeout"
class="form-control"
type="number" />
</div>
<button class="btn btn-primary" @click="updateConfig">
更新配置
</button>
<p class="hint">
💡 配置更新后,所有子应用都会收到最新配置
</p>
</div>
</div>
</div>
<button @click="updateConfig" class="btn btn-primary">
更新配置
</button>
<p class="hint">💡 配置更新后,所有子应用都会收到最新配置</p>
</div>
</div>
</div>
<!-- 通信说明 -->
<div class="demo-section info-section">
<div class="section-header">
<h2>📚 通信方式说明</h2>
</div>
<div class="section-content">
<div class="info-card">
<h3>1. 全局状态管理 (Global State)</h3>
<p>
使用 qiankun 的
<code>initGlobalState</code> API,实现基座和子应用之间的状态共享。
</p>
<ul>
<li>✅ 双向通信:基座和子应用都可以修改状态</li>
<li>✅ 实时同步:状态变化会立即通知所有订阅者</li>
<li>✅ 类型安全:使用 TypeScript 定义状态结构</li>
</ul>
</div>
<div class="info-card">
<h3>2. Props 传递</h3>
<p>基座在注册子应用时,可以通过 props 向子应用传递数据。</p>
<ul>
<li>✅ 单向数据流:基座向子应用传递</li>
<li>✅ 配置传递:适合传递路由配置、权限等静态数据</li>
<li>✅ 生命周期传递:在 mount、update 时传递</li>
</ul>
</div>
<div class="info-card">
<h3>3. Actions 通信</h3>
<p>通过全局状态管理器,实现消息通知、事件广播等功能。</p>
<ul>
<li>✅ 事件驱动:基于发布订阅模式</li>
<li>✅ 广播消息:一对多通信</li>
<li>✅ 解耦合:应用之间不直接依赖</li>
</ul>
</div>
<!-- 通信说明 -->
<div class="demo-section info-section">
<div class="section-header">
<h2>📚 通信方式说明</h2>
</div>
<div class="section-content">
<div class="info-card">
<h3>1. 全局状态管理 (Global State)</h3>
<p>
使用 qiankun 的
<code>initGlobalState</code> API,实现基座和子应用之间的状态共享。
</p>
<ul>
<li>✅ 双向通信:基座和子应用都可以修改状态</li>
<li>✅ 实时同步:状态变化会立即通知所有订阅者</li>
<li>✅ 类型安全:使用 TypeScript 定义状态结构</li>
</ul>
</div>
<div class="info-card">
<h3>2. Props 传递</h3>
<p>基座在注册子应用时,可以通过 props 向子应用传递数据。</p>
<ul>
<li>✅ 单向数据流:基座向子应用传递</li>
<li>✅ 配置传递:适合传递路由配置、权限等静态数据</li>
<li>✅ 生命周期传递:在 mount、update 时传递</li>
</ul>
</div>
<div class="info-card">
<h3>3. Actions 通信</h3>
<p>通过全局状态管理器,实现消息通知、事件广播等功能。</p>
<ul>
<li>✅ 事件驱动:基于发布订阅模式</li>
<li>✅ 广播消息:一对多通信</li>
<li>✅ 解耦合:应用之间不直接依赖</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped>
......
<script setup lang="ts">
import type { GlobalState } from '@/qiankun';
import type { GlobalState } from "@/qiankun";
import { onMounted, onUnmounted, ref } from 'vue';
import { onMounted, onUnmounted, ref } from "vue";
// 按需引入 @venus/common-ui-vue 组件库的按钮组件
import { GLButton } from '@venus/common-ui-vue';
import { GLButton } from "@venus/common-ui-vue";
import { waitForConfigReady } from '@/config/center';
import { broadcast, communicationManager, microApps } from '@/qiankun';
import { waitForConfigReady } from "@/config/center";
import { broadcast, communicationManager, microApps } from "@/qiankun";
import {
Check,
Delete,
Edit,
Message,
Search,
Star,
} from '@element-plus/icons-vue';
Check,
Delete,
Edit,
Message,
Search,
Star,
} from "@element-plus/icons-vue";
const apps = microApps;
......@@ -23,8 +23,8 @@ const apps = microApps;
const globalState = ref<GlobalState | null>(null);
// 消息输入
const messageTitle = ref('来自主应用的消息');
const messageContent = ref('Hello from Main App!');
const messageTitle = ref("来自主应用的消息");
const messageContent = ref("Hello from Main App!");
const drawer = ref(false);
// 监听器的取消函数
let unsubscribe: (() => void) | null = null;
......@@ -33,512 +33,601 @@ let unsubscribe: (() => void) | null = null;
const buttonLoading = ref(false);
const clickCount = ref(0);
onMounted(async () => {
try {
await waitForConfigReady();
} catch (error: any) {
}
// 获取当前全局状态
globalState.value = communicationManager.getGlobalState();
// 监听全局状态变化
unsubscribe = communicationManager.onStateChange((state) => {
globalState.value = state;
});
try {
await waitForConfigReady();
} catch {}
// 获取当前全局状态
globalState.value = communicationManager.getGlobalState();
// 监听全局状态变化
unsubscribe = communicationManager.onStateChange((state) => {
globalState.value = state;
});
});
// 组件卸载时取消监听
onUnmounted(() => {
if (unsubscribe) {
unsubscribe();
}
if (unsubscribe) {
unsubscribe();
}
});
// 发送成功消息
const sendSuccessMessage = () => {
broadcast('success', '操作成功', '这是一条来自主应用的成功消息!');
broadcast("success", "操作成功", "这是一条来自主应用的成功消息!");
};
// 发送自定义消息
const sendCustomMessage = () => {
if (!messageTitle.value || !messageContent.value) {
broadcast('error', '发送失败', '标题和内容不能为空!');
return;
}
communicationManager.addNotification({
type: 'info',
title: messageTitle.value,
message: messageContent.value,
from: '主应用',
});
messageTitle.value = '';
messageContent.value = '';
if (!messageTitle.value || !messageContent.value) {
broadcast("error", "发送失败", "标题和内容不能为空!");
return;
}
communicationManager.addNotification({
type: "info",
title: messageTitle.value,
message: messageContent.value,
from: "主应用",
});
messageTitle.value = "";
messageContent.value = "";
};
// 切换主题
const toggleTheme = () => {
const currentTheme = globalState.value?.theme.mode || 'light';
const newTheme = currentTheme === 'light' ? 'dark' : 'light';
communicationManager.updateTheme({
mode: newTheme,
});
broadcast(
'success',
'主题切换',
`已切换到${newTheme === 'dark' ? '深色' : '浅色'}模式`,
);
const currentTheme = globalState.value?.theme.mode || "light";
const newTheme = currentTheme === "light" ? "dark" : "light";
communicationManager.updateTheme({
mode: newTheme,
});
broadcast(
"success",
"主题切换",
`已切换到${newTheme === "dark" ? "深色" : "浅色"}模式`,
);
};
// 更新用户信息
const updateUserInfo = () => {
const newUser = {
id: '001',
name: '李四',
avatar: '👨‍💻',
role: 'developer',
permissions: ['read', 'write'],
};
communicationManager.updateUser(newUser);
broadcast('success', '用户更新', `用户信息已更新为: ${newUser.name}`);
const newUser = {
id: "001",
name: "李四",
avatar: "👨‍💻",
role: "developer",
permissions: [ "read", "write" ],
};
communicationManager.updateUser(newUser);
broadcast("success", "用户更新", `用户信息已更新为: ${newUser.name}`);
};
// 清空所有通知
const clearAllNotifications = () => {
communicationManager.clearNotifications();
communicationManager.clearNotifications();
};
// 删除单个通知
const removeNotification = (id: string) => {
communicationManager.removeNotification(id);
communicationManager.removeNotification(id);
};
// 格式化时间
const formatTime = (timestamp: number) => {
const date = new Date(timestamp);
return date.toLocaleTimeString('zh-CN');
const date = new Date(timestamp);
return date.toLocaleTimeString("zh-CN");
};
// GLButton 组件演示方法
// 模拟异步操作
const handleAsyncClick = async () => {
buttonLoading.value = true;
broadcast('info', '异步操作', '正在处理异步操作...');
buttonLoading.value = true;
broadcast("info", "异步操作", "正在处理异步操作...");
// 模拟 2 秒的异步操作
await new Promise((resolve) => setTimeout(resolve, 2000));
// 模拟 2 秒的异步操作
await new Promise((resolve) => setTimeout(resolve, 2000));
buttonLoading.value = false;
broadcast('success', '操作成功', '异步操作已完成!');
buttonLoading.value = false;
broadcast("success", "操作成功", "异步操作已完成!");
};
// 确认操作
const handleConfirmClick = () => {
broadcast('success', '确认成功', '你已确认执行该操作');
broadcast("success", "确认成功", "你已确认执行该操作");
};
// 删除操作
const handleDeleteClick = () => {
broadcast('success', '删除成功', '删除操作已执行');
broadcast("success", "删除成功", "删除操作已执行");
};
// 防抖点击
const handleDebounceClick = () => {
clickCount.value++;
broadcast('info', '防抖按钮', `第 ${clickCount.value} 次有效点击`);
clickCount.value++;
broadcast("info", "防抖按钮", `第 ${clickCount.value} 次有效点击`);
};
</script>
<template>
<div class="home-page">
<div class="welcome-section">
<h1 class="title">欢迎使用</h1>
<p class="subtitle">基于 qiankun + Vue3 + Vite 构建的微前端主应用</p>
</div>
<el-button @click="drawer = true">Open</el-button>
<div class="feature-section">
<div class="feature-card">
<div class="feature-icon">微</div>
<h3 class="feature-title">微前端架构</h3>
<p class="feature-desc">
使用 qiankun 实现微前端架构,支持多业务线独立开发与部署。
</p>
</div>
<div class="feature-card">
<div class="feature-icon">速</div>
<h3 class="feature-title">Vue3 + Vite</h3>
<p class="feature-desc">
结合 Vue3 组合式 API 与 Vite 极致构建体验,显著提升开发效率。
</p>
</div>
<div class="feature-card">
<div class="feature-icon">拓</div>
<h3 class="feature-title">灵活扩展</h3>
<p class="feature-desc">
支持动态注册微应用,可按需扩展业务模块与发布策略。
</p>
</div>
<div class="feature-card">
<div class="feature-icon">稳</div>
<h3 class="feature-title">稳定可靠</h3>
<p class="feature-desc">
提供完善的权限体系与平台级监控,保障微前端运行稳定。
</p>
</div>
</div>
<div class="info-section">
<div class="info-card">
<h3>快速开始</h3>
<ul class="info-list">
<li>1. 执行 <code>pnpm install</code> 安装依赖</li>
<li>2. 运行 <code>pnpm dev</code> 启动主应用</li>
<li>3. 启动所需的微应用服务</li>
<li>4. 在 <code>src/qiankun/apps.ts</code> 中注册微应用</li>
</ul>
</div>
<div class="info-card">
<h3>微应用列表</h3>
<ul class="app-list">
<li v-for="app in apps" :key="app.name" class="app-item">
<span class="app-name">{{ app.name }}</span>
<span class="app-port">{{ app.entry }}</span>
<router-link
v-if="typeof app.activeRule === 'string'"
:to="app.activeRule"
class="app-link"
>
进入 >
</router-link>
<span v-else class="app-link disabled">暂不可用</span>
</li>
</ul>
</div>
</div>
<!-- 通信示例区域 -->
<div class="communication-section">
<h2 class="section-title">
<span class="title-icon">📡</span>
主应用 ↔ 微应用通讯演示
</h2>
<div class="communication-content">
<!-- 左侧:全局状态展示 -->
<div class="state-panel">
<h3 class="panel-title">全局共享状态</h3>
<div v-if="globalState" class="state-content">
<!-- 用户信息 -->
<div class="state-item">
<div class="state-label">👤 当前用户</div>
<div class="state-value">
<span class="user-avatar">{{ globalState.user?.avatar }}</span>
<span
>{{ globalState.user?.name }} ({{
globalState.user?.role
}})</span
>
</div>
<div class="home-page">
<div class="welcome-section">
<h1 class="title">
欢迎使用
</h1>
<p class="subtitle">
基于 qiankun + Vue3 + Vite 构建的微前端主应用
</p>
</div>
<el-button @click="drawer = true">
Open
</el-button>
<div class="feature-section">
<div class="feature-card">
<div class="feature-icon">
微
</div>
<h3 class="feature-title">
微前端架构
</h3>
<p class="feature-desc">
使用 qiankun 实现微前端架构,支持多业务线独立开发与部署。
</p>
</div>
<!-- 主题 -->
<div class="state-item">
<div class="state-label">🎨 主题模式</div>
<div class="state-value">
{{
globalState.theme.mode === 'light' ? '浅色模式' : '深色模式'
}}
<span
class="theme-color"
:style="{ backgroundColor: globalState.theme.primaryColor }"
></span>
</div>
<div class="feature-card">
<div class="feature-icon">
速
</div>
<h3 class="feature-title">
Vue3 + Vite
</h3>
<p class="feature-desc">
结合 Vue3 组合式 API 与 Vite 极致构建体验,显著提升开发效率。
</p>
</div>
<!-- 通知数量 -->
<div class="state-item">
<div class="state-label">🔔 通知数量</div>
<div class="state-value">
<span class="notification-badge">{{
globalState.notifications.length
}}</span>
</div>
<div class="feature-card">
<div class="feature-icon">
拓
</div>
<h3 class="feature-title">
灵活扩展
</h3>
<p class="feature-desc">
支持动态注册微应用,可按需扩展业务模块与发布策略。
</p>
</div>
<!-- API 配置 -->
<div class="state-item">
<div class="state-label">⚙️ API 配置</div>
<div class="state-value state-value-small">
{{ globalState.config.apiBaseUrl }}
</div>
<div class="feature-card">
<div class="feature-icon">
稳
</div>
<h3 class="feature-title">
稳定可靠
</h3>
<p class="feature-desc">
提供完善的权限体系与平台级监控,保障微前端运行稳定。
</p>
</div>
</div>
<div v-else class="state-loading">加载中...</div>
</div>
<!-- 右侧:通信操作区 -->
<div class="action-panel">
<h3 class="panel-title">通信操作</h3>
<!-- 快速发送消息 -->
<div class="action-group">
<div class="action-label">快速发送消息到微应用:</div>
<div class="button-group">
<button
class="action-btn success-btn"
@click="sendSuccessMessage"
>
✓ 发送成功消息
</button>
<div class="info-section">
<div class="info-card">
<h3>快速开始</h3>
<ul class="info-list">
<li>1. 执行 <code>pnpm install</code> 安装依赖</li>
<li>2. 运行 <code>pnpm dev</code> 启动主应用</li>
<li>3. 启动所需的微应用服务</li>
<li>4. 在 <code>src/qiankun/apps.ts</code> 中注册微应用</li>
</ul>
</div>
</div>
<!-- 自定义消息 -->
<div class="action-group">
<div class="action-label">自定义消息:</div>
<input
v-model="messageTitle"
type="text"
class="input-field"
placeholder="消息标题"
/>
<textarea
v-model="messageContent"
class="textarea-field"
placeholder="消息内容"
rows="3"
></textarea>
<button class="action-btn primary-btn" @click="sendCustomMessage">
📤 发送自定义消息
</button>
</div>
<!-- 状态更新操作 -->
<div class="action-group">
<div class="action-label">更新全局状态:</div>
<div class="button-group">
<button class="action-btn theme-btn" @click="toggleTheme">
🎨 切换主题
</button>
<button class="action-btn user-btn" @click="updateUserInfo">
👤 更新用户
</button>
</div>
</div>
</div>
</div>
<!-- 通知消息列表 -->
<div class="notification-panel">
<div class="notification-header">
<h3 class="panel-title">📬 消息通知列表</h3>
<button
v-if="globalState?.notifications.length"
class="clear-btn"
@click="clearAllNotifications"
>
清空全部
</button>
</div>
<div v-if="globalState?.notifications.length" class="notification-list">
<div
v-for="notification in globalState.notifications"
:key="notification.id"
class="notification-item"
:class="[`notification-${notification.type}`]"
>
<div class="notification-icon">
<span v-if="notification.type === 'success'">✓</span>
<span v-else-if="notification.type === 'warning'">⚠</span>
<span v-else-if="notification.type === 'error'">✕</span>
<span v-else>ℹ</span>
</div>
<div class="notification-content">
<div class="notification-title">{{ notification.title }}</div>
<div class="notification-message">{{ notification.message }}</div>
<div class="notification-meta">
<span v-if="notification.from" class="notification-from"
>来自: {{ notification.from }}</span
>
<span class="notification-time">{{
formatTime(notification.timestamp)
}}</span>
</div>
<div class="info-card">
<h3>微应用列表</h3>
<ul class="app-list">
<li v-for="app in apps"
:key="app.name"
class="app-item">
<span class="app-name">{{ app.name }}</span>
<span class="app-port">{{ app.entry }}</span>
<router-link v-if="typeof app.activeRule === 'string'"
class="app-link"
:to="app.activeRule">
进入 >
</router-link>
<span v-else class="app-link disabled">暂不可用</span>
</li>
</ul>
</div>
<button
class="notification-close"
@click="removeNotification(notification.id)"
>
✕
</button>
</div>
</div>
<div v-else class="notification-empty">
<div class="empty-icon">📭</div>
<div class="empty-text">暂无消息通知</div>
<div class="empty-hint">
点击上方按钮发送消息,微应用也可以发送消息到这里
</div>
</div>
</div>
<!-- 使用说明 -->
<div class="usage-tips">
<h4>💡 使用说明</h4>
<ul>
<li>
<strong>全局状态:</strong
>主应用和微应用共享的状态,任何一方修改都会实时同步。
</li>
<li>
<strong>消息通知:</strong
>主应用可以发送通知给微应用,微应用也可以发送通知给主应用。
</li>
<li>
<strong>实时监听:</strong
>状态变化会实时反映在界面上,打开控制台可以看到详细日志。
</li>
<li>
<strong>微应用接入:</strong>微应用通过 props 接收 actions,可以调用
<code>actions.setGlobalState()</code> 和
<code>actions.onGlobalStateChange()</code> 进行通信。
</li>
</ul>
</div>
<!-- Element Plus 原生按钮示例 -->
<div class="component-demo">
<h4 class="demo-title">📦 Element Plus 原生按钮</h4>
<div class="button-demo-group">
<el-button type="primary">Primary</el-button>
<el-button type="success">Success</el-button>
<el-button type="info">Info</el-button>
<el-button type="warning">Warning</el-button>
<el-button type="danger">Danger</el-button>
</div>
</div>
<!-- GLButton 组件库按钮示例 -->
<div class="component-demo">
<h4 class="demo-title">🎨 @venus/common-ui-vue GLButton 组件</h4>
<!-- 基础按钮 -->
<div class="demo-section">
<h5 class="section-subtitle">基础样式</h5>
<div class="button-demo-group">
<GLButton type="primary">主要按钮</GLButton>
<GLButton type="success">成功按钮</GLButton>
<GLButton type="info">信息按钮</GLButton>
<GLButton type="warning">警告按钮</GLButton>
<GLButton type="danger">危险按钮</GLButton>
</div>
</div>
<!-- 加载状态 -->
<div class="demo-section">
<h5 class="section-subtitle">加载状态</h5>
<div class="button-demo-group">
<GLButton type="primary" loading>加载中</GLButton>
<GLButton
type="success"
:loading="buttonLoading"
@click="handleAsyncClick"
>
点击模拟异步操作
</GLButton>
</div>
</div>
<!-- 禁用状态 -->
<div class="demo-section">
<h5 class="section-subtitle">禁用状态</h5>
<div class="button-demo-group">
<GLButton type="primary" disabled>禁用按钮</GLButton>
<GLButton type="success" disabled>禁用按钮</GLButton>
</div>
</div>
<!-- 通信示例区域 -->
<div class="communication-section">
<h2 class="section-title">
<span class="title-icon">📡</span>
主应用 ↔ 微应用通讯演示
</h2>
<div class="communication-content">
<!-- 左侧:全局状态展示 -->
<div class="state-panel">
<h3 class="panel-title">
全局共享状态
</h3>
<div v-if="globalState" class="state-content">
<!-- 用户信息 -->
<div class="state-item">
<div class="state-label">
👤 当前用户
</div>
<div class="state-value">
<span class="user-avatar">{{ globalState.user?.avatar }}</span>
<span>
{{ globalState.user?.name }} ({{
globalState.user?.role
}})
</span>
</div>
</div>
<!-- 主题 -->
<div class="state-item">
<div class="state-label">
🎨 主题模式
</div>
<div class="state-value">
{{
globalState.theme.mode === 'light' ? '浅色模式' : '深色模式'
}}
<span class="theme-color"
:style="{ backgroundColor: globalState.theme.primaryColor }">
</span>
</div>
</div>
<!-- 通知数量 -->
<div class="state-item">
<div class="state-label">
🔔 通知数量
</div>
<div class="state-value">
<span class="notification-badge">
{{
globalState.notifications.length
}}
</span>
</div>
</div>
<!-- API 配置 -->
<div class="state-item">
<div class="state-label">
⚙️ API 配置
</div>
<div class="state-value state-value-small">
{{ globalState.config.apiBaseUrl }}
</div>
</div>
</div>
<div v-else class="state-loading">
加载中...
</div>
</div>
<!-- 右侧:通信操作区 -->
<div class="action-panel">
<h3 class="panel-title">
通信操作
</h3>
<!-- 快速发送消息 -->
<div class="action-group">
<div class="action-label">
快速发送消息到微应用:
</div>
<div class="button-group">
<button class="action-btn success-btn"
@click="sendSuccessMessage">
✓ 发送成功消息
</button>
</div>
</div>
<!-- 自定义消息 -->
<div class="action-group">
<div class="action-label">
自定义消息:
</div>
<input v-model="messageTitle"
class="input-field"
placeholder="消息标题"
type="text" />
<textarea v-model="messageContent"
class="textarea-field"
placeholder="消息内容"
rows="3">
</textarea>
<button class="action-btn primary-btn" @click="sendCustomMessage">
📤 发送自定义消息
</button>
</div>
<!-- 状态更新操作 -->
<div class="action-group">
<div class="action-label">
更新全局状态:
</div>
<div class="button-group">
<button class="action-btn theme-btn" @click="toggleTheme">
🎨 切换主题
</button>
<button class="action-btn user-btn" @click="updateUserInfo">
👤 更新用户
</button>
</div>
</div>
</div>
</div>
<!-- 确认提示 -->
<div class="demo-section">
<h5 class="section-subtitle">确认提示</h5>
<div class="button-demo-group">
<GLButton
type="warning"
confirm-text="确定要执行这个操作吗?"
@click="handleConfirmClick"
>
点击需要确认
</GLButton>
<GLButton
type="danger"
confirm-text="确定要删除吗?此操作不可恢复!"
@click="handleDeleteClick"
>
删除操作
</GLButton>
</div>
</div>
<!-- 通知消息列表 -->
<div class="notification-panel">
<div class="notification-header">
<h3 class="panel-title">
📬 消息通知列表
</h3>
<button v-if="globalState?.notifications.length"
class="clear-btn"
@click="clearAllNotifications">
清空全部
</button>
</div>
<div v-if="globalState?.notifications.length" class="notification-list">
<div v-for="notification in globalState.notifications"
:key="notification.id"
class="notification-item"
:class="[`notification-${notification.type}`]">
<div class="notification-icon">
<span v-if="notification.type === 'success'">✓</span>
<span v-else-if="notification.type === 'warning'">⚠</span>
<span v-else-if="notification.type === 'error'">✕</span>
<span v-else>ℹ</span>
</div>
<div class="notification-content">
<div class="notification-title">
{{ notification.title }}
</div>
<div class="notification-message">
{{ notification.message }}
</div>
<div class="notification-meta">
<span v-if="notification.from"
class="notification-from">
来自: {{ notification.from }}
</span>
<span class="notification-time">
{{
formatTime(notification.timestamp)
}}
</span>
</div>
</div>
<button class="notification-close"
@click="removeNotification(notification.id)">
✕
</button>
</div>
</div>
<div v-else class="notification-empty">
<div class="empty-icon">
📭
</div>
<div class="empty-text">
暂无消息通知
</div>
<div class="empty-hint">
点击上方按钮发送消息,微应用也可以发送消息到这里
</div>
</div>
</div>
<!-- 防抖 -->
<div class="demo-section">
<h5 class="section-subtitle">防抖功能(1秒)</h5>
<div class="button-demo-group">
<GLButton
type="primary"
:debounce="1000"
@click="handleDebounceClick"
>
防抖按钮 (1s)
</GLButton>
<span class="demo-tip">点击次数: {{ clickCount }}</span>
</div>
</div>
<!-- 使用说明 -->
<div class="usage-tips">
<h4>💡 使用说明</h4>
<ul>
<li>
<strong>全局状态:</strong>主应用和微应用共享的状态,任何一方修改都会实时同步。
</li>
<li>
<strong>消息通知:</strong>主应用可以发送通知给微应用,微应用也可以发送通知给主应用。
</li>
<li>
<strong>实时监听:</strong>状态变化会实时反映在界面上,打开控制台可以看到详细日志。
</li>
<li>
<strong>微应用接入:</strong>微应用通过 props 接收 actions,可以调用
<code>actions.setGlobalState()</code> 和
<code>actions.onGlobalStateChange()</code> 进行通信。
</li>
</ul>
</div>
<!-- 图标按钮 -->
<div class="demo-section">
<h5 class="section-subtitle">图标按钮</h5>
<div class="button-demo-group">
<GLButton type="primary" :icon="Search">搜索</GLButton>
<GLButton type="success" :icon="Check">确认</GLButton>
<GLButton type="warning" :icon="Edit">编辑</GLButton>
<GLButton type="danger" :icon="Delete">删除</GLButton>
<GLButton type="info" :icon="Message" circle />
<GLButton type="primary" :icon="Star" circle />
</div>
</div>
<!-- Element Plus 原生按钮示例 -->
<div class="component-demo">
<h4 class="demo-title">
📦 Element Plus 原生按钮
</h4>
<div class="button-demo-group">
<el-button type="primary">
Primary
</el-button>
<el-button type="success">
Success
</el-button>
<el-button type="info">
Info
</el-button>
<el-button type="warning">
Warning
</el-button>
<el-button type="danger">
Danger
</el-button>
</div>
</div>
<!-- 插槽 -->
<div class="demo-section">
<h5 class="section-subtitle">防抖功能(1秒)</h5>
<div class="button-demo-group">
<GLButton
type="primary"
:debounce="1000"
@click="handleDebounceClick"
>
<template #icon>
<span>这是图标</span>
</template>
防抖按钮 (1s)
</GLButton>
<span class="demo-tip">点击次数: {{ clickCount }}</span>
</div>
<!-- GLButton 组件库按钮示例 -->
<div class="component-demo">
<h4 class="demo-title">
🎨 @venus/common-ui-vue GLButton 组件
</h4>
<!-- 基础按钮 -->
<div class="demo-section">
<h5 class="section-subtitle">
基础样式
</h5>
<div class="button-demo-group">
<GLButton type="primary">
主要按钮
</GLButton>
<GLButton type="success">
成功按钮
</GLButton>
<GLButton type="info">
信息按钮
</GLButton>
<GLButton type="warning">
警告按钮
</GLButton>
<GLButton type="danger">
危险按钮
</GLButton>
</div>
</div>
<!-- 加载状态 -->
<div class="demo-section">
<h5 class="section-subtitle">
加载状态
</h5>
<div class="button-demo-group">
<GLButton loading type="primary">
加载中
</GLButton>
<GLButton :loading="buttonLoading"
type="success"
@click="handleAsyncClick">
点击模拟异步操作
</GLButton>
</div>
</div>
<!-- 禁用状态 -->
<div class="demo-section">
<h5 class="section-subtitle">
禁用状态
</h5>
<div class="button-demo-group">
<GLButton disabled type="primary">
禁用按钮
</GLButton>
<GLButton disabled type="success">
禁用按钮
</GLButton>
</div>
</div>
<!-- 确认提示 -->
<div class="demo-section">
<h5 class="section-subtitle">
确认提示
</h5>
<div class="button-demo-group">
<GLButton confirm-text="确定要执行这个操作吗?"
type="warning"
@click="handleConfirmClick">
点击需要确认
</GLButton>
<GLButton confirm-text="确定要删除吗?此操作不可恢复!"
type="danger"
@click="handleDeleteClick">
删除操作
</GLButton>
</div>
</div>
<!-- 防抖 -->
<div class="demo-section">
<h5 class="section-subtitle">
防抖功能(1秒)
</h5>
<div class="button-demo-group">
<GLButton :debounce="1000"
type="primary"
@click="handleDebounceClick">
防抖按钮 (1s)
</GLButton>
<span class="demo-tip">点击次数: {{ clickCount }}</span>
</div>
</div>
<!-- 图标按钮 -->
<div class="demo-section">
<h5 class="section-subtitle">
图标按钮
</h5>
<div class="button-demo-group">
<GLButton :icon="Search" type="primary">
搜索
</GLButton>
<GLButton :icon="Check" type="success">
确认
</GLButton>
<GLButton :icon="Edit" type="warning">
编辑
</GLButton>
<GLButton :icon="Delete" type="danger">
删除
</GLButton>
<GLButton circle
:icon="Message"
type="info" />
<GLButton circle
:icon="Star"
type="primary" />
</div>
</div>
<!-- 插槽 -->
<div class="demo-section">
<h5 class="section-subtitle">
防抖功能(1秒)
</h5>
<div class="button-demo-group">
<GLButton :debounce="1000"
type="primary"
@click="handleDebounceClick">
<template #icon>
<span>这是图标</span>
</template>
防抖按钮 (1s)
</GLButton>
<span class="demo-tip">点击次数: {{ clickCount }}</span>
</div>
</div>
</div>
</div>
</div>
<el-drawer v-model="drawer"
title="I am the title"
:with-header="false">
<span>Hi there!</span>
</el-drawer>
</div>
<el-drawer v-model="drawer" title="I am the title" :with-header="false">
<span>Hi there!</span>
</el-drawer>
</div>
</template>
<style scoped>
......
<script setup lang="ts">
import { onMounted, onUnmounted, nextTick } from 'vue';
import { useRoute } from 'vue-router';
import { nextTick, onMounted, onUnmounted } from "vue";
import { useRoute } from "vue-router";
import GlobalLoading from '@/components/GlobalLoading.vue';
import GlobalLoading from "@/components/GlobalLoading.vue";
const route = useRoute();
onMounted(async () => {
console.log('[基座] 微应用容器组件已挂载,当前路由:', route.path);
console.log("[基座] 微应用容器组件已挂载,当前路由:", route.path);
// 等待 DOM 完全更新
await nextTick();
// 等待 DOM 完全更新
await nextTick();
// 确认容器元素已存在
const container = document.getElementById('subapp-container');
if (container) {
console.log('[基座] 微应用容器 DOM 已就绪');
} else {
console.error('[基座] 微应用容器 DOM 未找到,可能导致微应用加载失败');
}
// 确认容器元素已存在
const container = document.querySelector("#subapp-container");
if (container) {
console.log("[基座] 微应用容器 DOM 已就绪");
} else {
console.error("[基座] 微应用容器 DOM 未找到,可能导致微应用加载失败");
}
});
onUnmounted(() => {
console.log('[基座] 微应用容器已卸载');
console.log("[基座] 微应用容器已卸载");
});
</script>
<template>
<div class="micro-app-wrapper">
<!-- qiankun 微应用容器 - 作为唯一的微应用挂载点 -->
<div id="subapp-container" class="micro-app-container"></div>
<!-- 子应用加载中的 loading -->
<GlobalLoading />
</div>
<div class="micro-app-wrapper">
<!-- qiankun 微应用容器 - 作为唯一的微应用挂载点 -->
<div id="subapp-container" class="micro-app-container"></div>
<!-- 子应用加载中的 loading -->
<GlobalLoading />
</div>
</template>
<style scoped>
......
# EXAMPLE USAGE:
#
# Refer for explanation to following link:
# https://lefthook.dev/configuration/
#
# pre-push:
# jobs:
# - name: packages audit
# tags:
# - frontend
# - security
# run: yarn audit
#
# - name: gems audit
# tags:
# - backend
# - security
# run: bundle audit
#
# pre-commit:
# parallel: true
# jobs:
# - run: yarn eslint {staged_files}
# glob: "*.{js,ts,jsx,tsx}"
#
# - name: rubocop
# glob: "*.rb"
# exclude:
# - config/application.rb
# - config/routes.rb
# run: bundle exec rubocop --force-exclusion {all_files}
#
# - name: govet
# files: git ls-files -m
# glob: "*.go"
# run: go vet {files}
#
# - script: "hello.js"
# runner: node
#
# - script: "hello.go"
# runner: go run
pre-commit:
parallel: true
commands:
code-workspace:
run: pnpm vsh code-workspace --auto-commit
# lint-staged:
# run: pnpm lint-staged
lint-staged:
run: pnpm lint-staged
post-merge:
commands:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!