Commit 064099dd by Jaxon

style: monorepo 根项目配置文件格式化

1 parent 91142695
Showing 143 changed files with 1601 additions and 1348 deletions
export default {
"*.{js,ts,tsx,jsx,vue}": ["prettier --write", "eslint --fix"],
"*.{md,json,css,less,scss}": ["prettier --write"],
"*.{js,ts,tsx,jsx,vue}": [ "prettier --write", "eslint --fix" ],
"*.{md,json,css,less,scss}": [ "prettier --write" ],
};
......@@ -2,7 +2,6 @@ dist
dev-dist
.local
.output.js
node_modules
.nvmrc
coverage
CODEOWNERS
......@@ -14,6 +13,7 @@ CODEOWNERS
**/*.ts
**/*.jsx
**/*.tsx
**/*.json
**/*.wxs
**/*.svg
**/*.sh
......@@ -22,8 +22,10 @@ public
.npmrc
*-lock.yaml
node_modules
miniprogram_npm
uni_modules
wxcomponents
# 只格式化 wxml
!*.wxml
......
......@@ -4,3 +4,4 @@ __tests__
coverage
miniprogram_npm
uni_modules
wxcomponents
{
"servers": {
"ESLint": {
"type": "stdio",
"command": "npx",
"args": [
"@eslint/mcp@latest"
]
}
},
"inputs": []
}
<template>
<div id="micro-app" class="micro-app-container">
<header class="app-header">
<h1>🚀 Vue3 微前端子应用</h1>
<nav class="nav-menu">
<router-link class="nav-link" to="/">
首页
</router-link>
<router-link class="nav-link" to="/about">
关于
</router-link>
<router-link class="nav-link" to="/communication">
通信示例
</router-link>
<router-link class="nav-link" to="/user">
用户管理
</router-link>
<router-link class="nav-link" to="/settings">
系统设置
</router-link>
</nav>
</header>
<main class="app-main">
<router-view v-slot="{ Component }">
<transition mode="out-in" name="fade">
<component :is="Component" />
</transition>
</router-view>
</main>
<footer class="app-footer">
<p>© 2025 Venus 微前端子应用模板</p>
</footer>
</div>
</template>
<script setup lang="ts">
import { onMounted } from "vue";
......@@ -6,33 +43,6 @@ onMounted(() => {
});
</script>
<template>
<div id="micro-app" class="micro-app-container">
<header class="app-header">
<h1>🚀 Vue3 微前端子应用</h1>
<nav class="nav-menu">
<router-link to="/" class="nav-link">首页</router-link>
<router-link to="/about" class="nav-link">关于</router-link>
<router-link to="/communication" class="nav-link">通信示例</router-link>
<router-link to="/user" class="nav-link">用户管理</router-link>
<router-link to="/settings" class="nav-link">系统设置</router-link>
</nav>
</header>
<main class="app-main">
<router-view v-slot="{ Component }">
<transition name="fade" mode="out-in">
<component :is="Component" />
</transition>
</router-view>
</main>
<footer class="app-footer">
<p>© 2025 Venus 微前端子应用模板</p>
</footer>
</div>
</template>
<style scoped>
.micro-app-container {
display: flex;
......
......@@ -164,7 +164,7 @@ class SubAppCommunicationManager {
// 注意:这里需要基座的 communication manager 来处理通知添加逻辑
// 所以我们实际上是触发一个状态变化,让基座来处理
this.setGlobalState({
notifications: [newNotification] as any, // 基座会合并到现有通知列表
notifications: [ newNotification ] as any, // 基座会合并到现有通知列表
});
}
......
<script setup lang="ts">
// About 页面
</script>
<template>
<div class="about-view">
<div class="content-card">
<h1>📖 关于本应用</h1>
<section class="section">
<h2>技术栈</h2>
<ul class="tech-list">
<li>
<strong>Vue 3</strong>
- 渐进式 JavaScript 框架
</li>
<li>
<strong>TypeScript</strong>
- 类型安全的 JavaScript 超集
</li>
<li>
<strong>Vite</strong>
- 新一代前端构建工具
</li>
<li>
<strong>Vue Router</strong>
- 官方路由管理器
</li>
<li>
<strong>Pinia</strong>
- 新一代状态管理库
</li>
<li>
<strong>qiankun</strong>
- 微前端框架
</li>
</ul>
</section>
<section class="section">
<h2>功能特性</h2>
<ul class="feature-list">
<li>✅ 支持独立运行和基座集成</li>
<li>✅ 完整的 TypeScript 支持</li>
<li>✅ 自动导入 API 和组件</li>
<li>✅ 热模块替换 (HMR)</li>
<li>✅ 路由懒加载</li>
<li>✅ CSS 样式隔离</li>
</ul>
</section>
<section class="section">
<h2>快速开始</h2>
<div class="code-block">
<pre><code># 安装依赖
<div class="about-view">
<div class="content-card">
<h1>📖 关于本应用</h1>
<section class="section">
<h2>技术栈</h2>
<ul class="tech-list">
<li>
<strong>Vue 3</strong>
- 渐进式 JavaScript 框架
</li>
<li>
<strong>TypeScript</strong>
- 类型安全的 JavaScript 超集
</li>
<li>
<strong>Vite</strong>
- 新一代前端构建工具
</li>
<li>
<strong>Vue Router</strong>
- 官方路由管理器
</li>
<li>
<strong>Pinia</strong>
- 新一代状态管理库
</li>
<li>
<strong>qiankun</strong>
- 微前端框架
</li>
</ul>
</section>
<section class="section">
<h2>功能特性</h2>
<ul class="feature-list">
<li>✅ 支持独立运行和基座集成</li>
<li>✅ 完整的 TypeScript 支持</li>
<li>✅ 自动导入 API 和组件</li>
<li>✅ 热模块替换 (HMR)</li>
<li>✅ 路由懒加载</li>
<li>✅ CSS 样式隔离</li>
</ul>
</section>
<section class="section">
<h2>快速开始</h2>
<div class="code-block">
<pre>
<code>
# 安装依赖
pnpm install
# 启动开发服务器
pnpm dev
# 构建生产版本
pnpm build</code></pre>
</div>
</section>
</div>
</div>
pnpm build
</code>
</pre>
</div>
</section>
</div>
</div>
</template>
<script setup lang="ts">
// About 页面
</script>
<style scoped>
.about-view {
max-width: 900px;
......
<template>
<div class="notfound-view">
<div class="content-card">
<div class="error-code">
404
</div>
<h1>页面未找到</h1>
<p>抱歉,您访问的页面不存在或已被删除</p>
<button class="btn-home" @click="goHome">
🏠 返回首页
</button>
</div>
</div>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";
......@@ -8,17 +23,6 @@ const goHome = () => {
};
</script>
<template>
<div class="notfound-view">
<div class="content-card">
<div class="error-code">404</div>
<h1>页面未找到</h1>
<p>抱歉,您访问的页面不存在或已被删除</p>
<button @click="goHome" class="btn-home">🏠 返回首页</button>
</div>
</div>
</template>
<style scoped>
.notfound-view {
display: flex;
......
<template>
<div class="settings-view">
<div class="content-card">
<h1>⚙️ 系统设置</h1>
<div class="settings-grid">
<div class="setting-group">
<h2>🎨 主题设置</h2>
<div class="setting-item">
<label>主题色:</label>
<select v-model="settings.theme" class="select-input">
<option value="purple">
紫色
</option>
<option value="blue">
蓝色
</option>
<option value="green">
绿色
</option>
<option value="orange">
橙色
</option>
</select>
</div>
<div class="setting-item">
<label>暗黑模式:</label>
<input v-model="settings.darkMode"
class="checkbox-input"
type="checkbox" />
</div>
</div>
<div class="setting-group">
<h2>🔔 通知设置</h2>
<div class="setting-item">
<label>桌面通知:</label>
<input v-model="settings.notifications.desktop"
class="checkbox-input"
type="checkbox" />
</div>
<div class="setting-item">
<label>邮件通知:</label>
<input v-model="settings.notifications.email"
class="checkbox-input"
type="checkbox" />
</div>
<div class="setting-item">
<label>短信通知:</label>
<input v-model="settings.notifications.sms"
class="checkbox-input"
type="checkbox" />
</div>
</div>
<div class="setting-group">
<h2>🌐 语言设置</h2>
<div class="setting-item">
<label>界面语言:</label>
<select v-model="settings.language" class="select-input">
<option value="zh-CN">
简体中文
</option>
<option value="en-US">
English
</option>
<option value="ja-JP">
日本語
</option>
</select>
</div>
<div class="setting-item">
<label>时区:</label>
<select v-model="settings.timezone" class="select-input">
<option value="Asia/Shanghai">
北京时间 (UTC+8)
</option>
<option value="America/New_York">
纽约时间 (UTC-5)
</option>
<option value="Europe/London">
伦敦时间 (UTC+0)
</option>
</select>
</div>
</div>
<div class="setting-group">
<h2>🔒 安全设置</h2>
<div class="setting-item">
<label>双因素认证:</label>
<input v-model="settings.security.twoFactor"
class="checkbox-input"
type="checkbox" />
</div>
<div class="setting-item">
<label>会话超时 (分钟):</label>
<input v-model="settings.security.sessionTimeout"
class="number-input"
max="120"
min="5"
type="number" />
</div>
</div>
</div>
<div class="actions">
<button class="btn-save" @click="saveSettings">
💾 保存设置
</button>
<button class="btn-reset" @click="resetSettings">
🔄 重置默认
</button>
</div>
<div class="current-settings">
<h3>当前配置 (JSON)</h3>
<pre>{{ JSON.stringify(settings, null, 2) }}</pre>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { reactive } from "vue";
......@@ -37,6 +160,7 @@ const settings = reactive<Settings>({ ...defaultSettings });
const saveSettings = () => {
console.log("保存设置:", settings);
/* eslint-disable no-alert */
alert("设置已保存!");
};
......@@ -48,96 +172,6 @@ const resetSettings = () => {
};
</script>
<template>
<div class="settings-view">
<div class="content-card">
<h1>⚙️ 系统设置</h1>
<div class="settings-grid">
<div class="setting-group">
<h2>🎨 主题设置</h2>
<div class="setting-item">
<label>主题色:</label>
<select v-model="settings.theme" class="select-input">
<option value="purple">紫色</option>
<option value="blue">蓝色</option>
<option value="green">绿色</option>
<option value="orange">橙色</option>
</select>
</div>
<div class="setting-item">
<label>暗黑模式:</label>
<input type="checkbox" v-model="settings.darkMode" class="checkbox-input" />
</div>
</div>
<div class="setting-group">
<h2>🔔 通知设置</h2>
<div class="setting-item">
<label>桌面通知:</label>
<input type="checkbox" v-model="settings.notifications.desktop" class="checkbox-input" />
</div>
<div class="setting-item">
<label>邮件通知:</label>
<input type="checkbox" v-model="settings.notifications.email" class="checkbox-input" />
</div>
<div class="setting-item">
<label>短信通知:</label>
<input type="checkbox" v-model="settings.notifications.sms" class="checkbox-input" />
</div>
</div>
<div class="setting-group">
<h2>🌐 语言设置</h2>
<div class="setting-item">
<label>界面语言:</label>
<select v-model="settings.language" class="select-input">
<option value="zh-CN">简体中文</option>
<option value="en-US">English</option>
<option value="ja-JP">日本語</option>
</select>
</div>
<div class="setting-item">
<label>时区:</label>
<select v-model="settings.timezone" class="select-input">
<option value="Asia/Shanghai">北京时间 (UTC+8)</option>
<option value="America/New_York">纽约时间 (UTC-5)</option>
<option value="Europe/London">伦敦时间 (UTC+0)</option>
</select>
</div>
</div>
<div class="setting-group">
<h2>🔒 安全设置</h2>
<div class="setting-item">
<label>双因素认证:</label>
<input type="checkbox" v-model="settings.security.twoFactor" class="checkbox-input" />
</div>
<div class="setting-item">
<label>会话超时 (分钟):</label>
<input
type="number"
v-model="settings.security.sessionTimeout"
class="number-input"
min="5"
max="120" />
</div>
</div>
</div>
<div class="actions">
<button @click="saveSettings" class="btn-save">💾 保存设置</button>
<button @click="resetSettings" class="btn-reset">🔄 重置默认</button>
</div>
<div class="current-settings">
<h3>当前配置 (JSON)</h3>
<pre>{{ JSON.stringify(settings, null, 2) }}</pre>
</div>
</div>
</div>
</template>
<style scoped>
.settings-view {
max-width: 1200px;
......
<template>
<div class="user-view">
<div class="content-card">
<h1>👥 用户管理</h1>
<div class="toolbar">
<button class="btn-add" @click="addUser">
➕ 新增用户
</button>
</div>
<div class="table-container">
<table class="user-table">
<thead>
<tr>
<th>ID</th>
<th>姓名</th>
<th>邮箱</th>
<th>角色</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="user in users" :key="user.id">
<td>{{ user.id }}</td>
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
<td>
<span class="badge" :class="`badge-${user.role}`">
{{ user.role }}
</span>
</td>
<td>
<span class="status" :class="user.active ? 'status-active' : 'status-inactive'">
{{ user.active ? "在线" : "离线" }}
</span>
</td>
<td>
<button class="btn-edit" @click="editUser(user)">
编辑
</button>
<button class="btn-delete" @click="deleteUser(user.id)">
删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
......@@ -53,65 +107,17 @@ const addUser = () => {
const editUser = (user: User) => {
console.log("编辑用户:", user);
alert(`编辑用户: ${user.name}`);
};
const deleteUser = (id: number) => {
const index = users.value.findIndex((u) => u.id === id);
// eslint-disable-next-line
if (index !== -1 && confirm(`确定要删除用户 ${users.value[index].name} 吗?`)) {
users.value.splice(index, 1);
}
};
</script>
<template>
<div class="user-view">
<div class="content-card">
<h1>👥 用户管理</h1>
<div class="toolbar">
<button @click="addUser" class="btn-add">➕ 新增用户</button>
</div>
<div class="table-container">
<table class="user-table">
<thead>
<tr>
<th>ID</th>
<th>姓名</th>
<th>邮箱</th>
<th>角色</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="user in users" :key="user.id">
<td>{{ user.id }}</td>
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
<td>
<span class="badge" :class="`badge-${user.role}`">
{{ user.role }}
</span>
</td>
<td>
<span class="status" :class="user.active ? 'status-active' : 'status-inactive'">
{{ user.active ? "在线" : "离线" }}
</span>
</td>
<td>
<button @click="editUser(user)" class="btn-edit">编辑</button>
<button @click="deleteUser(user.id)" class="btn-delete">删除</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<style scoped>
.user-view {
max-width: 1200px;
......
......@@ -21,7 +21,7 @@ export default defineConfig(({ mode, command }) => {
vueJsx(),
// 自动导入 Vue 相关函数
AutoImport({
imports: ["vue", "vue-router", "pinia"],
imports: [ "vue", "vue-router", "pinia" ],
dts: "src/auto-imports.d.ts",
eslintrc: {
enabled: false,
......@@ -38,7 +38,7 @@ export default defineConfig(({ mode, command }) => {
],
resolve: {
alias: {
"@": resolve(__dirname, "src"),
"@": resolve(import.meta.dirname, "src"),
},
},
server: {
......
<template>
<div id="main-app">
<router-view />
</div>
<div id="main-app">
<router-view />
</div>
</template>
<script setup lang="ts">
......
......@@ -26,8 +26,8 @@ const mockUsers = [
avatar: "👤",
email: "admin@scrm.com",
phone: "13800138000",
roles: ["admin", "user"],
permissions: ["*:*:*"],
roles: [ "admin", "user" ],
permissions: [ "*:*:*" ],
department: "技术部",
position: "系统管理员",
status: 1,
......@@ -43,8 +43,8 @@ const mockUsers = [
avatar: "👨",
email: "user@scrm.com",
phone: "13800138001",
roles: ["user"],
permissions: ["user:read", "user:write"],
roles: [ "user" ],
permissions: [ "user:read", "user:write" ],
department: "销售部",
position: "销售专员",
status: 1,
......@@ -60,8 +60,8 @@ const mockUsers = [
avatar: "🧑",
email: "guest@scrm.com",
phone: "13800138002",
roles: ["guest"],
permissions: ["user:read"],
roles: [ "guest" ],
permissions: [ "user:read" ],
department: "访客",
position: "访客",
status: 1,
......
......@@ -15,7 +15,7 @@ export const config = {
baseURL: "https://dj.glsx.com.cn/rop-dj-smartcarlife/router",
appkey: "d7ffc3346fc9a45bccaaa35300d59022",
secret: "4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353",
timeout: 50000,
timeout: 50_000,
result: {
data_key: "data",
message_key: "message",
......@@ -28,7 +28,7 @@ export const config = {
baseURL: "https://scrm.glsx.com.cn/rop-scrm-shopmall/router",
appkey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
timeout: 50000,
timeout: 50_000,
result: {
data_key: "data",
message_key: "message",
......@@ -41,7 +41,7 @@ export const config = {
baseURL: "http://didicb.glsx.com.cn/router?method=glsx.accounts.biz.common.pictureUpload",
appkey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
timeout: 50000,
timeout: 50_000,
result: {
data_key: "data",
message_key: "message",
......
<template>
<div class="notification-center">
<!-- 通知图标按钮 -->
<div class="notification-badge" @click="togglePanel">
<span class="icon">🔔</span>
<span v-if="unreadCount > 0" class="badge">{{ unreadCount }}</span>
</div>
<!-- 通知面板 -->
<transition name="slide">
<div v-if="showPanel" class="notification-panel">
<div class="panel-header">
<h3>通知中心</h3>
<button v-if="notifications.length > 0"
class="clear-btn"
@click="clearAll">
清空
</button>
</div>
<div class="notification-list">
<div v-for="notification in notifications"
:key="notification.id"
class="notification-item"
:class="[`type-${notification.type}`]">
<div class="notification-icon">
{{ getIcon(notification.type) }}
</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="from">来自: {{ notification.from }}</span>
<span class="time">{{ formatTime(notification.timestamp) }}</span>
</div>
</div>
<button class="close-btn" @click="removeNotification(notification.id)">
✕
</button>
</div>
<div v-if="notifications.length === 0" class="empty-state">
<div class="empty-icon">
📭
</div>
<div class="empty-text">
暂无通知
</div>
</div>
</div>
</div>
</transition>
</div>
</template>
<script setup lang="ts">
import type { GlobalState } from "../qiankun";
......@@ -78,52 +137,6 @@ onUnmounted(() => {
});
</script>
<template>
<div class="notification-center">
<!-- 通知图标按钮 -->
<div class="notification-badge" @click="togglePanel">
<span class="icon">🔔</span>
<span v-if="unreadCount > 0" class="badge">{{ unreadCount }}</span>
</div>
<!-- 通知面板 -->
<transition name="slide">
<div v-if="showPanel" class="notification-panel">
<div class="panel-header">
<h3>通知中心</h3>
<button v-if="notifications.length > 0" @click="clearAll" class="clear-btn">清空</button>
</div>
<div class="notification-list">
<div
v-for="notification in notifications"
:key="notification.id"
class="notification-item"
:class="[`type-${notification.type}`]">
<div class="notification-icon">
{{ getIcon(notification.type) }}
</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="from">来自: {{ notification.from }}</span>
<span class="time">{{ formatTime(notification.timestamp) }}</span>
</div>
</div>
<button @click="removeNotification(notification.id)" class="close-btn">✕</button>
</div>
<div v-if="notifications.length === 0" class="empty-state">
<div class="empty-icon">📭</div>
<div class="empty-text">暂无通知</div>
</div>
</div>
</div>
</transition>
</div>
</template>
<style scoped>
.notification-center {
position: relative;
......
<template>
<div class="sidebar-menu-item">
<!-- 菜单项本身 -->
<div class="menu-item-content"
:class="{
active: isActive,
'has-children': hasChildren,
[`level-${menu.level || 1}`]: true,
}"
@click="handleClick">
<!-- 展开/收起图标 -->
<span v-if="hasChildren"
class="expand-icon"
@click.stop="handleToggle">
{{ isExpanded ? "▼" : "▶" }}
</span>
<!-- 菜单图标 -->
<span v-if="menu.icon" class="menu-icon">{{ menu.icon }}</span>
<!-- 菜单标题 -->
<span class="menu-title">{{ menu.title }}</span>
<!-- 徽章 -->
<span v-if="menu.meta?.badge" class="menu-badge">
{{ menu.meta.badge }}
</span>
</div>
<!-- 子菜单 -->
<transition name="submenu-expand">
<div v-if="hasChildren && isExpanded" class="submenu">
<SidebarMenuItem v-for="child in menu.children"
:key="child.id"
:active-path="activePath"
:expanded-keys="expandedKeys"
:menu="child"
@click="$emit('click', $event)"
@toggle="$emit('toggle', $event)" />
</div>
</transition>
</div>
</template>
<script setup lang="ts">
import type { MenuItem } from "@/types/menu";
import { computed } from "vue";
// eslint-disable-next-line
import SidebarMenuItem from "./SidebarMenuItem.vue";
interface Props {
......@@ -47,50 +92,6 @@ const handleToggle = () => {
};
</script>
<template>
<div class="sidebar-menu-item">
<!-- 菜单项本身 -->
<div
class="menu-item-content"
:class="{
active: isActive,
'has-children': hasChildren,
[`level-${menu.level || 1}`]: true,
}"
@click="handleClick">
<!-- 展开/收起图标 -->
<span v-if="hasChildren" class="expand-icon" @click.stop="handleToggle">
{{ isExpanded ? "▼" : "▶" }}
</span>
<!-- 菜单图标 -->
<span v-if="menu.icon" class="menu-icon">{{ menu.icon }}</span>
<!-- 菜单标题 -->
<span class="menu-title">{{ menu.title }}</span>
<!-- 徽章 -->
<span v-if="menu.meta?.badge" class="menu-badge">
{{ menu.meta.badge }}
</span>
</div>
<!-- 子菜单 -->
<transition name="submenu-expand">
<div v-if="hasChildren && isExpanded" class="submenu">
<SidebarMenuItem
v-for="child in menu.children"
:key="child.id"
:menu="child"
:active-path="activePath"
:expanded-keys="expandedKeys"
@click="$emit('click', $event)"
@toggle="$emit('toggle', $event)" />
</div>
</transition>
</div>
</template>
<style scoped>
.sidebar-menu-item {
width: 100%;
......
<template>
<div class="user-info">
<!-- 已登录状态 -->
<div v-if="userStore.isLoggedIn"
class="user-card"
@click="toggleDropdown">
<div class="user-avatar">
{{ userStore.userAvatar || "👤" }}
</div>
<div class="user-details">
<div class="user-name">
{{ userStore.userName }}
</div>
<div class="user-role">
{{ getRoleText() }}
</div>
</div>
<div class="dropdown-icon">
▼
</div>
<!-- 下拉菜单 -->
<div v-if="showDropdown"
class="user-dropdown"
@click.stop>
<div class="dropdown-header">
<div class="dropdown-avatar">
{{ userStore.userAvatar || "👤" }}
</div>
<div class="dropdown-info">
<div class="dropdown-name">
{{ userStore.userName }}
</div>
<div class="dropdown-id">
ID: {{ userStore.userId }}
</div>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="dropdown-menu">
<div class="menu-item" @click="handleProfile">
<span class="menu-icon">👤</span>
<span>个人中心</span>
</div>
<div class="menu-item" @click="handleSettings">
<span class="menu-icon">⚙️</span>
<span>设置</span>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="dropdown-footer">
<button class="logout-btn" @click="handleLogout">
<span class="logout-icon">🚪</span>
<span>退出登录</span>
</button>
</div>
</div>
</div>
<!-- 未登录状态 -->
<div v-else class="user-empty">
<router-link class="login-link" to="/login">
登录
</router-link>
</div>
<!-- 确认对话框 -->
<div v-if="showConfirmDialog"
class="confirm-dialog-overlay"
@click="showConfirmDialog = false">
<div class="confirm-dialog" @click.stop>
<div class="dialog-header">
<span class="dialog-icon">❓</span>
<h3 class="dialog-title">
确认退出
</h3>
</div>
<div class="dialog-content">
<p>确定要退出登录吗?</p>
</div>
<div class="dialog-footer">
<button class="dialog-btn cancel-btn" @click="showConfirmDialog = false">
取消
</button>
<button class="dialog-btn confirm-btn" @click="confirmLogout">
确认退出
</button>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { onMounted, onUnmounted, ref } from "vue";
import { useRouter } from "vue-router";
......@@ -92,75 +189,6 @@ onUnmounted(() => {
});
</script>
<template>
<div class="user-info">
<!-- 已登录状态 -->
<div v-if="userStore.isLoggedIn" class="user-card" @click="toggleDropdown">
<div class="user-avatar">{{ userStore.userAvatar || "👤" }}</div>
<div class="user-details">
<div class="user-name">{{ userStore.userName }}</div>
<div class="user-role">{{ getRoleText() }}</div>
</div>
<div class="dropdown-icon">▼</div>
<!-- 下拉菜单 -->
<div v-if="showDropdown" class="user-dropdown" @click.stop>
<div class="dropdown-header">
<div class="dropdown-avatar">{{ userStore.userAvatar || "👤" }}</div>
<div class="dropdown-info">
<div class="dropdown-name">{{ userStore.userName }}</div>
<div class="dropdown-id">ID: {{ userStore.userId }}</div>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="dropdown-menu">
<div class="menu-item" @click="handleProfile">
<span class="menu-icon">👤</span>
<span>个人中心</span>
</div>
<div class="menu-item" @click="handleSettings">
<span class="menu-icon">⚙️</span>
<span>设置</span>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="dropdown-footer">
<button class="logout-btn" @click="handleLogout">
<span class="logout-icon">🚪</span>
<span>退出登录</span>
</button>
</div>
</div>
</div>
<!-- 未登录状态 -->
<div v-else class="user-empty">
<router-link to="/login" class="login-link">登录</router-link>
</div>
<!-- 确认对话框 -->
<div v-if="showConfirmDialog" class="confirm-dialog-overlay" @click="showConfirmDialog = false">
<div class="confirm-dialog" @click.stop>
<div class="dialog-header">
<span class="dialog-icon">❓</span>
<h3 class="dialog-title">确认退出</h3>
</div>
<div class="dialog-content">
<p>确定要退出登录吗?</p>
</div>
<div class="dialog-footer">
<button class="dialog-btn cancel-btn" @click="showConfirmDialog = false">取消</button>
<button class="dialog-btn confirm-btn" @click="confirmLogout">确认退出</button>
</div>
</div>
</div>
</div>
</template>
<style scoped>
@keyframes dropdown-slide-in {
from {
......
......@@ -193,7 +193,7 @@ export function getMenuParentPaths(menus: MenuItem[], targetPath: string): strin
function findPath(items: MenuItem[], target: string, currentPaths: string[]): boolean {
for (const item of items) {
const newPaths = [...currentPaths, item.path];
const newPaths = [ ...currentPaths, item.path ];
if (item.path === target) {
paths.push(...newPaths);
......
<template>
<div class="basic-layout">
<!-- 顶部导航已隐藏,所有菜单移至侧边栏 -->
<header class="layout-header">
<div class="header-left">
<div class="logo">
<span class="logo-text">SCRM 微前端平台</span>
</div>
</div>
<div class="header-right">
<NotificationCenter />
<UserInfo />
</div>
</header>
<!-- 主体区域 -->
<main class="layout-main">
<!-- 侧边栏 - 显示所有菜单 -->
<aside class="layout-sidebar">
<div class="sidebar-menu">
<!-- 按顶部菜单分组显示所有菜单 -->
<template v-for="topMenu in topMenus" :key="topMenu.id">
<div v-if="topMenu.sidebarMenus && topMenu.sidebarMenus.length > 0" class="menu-group">
<div
class="menu-group-title"
:class="{ active: isTopMenuActive(topMenu.id) }"
@click="handleTopMenuClick(topMenu.id, topMenu.path)">
<span v-if="topMenu.icon" class="group-icon">
{{ topMenu.icon }}
</span>
<span>{{ topMenu.title }}</span>
</div>
<template v-for="item in topMenu.sidebarMenus" :key="item.id">
<SidebarMenuItem
:active-path="route.path"
:expanded-keys="expandedKeys"
:menu="item"
@click="handleMenuClick"
@toggle="handleMenuToggle" />
</template>
</div>
</template>
</div>
</aside>
<!-- 内容区域 -->
<section class="layout-content">
<!-- 面包屑导航 -->
<div v-if="breadcrumbs.length > 0" class="breadcrumb">
<template v-for="(crumb, index) in breadcrumbs" :key="index">
<span
class="breadcrumb-item"
:class="{
clickable: crumb.path && index < breadcrumbs.length - 1,
}"
@click="crumb.path && index < breadcrumbs.length - 1 && router.push(crumb.path)">
{{ crumb.title }}
</span>
<span v-if="index < breadcrumbs.length - 1" class="breadcrumb-separator">/</span>
</template>
</div>
<!-- 微应用内容 -->
<div class="content-wrapper">
<router-view v-slot="{ Component, route: viewRoute }">
<!-- 微应用路由不使用过渡动画,避免延迟容器挂载 -->
<transition v-if="!isMicroAppRoute(viewRoute.path)" mode="out-in" name="fade">
<component :is="Component" />
</transition>
<!-- 微应用路由直接渲染,无过渡 -->
<component :is="Component" v-else />
</router-view>
</div>
</section>
</main>
<!-- 页脚 -->
<footer class="layout-footer">
<div class="footer-content">
<span>(C) 2024 SCRM 微前端平台. All Rights Reserved.</span>
</div>
</footer>
</div>
<div class="basic-layout">
<!-- 顶部导航已隐藏,所有菜单移至侧边栏 -->
<header class="layout-header">
<div class="header-left">
<div class="logo">
<span class="logo-text">SCRM 微前端平台</span>
</div>
</div>
<div class="header-right">
<NotificationCenter />
<UserInfo />
</div>
</header>
<!-- 主体区域 -->
<main class="layout-main">
<!-- 侧边栏 - 显示所有菜单 -->
<aside class="layout-sidebar">
<div class="sidebar-menu">
<!-- 按顶部菜单分组显示所有菜单 -->
<template v-for="topMenu in topMenus" :key="topMenu.id">
<div v-if="topMenu.sidebarMenus && topMenu.sidebarMenus.length > 0" class="menu-group">
<div class="menu-group-title"
:class="{ active: isTopMenuActive(topMenu.id) }"
@click="handleTopMenuClick(topMenu.id, topMenu.path)">
<span v-if="topMenu.icon" class="group-icon">
{{ topMenu.icon }}
</span>
<span>{{ topMenu.title }}</span>
</div>
<template v-for="item in topMenu.sidebarMenus" :key="item.id">
<SidebarMenuItem :active-path="route.path"
:expanded-keys="expandedKeys"
:menu="item"
@click="handleMenuClick"
@toggle="handleMenuToggle" />
</template>
</div>
</template>
</div>
</aside>
<!-- 内容区域 -->
<section class="layout-content">
<!-- 面包屑导航 -->
<div v-if="breadcrumbs.length > 0" class="breadcrumb">
<template v-for="(crumb, index) in breadcrumbs" :key="index">
<span class="breadcrumb-item"
:class="{
clickable: crumb.path && index < breadcrumbs.length - 1,
}"
@click="crumb.path && index < breadcrumbs.length - 1 && router.push(crumb.path)">
{{ crumb.title }}
</span>
<span v-if="index < breadcrumbs.length - 1" class="breadcrumb-separator">/</span>
</template>
</div>
<!-- 微应用内容 -->
<div class="content-wrapper">
<router-view v-slot="{ Component, route: viewRoute }">
<!-- 微应用路由不使用过渡动画,避免延迟容器挂载 -->
<transition v-if="!isMicroAppRoute(viewRoute.path)"
mode="out-in"
name="fade">
<component :is="Component" />
</transition>
<!-- 微应用路由直接渲染,无过渡 -->
<component :is="Component" v-else />
</router-view>
</div>
</section>
</main>
<!-- 页脚 -->
<footer class="layout-footer">
<div class="footer-content">
<span>(C) 2024 SCRM 微前端平台. All Rights Reserved.</span>
</div>
</footer>
</div>
</template>
<script setup lang="ts">
......@@ -133,7 +132,7 @@ const isTopMenuActive = (topMenuId: string): boolean => {
// 面包屑导航
const breadcrumbs = computed<BreadcrumbItem[]>(() => {
const crumbs: BreadcrumbItem[] = [{ title: "首页", path: "/home" }];
const crumbs: BreadcrumbItem[] = [ { title: "首页", path: "/home" } ];
// 如果不在首页,添加当前路由的面包屑
if (route.path !== "/home" && route.path !== "/") {
......
......@@ -61,7 +61,7 @@ const initialState: GlobalState = {
name: "张三仨",
avatar: "👨‍💼",
role: "admin",
permissions: ["read", "write", "delete", "admin"],
permissions: [ "read", "write", "delete", "admin" ],
},
theme: {
mode: "light",
......@@ -101,7 +101,7 @@ class CommunicationManager {
};
this.setGlobalState({
notifications: [...this.currentState.notifications, newNotification],
notifications: [ ...this.currentState.notifications, newNotification ],
});
}
......
<template>
<div class="micro-app-container">
<!-- 微应用加载状态显示 -->
<!-- <div v-if="loading" class="loading-container">
<div class="loading-spinner"></div>
<p class="loading-text">正在加载微应用...</p>
</div>
-->
<!-- 微应用加载失败提示 -->
<div v-if="error" class="error-container">
<div class="error-icon">
⚠️
</div>
<p class="error-text">
{{ error }}
</p>
<button class="retry-button" @click="handleRetry">
重试
</button>
</div>
</div>
</template>
<script setup lang="ts">
import { onMounted, onUnmounted, ref } from "vue";
import { useRoute } from "vue-router";
......@@ -55,23 +78,6 @@ const handleRetry = () => {
};
</script>
<template>
<div class="micro-app-container">
<!-- 微应用加载状态显示 -->
<!-- <div v-if="loading" class="loading-container">
<div class="loading-spinner"></div>
<p class="loading-text">正在加载微应用...</p>
</div>
-->
<!-- 微应用加载失败提示 -->
<div v-if="error" class="error-container">
<div class="error-icon">⚠️</div>
<p class="error-text">{{ error }}</p>
<button class="retry-button" @click="handleRetry">重试</button>
</div>
</div>
</template>
<style scoped>
@keyframes spin {
0% {
......
......@@ -112,7 +112,7 @@ const router = createRouter({
});
// 白名单:不需要登录的路由
const whiteList = new Set(["/forgot-password", "/login", "/register"]);
const whiteList = new Set([ "/forgot-password", "/login", "/register" ]);
/**
* 全局前置守卫
......
<template>
<!-- qiankun 微应用容器 - 作为唯一的微应用挂载点 -->
<div id="subapp-container" class="micro-app-container"></div>
</template>
<script setup lang="ts">
import { onMounted, onUnmounted } from "vue";
import { useRoute } from "vue-router";
......@@ -13,11 +18,6 @@ onUnmounted(() => {
});
</script>
<template>
<!-- qiankun 微应用容器 - 作为唯一的微应用挂载点 -->
<div id="subapp-container" class="micro-app-container"></div>
</template>
<style scoped>
.micro-app-container {
width: 100%;
......
<template>
<div class="not-found-page">
<div class="not-found-content">
<div class="error-code">
404
</div>
<h2 class="error-title">
页面未找到
</h2>
<p class="error-desc">
抱歉,您访问的页面不存在
</p>
<button class="back-button" @click="goHome">
返回首页
</button>
</div>
</div>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";
......@@ -8,17 +27,6 @@ const goHome = () => {
};
</script>
<template>
<div class="not-found-page">
<div class="not-found-content">
<div class="error-code">404</div>
<h2 class="error-title">页面未找到</h2>
<p class="error-desc">抱歉,您访问的页面不存在</p>
<button class="back-button" @click="goHome">返回首页</button>
</div>
</div>
</template>
<style scoped>
.not-found-page {
display: flex;
......
/// <reference types="vite/client" />
// / <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_API_BASE_URL: string;
......
......@@ -12,20 +12,20 @@ export default defineConfig({
vue(),
vueJsx(),
AutoImport({
imports: ["vue", "vue-router", "pinia"],
resolvers: [ElementPlusResolver()],
imports: [ "vue", "vue-router", "pinia" ],
resolvers: [ ElementPlusResolver() ],
dts: "src/auto-imports.d.ts",
}),
Components({
resolvers: [ElementPlusResolver()],
resolvers: [ ElementPlusResolver() ],
dts: "src/components.d.ts",
}),
],
resolve: {
alias: {
"@": resolve(__dirname, "src"),
"@": resolve(import.meta.dirname, "src"),
// 开发环境和构建时都直接使用源代码,避免 stub 模式的 jiti 问题
"@venus/common-ui-vue": resolve(__dirname, "../../../packages/common-ui/vue-ui/src/index.ts"),
"@venus/common-ui-vue": resolve(import.meta.dirname, "../../../packages/common-ui/vue-ui/src/index.ts"),
},
},
server: {
......
<template>
<div id="micro-app" class="micro-app-container">
<header class="app-header">
<div class="header-top">
<h1>🚀 Vue3 微前端子应用</h1>
<div class="header-status">
<span class="status-badge" :class="isQiankunMode ? 'status-active' : 'status-standalone'">
{{ isQiankunMode ? "🔗 已连接主应用" : "🔌 独立运行" }}
</span>
</div>
</div>
<nav class="nav-menu">
<router-link class="nav-link" to="/">
首页
</router-link>
<router-link class="nav-link" to="/about">
关于
</router-link>
<router-link class="nav-link" to="/communication">
通信示例
</router-link>
<router-link class="nav-link" to="/user">
用户管理
</router-link>
<router-link class="nav-link" to="/settings">
系统设置
</router-link>
</nav>
</header>
<main class="app-main">
<router-view v-slot="{ Component }">
<transition mode="out-in" name="fade">
<component :is="Component" />
</transition>
</router-view>
</main>
<footer class="app-footer">
<p>© 2025 Venus 微前端子应用模板</p>
</footer>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
......@@ -7,40 +51,6 @@ import { qiankunWindow } from "vite-plugin-qiankun/dist/helper";
const isQiankunMode = ref(qiankunWindow.__POWERED_BY_QIANKUN__);
</script>
<template>
<div id="micro-app" class="micro-app-container">
<header class="app-header">
<div class="header-top">
<h1>🚀 Vue3 微前端子应用</h1>
<div class="header-status">
<span class="status-badge" :class="isQiankunMode ? 'status-active' : 'status-standalone'">
{{ isQiankunMode ? "🔗 已连接主应用" : "🔌 独立运行" }}
</span>
</div>
</div>
<nav class="nav-menu">
<router-link to="/" class="nav-link">首页</router-link>
<router-link to="/about" class="nav-link">关于</router-link>
<router-link to="/communication" class="nav-link">通信示例</router-link>
<router-link to="/user" class="nav-link">用户管理</router-link>
<router-link to="/settings" class="nav-link">系统设置</router-link>
</nav>
</header>
<main class="app-main">
<router-view v-slot="{ Component }">
<transition name="fade" mode="out-in">
<component :is="Component" />
</transition>
</router-view>
</main>
<footer class="app-footer">
<p>© 2025 Venus 微前端子应用模板</p>
</footer>
</div>
</template>
<style scoped>
/* 响应式设计 */
@media (max-width: 768px) {
......
......@@ -174,7 +174,7 @@ class SubAppCommunicationManager {
// 注意:这里需要基座的 communication manager 来处理通知添加逻辑
// 所以我们实际上是触发一个状态变化,让基座来处理
this.setGlobalState({
notifications: [newNotification] as any, // 基座会合并到现有通知列表
notifications: [ newNotification ] as any, // 基座会合并到现有通知列表
});
}
......
<template>
<div class="communication-page">
<div class="page-header">
<h1>📱 子应用通信示例</h1>
<p class="subtitle">
演示子应用如何与基座进行数据通信
</p>
<div class="mode-badge">
<span v-if="isQiankunMode" class="badge qiankun">🔗 基座模式</span>
<span v-else class="badge standalone">🏠 独立模式</span>
</div>
</div>
<!-- 独立模式提示 -->
<div v-if="!isQiankunMode" class="alert alert-warning">
<div class="alert-icon">
⚠️
</div>
<div class="alert-content">
<h3>独立模式运行</h3>
<p>当前子应用运行在独立模式下,通信功能不可用。</p>
<p>
请通过基座访问以体验完整的通信功能:
<code>http://localhost:8080/subapp-vue/communication</code>
</p>
</div>
</div>
<!-- 通信功能区域 -->
<div v-if="isQiankunMode" class="demo-container">
<div class="demo-section">
<div class="section-header">
<h2>📱 通信功能</h2>
</div>
<div class="section-content">
<div class="info-card">
<h3>通信模块已移除</h3>
<p>子应用的通信模块已移除,所有通信功能由基座统一管理。</p>
<p>如需使用通信功能,请通过基座提供的 props 获取通信管理器实例。</p>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
......@@ -7,48 +53,6 @@ import { qiankunWindow } from "vite-plugin-qiankun/dist/helper";
const isQiankunMode = ref(qiankunWindow.__POWERED_BY_QIANKUN__);
</script>
<template>
<div class="communication-page">
<div class="page-header">
<h1>📱 子应用通信示例</h1>
<p class="subtitle">演示子应用如何与基座进行数据通信</p>
<div class="mode-badge">
<span v-if="isQiankunMode" class="badge qiankun">🔗 基座模式</span>
<span v-else class="badge standalone">🏠 独立模式</span>
</div>
</div>
<!-- 独立模式提示 -->
<div v-if="!isQiankunMode" class="alert alert-warning">
<div class="alert-icon">⚠️</div>
<div class="alert-content">
<h3>独立模式运行</h3>
<p>当前子应用运行在独立模式下,通信功能不可用。</p>
<p>
请通过基座访问以体验完整的通信功能:
<code>http://localhost:8080/subapp-vue/communication</code>
</p>
</div>
</div>
<!-- 通信功能区域 -->
<div v-if="isQiankunMode" class="demo-container">
<div class="demo-section">
<div class="section-header">
<h2>📱 通信功能</h2>
</div>
<div class="section-content">
<div class="info-card">
<h3>通信模块已移除</h3>
<p>子应用的通信模块已移除,所有通信功能由基座统一管理。</p>
<p>如需使用通信功能,请通过基座提供的 props 获取通信管理器实例。</p>
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.communication-page {
max-width: 1400px;
......
<template>
<div class="notfound-view">
<div class="content-card">
<div class="error-code">
404
</div>
<h1>页面未找到</h1>
<p>抱歉,您访问的页面不存在或已被删除</p>
<button class="btn-home" @click="goHome">
🏠 返回首页
</button>
</div>
</div>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";
......@@ -8,17 +23,6 @@ const goHome = () => {
};
</script>
<template>
<div class="notfound-view">
<div class="content-card">
<div class="error-code">404</div>
<h1>页面未找到</h1>
<p>抱歉,您访问的页面不存在或已被删除</p>
<button @click="goHome" class="btn-home">🏠 返回首页</button>
</div>
</div>
</template>
<style scoped>
.notfound-view {
display: flex;
......
<template>
<div class="settings-view">
<div class="content-card">
<h1>⚙️ 系统设置</h1>
<div class="settings-grid">
<div class="setting-group">
<h2>🎨 主题设置</h2>
<div class="setting-item">
<label>主题色:</label>
<select v-model="settings.theme" class="select-input">
<option value="purple">
紫色
</option>
<option value="blue">
蓝色
</option>
<option value="green">
绿色
</option>
<option value="orange">
橙色
</option>
</select>
</div>
<div class="setting-item">
<label>暗黑模式:</label>
<input v-model="settings.darkMode"
class="checkbox-input"
type="checkbox" />
</div>
</div>
<div class="setting-group">
<h2>🔔 通知设置</h2>
<div class="setting-item">
<label>桌面通知:</label>
<input v-model="settings.notifications.desktop"
class="checkbox-input"
type="checkbox" />
</div>
<div class="setting-item">
<label>邮件通知:</label>
<input v-model="settings.notifications.email"
class="checkbox-input"
type="checkbox" />
</div>
<div class="setting-item">
<label>短信通知:</label>
<input v-model="settings.notifications.sms"
class="checkbox-input"
type="checkbox" />
</div>
</div>
<div class="setting-group">
<h2>🌐 语言设置</h2>
<div class="setting-item">
<label>界面语言:</label>
<select v-model="settings.language" class="select-input">
<option value="zh-CN">
简体中文
</option>
<option value="en-US">
English
</option>
<option value="ja-JP">
日本語
</option>
</select>
</div>
<div class="setting-item">
<label>时区:</label>
<select v-model="settings.timezone" class="select-input">
<option value="Asia/Shanghai">
北京时间 (UTC+8)
</option>
<option value="America/New_York">
纽约时间 (UTC-5)
</option>
<option value="Europe/London">
伦敦时间 (UTC+0)
</option>
</select>
</div>
</div>
<div class="setting-group">
<h2>🔒 安全设置</h2>
<div class="setting-item">
<label>双因素认证:</label>
<input v-model="settings.security.twoFactor"
class="checkbox-input"
type="checkbox" />
</div>
<div class="setting-item">
<label>会话超时 (分钟):</label>
<input v-model="settings.security.sessionTimeout"
class="number-input"
max="120"
min="5"
type="number" />
</div>
</div>
</div>
<div class="actions">
<button class="btn-save" @click="saveSettings">
💾 保存设置
</button>
<button class="btn-reset" @click="resetSettings">
🔄 重置默认
</button>
</div>
<div class="current-settings">
<h3>当前配置 (JSON)</h3>
<pre>{{ JSON.stringify(settings, null, 2) }}</pre>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { reactive } from "vue";
......@@ -37,107 +160,20 @@ const settings = reactive<Settings>({ ...defaultSettings });
const saveSettings = () => {
console.log("保存设置:", settings);
// eslint-disable-next-line
alert("设置已保存!");
};
const resetSettings = () => {
// eslint-disable-next-line
if (confirm("确定要重置为默认设置吗?")) {
Object.assign(settings, defaultSettings);
// eslint-disable-next-line
alert("已重置为默认设置!");
}
};
</script>
<template>
<div class="settings-view">
<div class="content-card">
<h1>⚙️ 系统设置</h1>
<div class="settings-grid">
<div class="setting-group">
<h2>🎨 主题设置</h2>
<div class="setting-item">
<label>主题色:</label>
<select v-model="settings.theme" class="select-input">
<option value="purple">紫色</option>
<option value="blue">蓝色</option>
<option value="green">绿色</option>
<option value="orange">橙色</option>
</select>
</div>
<div class="setting-item">
<label>暗黑模式:</label>
<input type="checkbox" v-model="settings.darkMode" class="checkbox-input" />
</div>
</div>
<div class="setting-group">
<h2>🔔 通知设置</h2>
<div class="setting-item">
<label>桌面通知:</label>
<input type="checkbox" v-model="settings.notifications.desktop" class="checkbox-input" />
</div>
<div class="setting-item">
<label>邮件通知:</label>
<input type="checkbox" v-model="settings.notifications.email" class="checkbox-input" />
</div>
<div class="setting-item">
<label>短信通知:</label>
<input type="checkbox" v-model="settings.notifications.sms" class="checkbox-input" />
</div>
</div>
<div class="setting-group">
<h2>🌐 语言设置</h2>
<div class="setting-item">
<label>界面语言:</label>
<select v-model="settings.language" class="select-input">
<option value="zh-CN">简体中文</option>
<option value="en-US">English</option>
<option value="ja-JP">日本語</option>
</select>
</div>
<div class="setting-item">
<label>时区:</label>
<select v-model="settings.timezone" class="select-input">
<option value="Asia/Shanghai">北京时间 (UTC+8)</option>
<option value="America/New_York">纽约时间 (UTC-5)</option>
<option value="Europe/London">伦敦时间 (UTC+0)</option>
</select>
</div>
</div>
<div class="setting-group">
<h2>🔒 安全设置</h2>
<div class="setting-item">
<label>双因素认证:</label>
<input type="checkbox" v-model="settings.security.twoFactor" class="checkbox-input" />
</div>
<div class="setting-item">
<label>会话超时 (分钟):</label>
<input
type="number"
v-model="settings.security.sessionTimeout"
class="number-input"
min="5"
max="120" />
</div>
</div>
</div>
<div class="actions">
<button @click="saveSettings" class="btn-save">💾 保存设置</button>
<button @click="resetSettings" class="btn-reset">🔄 重置默认</button>
</div>
<div class="current-settings">
<h3>当前配置 (JSON)</h3>
<pre>{{ JSON.stringify(settings, null, 2) }}</pre>
</div>
</div>
</div>
</template>
<style scoped>
.settings-view {
max-width: 1200px;
......
<template>
<div class="user-view">
<div class="content-card">
<h1>👥 用户管理</h1>
<div class="toolbar">
<button class="btn-add" @click="addUser">
➕ 新增用户
</button>
</div>
<div class="table-container">
<table class="user-table">
<thead>
<tr>
<th>ID</th>
<th>姓名</th>
<th>邮箱</th>
<th>角色</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="user in users" :key="user.id">
<td>{{ user.id }}</td>
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
<td>
<span class="badge" :class="`badge-${user.role}`">
{{ user.role }}
</span>
</td>
<td>
<span class="status" :class="user.active ? 'status-active' : 'status-inactive'">
{{ user.active ? "在线" : "离线" }}
</span>
</td>
<td>
<button class="btn-edit" @click="editUser(user)">
编辑
</button>
<button class="btn-delete" @click="deleteUser(user.id)">
删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
......@@ -53,65 +107,19 @@ const addUser = () => {
const editUser = (user: User) => {
console.log("编辑用户:", user);
// eslint-disable-next-line
alert(`编辑用户: ${user.name}`);
};
const deleteUser = (id: number) => {
const index = users.value.findIndex((u) => u.id === id);
// eslint-disable-next-line
if (index !== -1 && confirm(`确定要删除用户 ${users.value[index].name} 吗?`)) {
users.value.splice(index, 1);
}
};
</script>
<template>
<div class="user-view">
<div class="content-card">
<h1>👥 用户管理</h1>
<div class="toolbar">
<button @click="addUser" class="btn-add">➕ 新增用户</button>
</div>
<div class="table-container">
<table class="user-table">
<thead>
<tr>
<th>ID</th>
<th>姓名</th>
<th>邮箱</th>
<th>角色</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="user in users" :key="user.id">
<td>{{ user.id }}</td>
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
<td>
<span class="badge" :class="`badge-${user.role}`">
{{ user.role }}
</span>
</td>
<td>
<span class="status" :class="user.active ? 'status-active' : 'status-inactive'">
{{ user.active ? "在线" : "离线" }}
</span>
</td>
<td>
<button @click="editUser(user)" class="btn-edit">编辑</button>
<button @click="deleteUser(user.id)" class="btn-delete">删除</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<style scoped>
.user-view {
max-width: 1200px;
......
{
"compilerOptions": {
"target": "ES2020",
"target": "ES2021",
"jsx": "preserve",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": ["ES2021", "DOM", "DOM.Iterable"],
"useDefineForClassFields": true,
/* Path Alias */
......
......@@ -21,7 +21,7 @@ export default defineConfig(({ mode, command }) => {
vueJsx(),
// 自动导入 Vue 相关函数
AutoImport({
imports: ["vue", "vue-router", "pinia"],
imports: [ "vue", "vue-router", "pinia" ],
dts: "src/auto-imports.d.ts",
eslintrc: {
enabled: false,
......@@ -38,7 +38,7 @@ export default defineConfig(({ mode, command }) => {
],
resolve: {
alias: {
"@": resolve(__dirname, "src"),
"@": resolve(import.meta.dirname, "src"),
},
},
server: {
......
......@@ -81,7 +81,7 @@ export default defineConfig({
],
},
socialLinks: [{ icon: "github", link: "https://github.com/venusjs/vue-venus-admin" }],
socialLinks: [ { icon: "github", link: "https://github.com/venusjs/vue-venus-admin" } ],
// 搜索配置
search: {
......@@ -122,7 +122,7 @@ export default defineConfig({
// 大纲配置
outline: {
level: [2, 3],
level: [ 2, 3 ],
label: "页面导航",
},
......@@ -165,9 +165,9 @@ export default defineConfig({
// 自定义元信息
head: [
["link", { rel: "icon", href: "/favicon.ico" }],
["meta", { name: "theme-color", content: "#646cff" }],
["meta", { name: "og:type", content: "website" }],
["meta", { name: "og:locale", content: "zh-CN" }],
[ "link", { rel: "icon", href: "/favicon.ico" } ],
[ "meta", { name: "theme-color", content: "#646cff" } ],
[ "meta", { name: "og:type", content: "website" } ],
[ "meta", { name: "og:locale", content: "zh-CN" } ],
],
});
......@@ -3,5 +3,5 @@ import { defineBuildConfig } from "unbuild";
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ["src/index"],
entries: [ "src/index" ],
});
......@@ -13,7 +13,7 @@ import type { Linter } from "eslint";
import { interopDefault } from "../util";
export async function comments(): Promise<Linter.Config[]> {
const [pluginComments] = await Promise.all([
const [ pluginComments ] = await Promise.all([
// @ts-expect-error - no types
interopDefault(import("eslint-plugin-eslint-comments")),
] as const);
......@@ -26,7 +26,7 @@ export async function comments(): Promise<Linter.Config[]> {
rules: {
"eslint-comments/no-aggregating-enable": "error",
"eslint-comments/no-duplicate-disable": "error",
"eslint-comments/no-unlimited-disable": "error",
"eslint-comments/no-unlimited-disable": "warn",
"eslint-comments/no-unused-enable": "error",
},
},
......
......@@ -13,7 +13,7 @@ import type { Linter } from "eslint";
export async function disableds(): Promise<Linter.Config[]> {
return [
{
files: ["**/__tests__/**/*.?([cm])[jt]s?(x)"],
files: [ "**/__tests__/**/*.?([cm])[jt]s?(x)" ],
name: "disables/test",
rules: {
"@typescript-eslint/ban-ts-comment": "off",
......@@ -21,14 +21,14 @@ export async function disableds(): Promise<Linter.Config[]> {
},
},
{
files: ["**/*.d.ts"],
files: [ "**/*.d.ts" ],
name: "disables/dts",
rules: {
"@typescript-eslint/triple-slash-reference": "off",
},
},
{
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
files: [ "**/*.js", "**/*.mjs", "**/*.cjs" ],
name: "disables/js",
rules: {
"@typescript-eslint/explicit-module-boundary-types": "off",
......
......@@ -20,7 +20,7 @@ export async function importPluginConfig(): Promise<Linter.Config[]> {
},
rules: {
// 优先在顶层位置声明类型导出,减少嵌套导致的类型混淆
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"import/consistent-type-specifier-style": [ "error", "prefer-top-level" ],
// 导入应集中在文件顶部
"import/first": "error",
// 导入后需换行以增强可读性
......
......@@ -39,15 +39,15 @@ export async function javascript(): Promise<Linter.Config[]> {
linterOptions: {
reportUnusedDisableDirectives: true,
},
ignores: ["**/*.wxml"],
ignores: [ "**/*.wxml" ],
plugins: {
"unused-imports": pluginUnusedImports,
},
rules: {
...js.configs.recommended.rules,
"object-curly-spacing": ["error", "always"],
semi: ["error", "always"],
"array-bracket-spacing": ["error", "always"],
"object-curly-spacing": [ "error", "always" ],
semi: [ "error", "always" ],
"array-bracket-spacing": [ "error", "always" ],
indent: [
"error",
"tab",
......@@ -66,7 +66,7 @@ export async function javascript(): Promise<Linter.Config[]> {
flatTernaryExpressions: false,
},
],
"comma-spacing": ["error", { before: false, after: true }],
"comma-spacing": [ "error", { before: false, after: true } ],
// 允许使用 tab(必须关掉 no-tabs)
"no-tabs": "off",
......@@ -78,16 +78,16 @@ export async function javascript(): Promise<Linter.Config[]> {
allowTemplateLiterals: true,
},
],
"keyword-spacing": ["error", { before: true, after: true }],
"accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
"keyword-spacing": [ "error", { before: true, after: true } ],
"accessor-pairs": [ "error", { enforceForClassMembers: true, setWithoutGet: true } ],
"array-callback-return": "error",
"block-scoped-var": "error",
"constructor-super": "error",
"default-case-last": "error",
"dot-notation": ["error", { allowKeywords: true }],
eqeqeq: ["error", "always"],
"dot-notation": [ "error", { allowKeywords: true } ],
eqeqeq: [ "error", "always" ],
"new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
"new-cap": [ "error", { capIsNew: false, newIsCap: true, properties: true } ],
"no-alert": "error",
"no-array-constructor": "error",
"no-async-promise-executor": "error",
......@@ -95,7 +95,7 @@ export async function javascript(): Promise<Linter.Config[]> {
"no-case-declarations": "error",
"no-class-assign": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": ["error", "always"],
"no-cond-assign": [ "error", "always" ],
"no-console": "off",
"no-const-assign": "error",
"no-control-regex": "error",
......@@ -105,7 +105,7 @@ export async function javascript(): Promise<Linter.Config[]> {
"no-dupe-class-members": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-empty": ["error", { allowEmptyCatch: true }],
"no-empty": [ "error", { allowEmptyCatch: true } ],
"no-empty-character-class": "error",
"no-empty-function": "off",
"no-empty-pattern": "error",
......@@ -122,7 +122,7 @@ export async function javascript(): Promise<Linter.Config[]> {
"no-invalid-regexp": "error",
"no-irregular-whitespace": "error",
"no-iterator": "error",
"no-labels": ["error", { allowLoop: false, allowSwitch: false }],
"no-labels": [ "error", { allowLoop: false, allowSwitch: false } ],
"no-lone-blocks": "error",
"no-loss-of-precision": "error",
"no-misleading-character-class": "error",
......@@ -137,7 +137,7 @@ export async function javascript(): Promise<Linter.Config[]> {
"no-octal-escape": "error",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-redeclare": ["error", { builtinGlobals: false }],
"no-redeclare": [ "error", { builtinGlobals: false } ],
"no-regex-spaces": "error",
"no-restricted-globals": [
"error",
......@@ -175,7 +175,7 @@ export async function javascript(): Promise<Linter.Config[]> {
"TSEnumDeclaration[const=true]",
"TSExportAssignment",
],
"no-self-assign": ["error", { props: true }],
"no-self-assign": [ "error", { props: true } ],
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow-restricted-names": "error",
......@@ -187,7 +187,7 @@ export async function javascript(): Promise<Linter.Config[]> {
"no-undef-init": "error",
"no-unexpected-multiline": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
"no-unneeded-ternary": [ "error", { defaultAssignment: false } ],
"no-unreachable": "error",
"no-unreachable-loop": "error",
"no-unsafe-finally": "error",
......@@ -209,7 +209,7 @@ export async function javascript(): Promise<Linter.Config[]> {
vars: "all",
},
],
"no-use-before-define": ["error", { classes: false, functions: false, variables: false }],
"no-use-before-define": [ "error", { classes: false, functions: false, variables: false } ],
"no-useless-backreference": "error",
"no-useless-call": "error",
"no-useless-catch": "error",
......@@ -219,8 +219,8 @@ export async function javascript(): Promise<Linter.Config[]> {
"no-useless-return": "error",
"no-var": "error",
"no-with": "error",
"object-shorthand": ["error", "always", { avoidQuotes: true, ignoreConstructors: false }],
"one-var": ["error", { initialized: "never" }],
"object-shorthand": [ "error", "always", { avoidQuotes: true, ignoreConstructors: false } ],
"one-var": [ "error", { initialized: "never" } ],
"prefer-arrow-callback": [
"error",
{
......@@ -238,14 +238,14 @@ export async function javascript(): Promise<Linter.Config[]> {
"prefer-exponentiation-operator": "error",
"prefer-promise-reject-errors": "error",
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
"prefer-regex-literals": [ "error", { disallowRedundantWrapping: true } ],
"prefer-rest-params": "warn",
"prefer-spread": "error",
"prefer-template": "error",
"space-before-function-paren": "off",
"spaced-comment": "error",
"symbol-description": "error",
"unicode-bom": ["error", "never"],
"unicode-bom": [ "error", "never" ],
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
......@@ -257,11 +257,11 @@ export async function javascript(): Promise<Linter.Config[]> {
varsIgnorePattern: "^_",
},
],
"use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
"valid-typeof": ["error", { requireStringLiterals: true }],
"use-isnan": [ "error", { enforceForIndexOf: true, enforceForSwitchCase: true } ],
"valid-typeof": [ "error", { requireStringLiterals: true } ],
"vars-on-top": "error",
yoda: ["error", "never"],
yoda: [ "error", "never" ],
},
},
];
......
......@@ -12,7 +12,7 @@ import type { Linter } from "eslint";
import { interopDefault } from "../util";
export async function jsdoc(): Promise<Linter.Config[]> {
const [pluginJsdoc] = await Promise.all([interopDefault(import("eslint-plugin-jsdoc"))] as const);
const [ pluginJsdoc ] = await Promise.all([ interopDefault(import("eslint-plugin-jsdoc")) ] as const);
return [
{
......
......@@ -21,7 +21,7 @@ export async function node(): Promise<Linter.Config[]> {
n: pluginNode,
},
rules: {
"n/handle-callback-err": ["error", "^(err|error)$"],
"n/handle-callback-err": [ "error", "^(err|error)$" ],
"n/no-deprecated-api": "error",
"n/no-exports-assign": "error",
"n/no-extraneous-import": [
......@@ -48,14 +48,14 @@ export async function node(): Promise<Linter.Config[]> {
version: ">=20.12.0",
},
],
"n/prefer-global/buffer": ["error", "never"],
"n/prefer-global/buffer": [ "error", "never" ],
// 'n/no-missing-import': 'off',
"n/prefer-global/process": ["error", "never"],
"n/prefer-global/process": [ "error", "never" ],
"n/process-exit-as-throw": "error",
},
},
{
files: ["scripts/**/*.?([cm])[jt]s?(x)", "internal/**/*.?([cm])[jt]s?(x)"],
files: [ "scripts/**/*.?([cm])[jt]s?(x)", "internal/**/*.?([cm])[jt]s?(x)" ],
rules: {
"n/prefer-global/process": "off",
},
......
......@@ -31,38 +31,38 @@ export async function perfectionist(): Promise<Linter.Config[]> {
{
customGroups: {
type: {
"vben-core-type": ["^@vben-core/.+"],
"vben-type": ["^@venus/.+"],
"vue-type": ["^vue$", "^vue-.+", "^@vue/.+"],
"vben-core-type": [ "^@vben-core/.+" ],
"vben-type": [ "^@venus/.+" ],
"vue-type": [ "^vue$", "^vue-.+", "^@vue/.+" ],
},
value: {
vben: ["^@venus/.+"],
"vben-core": ["^@vben-core/.+"],
vue: ["^vue$", "^vue-.+", "^@vue/.+"],
vben: [ "^@venus/.+" ],
"vben-core": [ "^@vben-core/.+" ],
vue: [ "^vue$", "^vue-.+", "^@vue/.+" ],
},
},
environment: "node",
groups: [
["external-type", "builtin-type", "type"],
[ "external-type", "builtin-type", "type" ],
"vue-type",
"vben-type",
"vben-core-type",
["parent-type", "sibling-type", "index-type"],
["internal-type"],
[ "parent-type", "sibling-type", "index-type" ],
[ "internal-type" ],
"builtin",
"vue",
"vben",
"vben-core",
"external",
"internal",
["parent", "sibling", "index"],
[ "parent", "sibling", "index" ],
"side-effect",
"side-effect-style",
"style",
"object",
"unknown",
],
internalPattern: ["^#/.+"],
internalPattern: [ "^#/.+" ],
newlinesBetween: "always",
order: "asc",
type: "natural",
......@@ -84,8 +84,8 @@ export async function perfectionist(): Promise<Linter.Config[]> {
list: "list",
children: "children",
},
groups: ["unknown", "items", "list", "children"],
ignorePattern: ["children"],
groups: [ "unknown", "items", "list", "children" ],
ignorePattern: [ "children" ],
order: "asc",
type: "natural",
},
......
......@@ -12,7 +12,7 @@ import type { Linter } from "eslint";
import { interopDefault } from "../util";
export async function regexp(): Promise<Linter.Config[]> {
const [pluginRegexp] = await Promise.all([interopDefault(import("eslint-plugin-regexp"))] as const);
const [ pluginRegexp ] = await Promise.all([ interopDefault(import("eslint-plugin-regexp")) ] as const);
return [
{
......
......@@ -13,7 +13,7 @@ import type { Linter } from "eslint";
import { interopDefault } from "../util";
export async function test(): Promise<Linter.Config[]> {
const [pluginTest, pluginNoOnlyTests] = await Promise.all([
const [ pluginTest, pluginNoOnlyTests ] = await Promise.all([
interopDefault(import("eslint-plugin-vitest")),
// @ts-expect-error - no types
interopDefault(import("eslint-plugin-no-only-tests")),
......@@ -40,7 +40,7 @@ export async function test(): Promise<Linter.Config[]> {
rules: {
"no-console": "off",
"node/prefer-global/process": "off",
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
"test/consistent-test-it": [ "error", { fn: "it", withinDescribe: "it" } ],
"test/no-identical-title": "error",
"test/no-import-node-test": "error",
"test/no-only-tests": "error",
......
......@@ -11,7 +11,7 @@ import type { Linter } from "eslint";
import { interopDefault } from "../util";
export async function turbo(): Promise<Linter.Config[]> {
const [pluginTurbo] = await Promise.all([interopDefault(import("eslint-config-turbo"))] as const);
const [ pluginTurbo ] = await Promise.all([ interopDefault(import("eslint-config-turbo")) ] as const);
return [
{
......
......@@ -12,14 +12,14 @@ import type { Linter } from "eslint";
import { interopDefault } from "../util";
export async function typescript(): Promise<Linter.Config[]> {
const [pluginTs, parserTs] = await Promise.all([
const [ pluginTs, parserTs ] = await Promise.all([
interopDefault(import("@typescript-eslint/eslint-plugin")),
interopDefault(import("@typescript-eslint/parser")),
] as const);
return [
{
files: ["**/*.?([cm])[jt]s?(x)"],
files: [ "**/*.?([cm])[jt]s?(x)" ],
languageOptions: {
parser: parserTs,
parserOptions: {
......@@ -29,7 +29,7 @@ export async function typescript(): Promise<Linter.Config[]> {
jsx: true,
},
ecmaVersion: "latest",
extraFileExtensions: [".vue"],
extraFileExtensions: [ ".vue" ],
jsxPragma: "React",
project: "./tsconfig.*.json",
sourceType: "module",
......@@ -61,7 +61,7 @@ export async function typescript(): Promise<Linter.Config[]> {
"@typescript-eslint/no-empty-function": [
"error",
{
allow: ["arrowFunctions", "functions", "methods"],
allow: [ "arrowFunctions", "functions", "methods" ],
},
],
"@typescript-eslint/no-explicit-any": "off",
......@@ -90,7 +90,7 @@ export async function typescript(): Promise<Linter.Config[]> {
function ignoresMiniprogram(pluginTs: any, parserTs: any): Linter.Config {
return {
files: ["apps/miniprogram/**/*.?([cm])[jt]s?(x)"],
files: [ "apps/miniprogram/**/*.?([cm])[jt]s?(x)" ],
languageOptions: {
parser: parserTs,
parserOptions: {
......@@ -99,7 +99,7 @@ function ignoresMiniprogram(pluginTs: any, parserTs: any): Linter.Config {
jsx: true,
},
ecmaVersion: "latest",
extraFileExtensions: [".vue"],
extraFileExtensions: [ ".vue" ],
jsxPragma: "React",
project: "./tsconfig.*.json",
sourceType: "module",
......@@ -121,7 +121,7 @@ function ignoresMiniprogram(pluginTs: any, parserTs: any): Linter.Config {
function ignoresScript(pluginTs: any, parserTs: any): Linter.Config {
return {
files: ["scripts/**/*.?([cm])[jt]s?(x)"],
files: [ "scripts/**/*.?([cm])[jt]s?(x)" ],
languageOptions: {
parser: parserTs,
parserOptions: {
......@@ -130,7 +130,7 @@ function ignoresScript(pluginTs: any, parserTs: any): Linter.Config {
jsx: true,
},
ecmaVersion: "latest",
extraFileExtensions: [".vue"],
extraFileExtensions: [ ".vue" ],
jsxPragma: "React",
project: "./tsconfig.*.json",
sourceType: "module",
......
......@@ -13,14 +13,14 @@ import type { Linter } from "eslint";
import { interopDefault } from "../util";
export async function unicorn(): Promise<Linter.Config[]> {
const [pluginUnicorn] = await Promise.all([interopDefault(import("eslint-plugin-unicorn"))] as const);
const [ pluginUnicorn ] = await Promise.all([ interopDefault(import("eslint-plugin-unicorn")) ] as const);
return [
{
plugins: {
unicorn: pluginUnicorn,
},
ignores: ["**/*.wxml"],
ignores: [ "**/*.wxml" ],
rules: {
...pluginUnicorn.configs.recommended.rules,
"unicorn/no-abusive-eslint-disable": "off",
......@@ -40,14 +40,14 @@ export async function unicorn(): Promise<Linter.Config[]> {
"unicorn/no-useless-undefined": "off",
"unicorn/prefer-at": "off",
"unicorn/prefer-dom-node-text-content": "off",
"unicorn/prefer-export-from": ["error", { ignoreUsedVariables: true }],
"unicorn/prefer-export-from": [ "error", { ignoreUsedVariables: true } ],
"unicorn/prefer-global-this": "off",
"unicorn/prefer-top-level-await": "off",
"unicorn/prevent-abbreviations": "off",
},
},
{
files: ["scripts/**/*.?([cm])[jt]s?(x)", "internal/**/*.?([cm])[jt]s?(x)"],
files: [ "scripts/**/*.?([cm])[jt]s?(x)", "internal/**/*.?([cm])[jt]s?(x)" ],
rules: {
"unicorn/no-process-exit": "off",
},
......
......@@ -12,7 +12,7 @@ import type { Linter } from "eslint";
import { interopDefault } from "../util";
export async function vue(): Promise<Linter.Config[]> {
const [pluginVue, parserVue, parserTs] = await Promise.all([
const [ pluginVue, parserVue, parserTs ] = await Promise.all([
interopDefault(import("eslint-plugin-vue")),
interopDefault(import("vue-eslint-parser")),
interopDefault(import("@typescript-eslint/parser")),
......@@ -28,7 +28,7 @@ export async function vue(): Promise<Linter.Config[]> {
...flatRecommended,
{
// 针对 .vue 文件的专属规则
files: ["**/*.vue"],
files: [ "**/*.vue" ],
languageOptions: {
// globals: {
// computed: 'readonly',
......@@ -51,7 +51,7 @@ export async function vue(): Promise<Linter.Config[]> {
ecmaFeatures: {
jsx: true,
},
extraFileExtensions: [".vue"],
extraFileExtensions: [ ".vue" ],
parser: parserTs,
sourceType: "module",
},
......@@ -64,7 +64,7 @@ export async function vue(): Promise<Linter.Config[]> {
// 继承插件基础规则
...pluginVue.configs?.base?.rules,
"array-bracket-spacing": ["error", "always"],
"array-bracket-spacing": [ "error", "always" ],
/**
* vue/attribute-hyphenation: 要求模板属性使用连字符风格
* 设置原因: HTML 属性习惯上使用连字符(kebab-case),与 HTML 标准一致,便于代码审阅和 HTML 直接识别
......@@ -84,7 +84,7 @@ export async function vue(): Promise<Linter.Config[]> {
"vue/block-order": [
"error",
{
order: ["template", "script", "style"],
order: [ [ "template", "script" ], "style" ],
},
],
......@@ -113,19 +113,19 @@ export async function vue(): Promise<Linter.Config[]> {
* vue/component-name-in-template-casing: 要求模板中的组件使用 PascalCase 命名
* 设置原因: PascalCase 使组件易于识别,与 JavaScript 类的命名约定一致,提高代码可读性
*/
"vue/component-name-in-template-casing": ["error", "PascalCase"],
"vue/component-name-in-template-casing": [ "error", "PascalCase" ],
/**
* vue/component-options-name-casing: 要求组件选项名使用 PascalCase
* 设置原因: 组件选项如 MyComponent 使用 PascalCase,与类和构造函数的命名约定一致
*/
"vue/component-options-name-casing": ["error", "PascalCase"],
"vue/component-options-name-casing": [ "error", "PascalCase" ],
/**
* vue/custom-event-name-casing: 要求自定义事件名使用 camelCase
* 设置原因: camelCase 是 JavaScript 事件的标准命名约定(如 onClick、onChange),保持一致性
*/
"vue/custom-event-name-casing": ["error", "camelCase"],
"vue/custom-event-name-casing": [ "error", "camelCase" ],
/**
* vue/define-macros-order: 强制 defineXxx 宏的执行顺序
......@@ -134,7 +134,7 @@ export async function vue(): Promise<Linter.Config[]> {
"vue/define-macros-order": [
"error",
{
order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"],
order: [ "defineOptions", "defineProps", "defineEmits", "defineSlots" ],
},
],
......@@ -142,19 +142,19 @@ export async function vue(): Promise<Linter.Config[]> {
* vue/dot-location: 强制点号位置在属性上
* 设置原因: 点号位于属性左侧(property)时,更符合代码链式调用的视觉习惯
*/
"vue/dot-location": ["error", "property"],
"vue/dot-location": [ "error", "property" ],
/**
* vue/dot-notation: 要求使用点号记法而不是括号记法访问属性
* 设置原因: 点号记法(obj.prop)比括号记法(obj['prop'])更简洁易读,allowKeywords 允许使用保留字作属性
*/
"vue/dot-notation": ["error", { allowKeywords: true }],
"vue/dot-notation": [ "error", { allowKeywords: true } ],
/**
* vue/eqeqeq: 要求使用 === 和 !== 而不是 == 和 !=
* 设置原因: smart 模式允许与 null 比较时使用 ==,避免隐式类型转换导致的 bug,同时保持常见情况的简洁
*/
"vue/eqeqeq": ["error", "smart"],
"vue/eqeqeq": [ "error", "smart" ],
// 控制 Vue 模板中 HTML 标签的缩进
"vue/html-indent": [
"error",
......@@ -172,7 +172,7 @@ export async function vue(): Promise<Linter.Config[]> {
* vue/html-quotes: 要求 HTML 属性值使用双引号
* 设置原因: 双引号是 HTML 的标准写法,与代码规范一致,提高统一性
*/
"vue/html-quotes": ["error", "double"],
"vue/html-quotes": [ "error", "double" ],
/**
* vue/max-attributes-per-line: 强制:Vue 元素属性每行最多数量限制
......@@ -198,7 +198,7 @@ export async function vue(): Promise<Linter.Config[]> {
"vue/singleline-html-element-content-newline": [
"error",
{
externalIgnores: ["text"], // 忽略 <text> 标签(单行 <text> 内容无需换行,适用于 Vue 小程序等场景)
externalIgnores: [ "text" ], // 忽略 <text> 标签(单行 <text> 内容无需换行,适用于 Vue 小程序等场景)
},
],
// 强制:Vue 元素首属性的换行格式
......@@ -240,13 +240,13 @@ export async function vue(): Promise<Linter.Config[]> {
* vue/no-empty-pattern: 禁止空的解构模式
* 设置原因: 空模式 {} 或 [] 表示的意图不明确,通常是代码错误,应该避免
*/
"vue/no-empty-pattern": ["error", { allowObjectPatternsAsParameters: false }],
"vue/no-empty-pattern": [ "error", { "allowObjectPatternsAsParameters": false } ],
/**
* vue/no-extra-parens: 禁止不必要的括号
* 设置原因: 仅禁止函数表达式的多余括号,保持代码简洁,避免视觉混乱
*/
"vue/no-extra-parens": ["error", "functions"],
"vue/no-extra-parens": [ "error", "functions" ],
/**
* vue/no-irregular-whitespace: 禁止不规则的空白符
......@@ -270,13 +270,13 @@ export async function vue(): Promise<Linter.Config[]> {
* vue/no-restricted-syntax: 禁止某些语法结构
* 设置原因: 禁止 debugger(生产遗留)、标记语句(不推荐)和 with 语句(易出错),提高代码质量
*/
"vue/no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
"vue/no-restricted-syntax": [ "error", "DebuggerStatement", "LabeledStatement", "WithStatement" ],
/**
* vue/no-restricted-v-bind: 禁止 v-bind 绑定以 'v-' 开头的属性
* 设置原因: 以 'v-' 开头的属性是 Vue 指令前缀,不应通过 v-bind 动态绑定,避免混淆
*/
"vue/no-restricted-v-bind": ["error", "/^v-/"],
"vue/no-restricted-v-bind": [ "error", "/^v-/" ],
/**
* vue/no-sparse-arrays: 禁止稀疏数组(数组中有空槽)
......@@ -337,7 +337,7 @@ export async function vue(): Promise<Linter.Config[]> {
* vue/prop-name-casing: 要求 prop 名使用 camelCase
* 设置原因: JavaScript 对象属性使用 camelCase,props 作为 JavaScript 对象属性应保持一致
*/
"vue/prop-name-casing": ["error", "camelCase"],
"vue/prop-name-casing": [ "error", "camelCase" ],
/**
* vue/require-default-prop: 要求所有 prop 有默认值
......@@ -367,7 +367,7 @@ export async function vue(): Promise<Linter.Config[]> {
* vue/space-unary-ops: 要求一元操作符前后有空格
* 设置原因: typeof x 比 typeosx 清晰,words 为 true 使 typeof、delete 等词类操作符前后加空格,nonwords 为 false 不要求 ++、-- 前后空格
*/
"vue/space-unary-ops": ["error", { nonwords: false, words: true }],
"vue/space-unary-ops": [ "error", { nonwords: false, words: true } ],
/**
* vue/v-on-event-hyphenation: 要求 v-on 事件名使用连字符风格
......
......@@ -21,7 +21,7 @@ export function wxmlConfig(): Linter.Config[] {
return [
{
files: ["**/*.wxml", "**/*.wxs"],
files: [ "**/*.wxml", "**/*.wxs" ],
languageOptions: {
parser: wxmlParserWithMeta,
},
......@@ -211,7 +211,7 @@ export function wxmlConfig(): Linter.Config[] {
* ✅ 正确: <view wx:if="{{show}}">{{title}}</view>
* ❌ 错误: <component attr='{{data}}' />
*/
"wxml/quotes": ["error", "double"],
"wxml/quotes": [ "error", "double" ],
// ===========================
// 事件绑定相关规则
......@@ -224,7 +224,7 @@ export function wxmlConfig(): Linter.Config[] {
* ✅ 正确 (colon style): <view bind:tap="clickhandler" />, <view mut-bind:tap="clickhandler" />, <view catch:tap="clickhandler" />
* ❌ 错误 (no-colon style): <view bindtap="clickhandler" />
*/
"wxml/event-binding-style": ["error", "colon"],
"wxml/event-binding-style": [ "error", "colon" ],
// ===========================
// wx:for 和 wx:key 相关规则
......@@ -305,7 +305,7 @@ export function wxmlConfig(): Linter.Config[] {
* ✅ 正确: <view depth="1"><view depth="2"><view depth="3"></view></view><view depth="2"></view></view>
* ❌ 错误: 超过配置的最大深度
*/
"wxml/max-depth": ["warn", 10],
"wxml/max-depth": [ "warn", 10 ],
/**
* 强制文件的最大行数
......@@ -314,7 +314,7 @@ export function wxmlConfig(): Linter.Config[] {
* ✅ 正确: 文件行数不超过指定数量
* ❌ 错误: 超过最大行数的文件
*/
"wxml/max-lines": ["warn", { max: 500 }],
"wxml/max-lines": [ "warn", { max: 500 } ],
// ===========================
// 其他规则
......
......@@ -14,6 +14,6 @@ import { customConfigMiniprogram } from "./miniprogram";
import { customConfigUniapp } from "./uniapp";
import { customConfigVben } from "./vben";
const customConfig: Linter.Config[] = [...customConfigVben(), ...customConfigMiniprogram(), ...customConfigUniapp()];
const customConfig: Linter.Config[] = [ ...customConfigVben(), ...customConfigMiniprogram(), ...customConfigUniapp() ];
export { customConfig };
......@@ -5,7 +5,7 @@ import type { Linter } from "eslint";
export function customConfigMiniprogram(): Linter.Config[] {
return [
{
files: ["apps/**/miniprogram/**/*.?([cm])[jt]s?(x)"],
files: [ "apps/**/miniprogram/**/*.?([cm])[jt]s?(x)" ],
rules: {
// ==================== CommonJS 相关 ====================
// 小程序强制使用 CommonJS,不支持 ES Modules 语法
......
......@@ -3,11 +3,12 @@ import type { Linter } from "eslint";
export function customConfigUniapp(): Linter.Config[] {
return [
{
files: ["apps/**/uniapp/**/**"],
files: [ "apps/**/uniapp/**/**" ],
rules: {
"eslint-comments/no-unlimited-disable": "off",
"unicorn/prefer-module": "warn",
},
},
];
}
import type { Linter } from "eslint";
const restrictedImportIgnores = ["**/vite.config.mts", "**/tailwind.config.mjs", "**/postcss.config.mjs"];
const restrictedImportIgnores = [ "**/vite.config.mts", "**/tailwind.config.mjs", "**/postcss.config.mjs" ];
export function customConfigVben(): Linter.Config[] {
return [
{
files: ["**/**/playwright.config.ts"],
files: [ "**/**/playwright.config.ts" ],
rules: {
"n/prefer-global/buffer": "off",
"n/prefer-global/process": "off",
......@@ -12,14 +12,14 @@ export function customConfigVben(): Linter.Config[] {
},
},
{
files: ["internal/**/**", "scripts/**/**"],
files: [ "internal/**/**", "scripts/**/**" ],
rules: {
"no-console": "off",
},
},
// shadcn-ui 内部组件是自动生成的,不做太多限制
{
files: ["packages/@core/ui-kit/shadcn-ui/**/**"],
files: [ "packages/@core/ui-kit/shadcn-ui/**/**" ],
rules: {
"vue/require-default-prop": "off",
},
......@@ -39,114 +39,114 @@ export function customConfigVben(): Linter.Config[] {
},
},
{
files: ["**/**.vue"],
files: [ "**/**.vue" ],
ignores: restrictedImportIgnores,
rules: {
"perfectionist/sort-objects": "off",
},
},
{
// apps内部的一些基础规则
files: ["apps/**/**"],
ignores: restrictedImportIgnores,
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["#/api/*"],
message: "The #/api package cannot be imported, please use the @core package itself",
},
{
group: ["#/layouts/*"],
message:
"The #/layouts package cannot be imported, please use the @core package itself",
},
{
group: ["#/locales/*"],
message:
"The #/locales package cannot be imported, please use the @core package itself",
},
{
group: ["#/stores/*"],
message: "The #/stores package cannot be imported, please use the @core package itself",
},
],
},
],
"perfectionist/sort-interfaces": "off",
},
},
{
// @core内部组件,不能引入@venus/* 里面的包
files: ["packages/@core/**/**"],
ignores: restrictedImportIgnores,
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["@venus/*"],
message:
"The @core package cannot import the @vben package, please use the @core package itself",
},
],
},
],
},
},
{
// @core/shared内部组件,不能引入@venus/* 或者 @vben-core/* 里面的包
files: ["packages/@core/base/**/**"],
ignores: restrictedImportIgnores,
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["@venus/*", "@vben-core/*"],
message:
"The @vben-core/shared package cannot import the @vben package, please use the @core/shared package itself",
},
],
},
],
},
},
// {
// // apps内部的一些基础规则
// files: [ "apps/**/**" ],
// ignores: restrictedImportIgnores,
// rules: {
// "no-restricted-imports": [
// "error",
// {
// patterns: [
// {
// group: [ "#/api/*" ],
// message: "The #/api package cannot be imported, please use the @core package itself",
// },
// {
// group: [ "#/layouts/*" ],
// message:
// "The #/layouts package cannot be imported, please use the @core package itself",
// },
// {
// group: [ "#/locales/*" ],
// message:
// "The #/locales package cannot be imported, please use the @core package itself",
// },
// {
// group: [ "#/stores/*" ],
// message: "The #/stores package cannot be imported, please use the @core package itself",
// },
// ],
// },
// ],
// "perfectionist/sort-interfaces": "off",
// },
// },
// {
// // @core内部组件,不能引入@venus/* 里面的包
// files: [ "packages/@core/**/**" ],
// ignores: restrictedImportIgnores,
// rules: {
// "no-restricted-imports": [
// "error",
// {
// patterns: [
// {
// group: [ "@venus/*" ],
// message:
// "The @core package cannot import the @vben package, please use the @core package itself",
// },
// ],
// },
// ],
// },
// },
// {
// // @core/shared内部组件,不能引入@venus/* 或者 @vben-core/* 里面的包
// files: [ "packages/@core/base/**/**" ],
// ignores: restrictedImportIgnores,
// rules: {
// "no-restricted-imports": [
// "error",
// {
// patterns: [
// {
// group: [ "@venus/*", "@vben-core/*" ],
// message:
// "The @vben-core/shared package cannot import the @vben package, please use the @core/shared package itself",
// },
// ],
// },
// ],
// },
// },
{
// 不能引入@venus/*里面的包
files: [
"packages/types/**/**",
"packages/utils/**/**",
"packages/icons/**/**",
"packages/constants/**/**",
"packages/styles/**/**",
"packages/stores/**/**",
"packages/preferences/**/**",
"packages/locales/**/**",
],
ignores: restrictedImportIgnores,
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["@venus/*"],
message: "The @vben package cannot be imported, please use the @core package itself",
},
],
},
],
},
},
// {
// // 不能引入@venus/*里面的包
// files: [
// "packages/types/**/**",
// "packages/utils/**/**",
// "packages/icons/**/**",
// "packages/constants/**/**",
// "packages/styles/**/**",
// "packages/stores/**/**",
// "packages/preferences/**/**",
// "packages/locales/**/**",
// ],
// ignores: restrictedImportIgnores,
// rules: {
// "no-restricted-imports": [
// "error",
// {
// patterns: [
// {
// group: [ "@venus/*" ],
// message: "The @vben package cannot be imported, please use the @core package itself",
// },
// ],
// },
// ],
// },
// },
// 后端模拟代码,不需要太多规则
{
files: ["apps/backend-mock/**/**", "docs/**/**"],
files: [ "apps/backend-mock/**/**", "docs/**/**" ],
rules: {
"@typescript-eslint/no-extraneous-class": "off",
"n/no-extraneous-import": "off",
......
......@@ -7,17 +7,17 @@ export default {
htmlWhitespaceSensitivity: "ignore",
bracketSameLine: true,
plugins: ["prettier-plugin-tailwindcss", "@venus/prettier-plugin-wxml"],
plugins: [ "prettier-plugin-tailwindcss", "@venus/prettier-plugin-wxml" ],
overrides: [
{
files: ["*.json5"],
files: [ "*.json5" ],
options: {
quoteProps: "preserve",
singleQuote: false,
},
},
{
files: ["*.wxml"],
files: [ "*.wxml" ],
options: {
parser: "wxml",
},
......
......@@ -156,11 +156,11 @@ function buildMultiLineMustacheDocFromPrinted(printedText) {
if (simple) {
// Simple identifier like "title": content aligns with '{{', '}}' at parent indent
return [indent([hardline, "{{", ...contentDoc]), hardline, "}}", hardline];
return [ indent([ hardline, "{{", ...contentDoc ]), hardline, "}}", hardline ];
}
// Complex expression: indent inner content, align '}}' with '{{'
return [indent([hardline, "{{", indent(contentDoc), hardline, "}}"]), hardline];
return [ indent([ hardline, "{{", indent(contentDoc), hardline, "}}" ]), hardline ];
}
function printElement(path, opts, print) {
......@@ -244,7 +244,7 @@ function printElement(path, opts, print) {
const content = allParts.slice(0, -1); // 前面的是内容
return group([
parts[0], // <text ...>
indent([hardline, ...content]),
indent([ hardline, ...content ]),
hardline,
endTag,
]);
......@@ -321,7 +321,7 @@ function printElement(path, opts, print) {
parts.push(...childrenParts);
} else {
const childrenWithBreaks = [];
for (const [i, printed] of childrenParts.entries()) {
for (const [ i, printed ] of childrenParts.entries()) {
if (i > 0) childrenWithBreaks.push(hardline);
const entry = childEntries[i];
// Don't split multi-line text to avoid instability; trust the printed output
......@@ -346,7 +346,7 @@ function printElement(path, opts, print) {
}
// Normal path
if (!didSpecial) {
parts.push(indent([hardline, ...childrenWithBreaks]), hardline);
parts.push(indent([ hardline, ...childrenWithBreaks ]), hardline);
}
}
}
......@@ -439,7 +439,7 @@ function printStartTag(path, opts, print) {
// 从路径中获取当前节点
const node = path.getValue();
// 初始化部分数组,包含开始标签的 "<" 和标签名称
const parts = ["<", node.name];
const parts = [ "<", node.name ];
// 检查是否存在属性且属性列表不为空
if (node.attributes && node.attributes.length > 0) {
// 将每个属性映射为格式化的属性文档字符串
......@@ -482,7 +482,7 @@ function printStartTag(path, opts, print) {
parts.push(" ", firstAttr);
// 计算与第一个属性对齐的缩进
const firstAttrIndent = " ".repeat(node.name.length + 2); // "<" + tagName + space
const indentedAttributes = [hardline, firstAttrIndent, join([hardline, firstAttrIndent], restAttrs)];
const indentedAttributes = [ hardline, firstAttrIndent, join([ hardline, firstAttrIndent ], restAttrs) ];
parts.push(...indentedAttributes);
} else {
// 只有一个属性,保留在同一行
......
......@@ -3,5 +3,5 @@ import { defineBuildConfig } from "unbuild";
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ["src/index"],
entries: [ "src/index" ],
});
......@@ -8,15 +8,15 @@ export function configMiniprogram(): ConfigOverride[] {
return [
// WXSS 文件的配置(纯样式文件)
{
files: ["**/apps/miniprogram/**/*.{css,less,scss,sass,wxss}", "**/apps/uniapp/**/*.{css,less,scss,sass}"],
files: [ "**/apps/miniprogram/**/*.{css,less,scss,sass,wxss}", "**/apps/uniapp/**/*.{css,less,scss,sass}" ],
customSyntax: "postcss",
extends: ["stylelint-config-recess-order"],
extends: [ "stylelint-config-recess-order" ],
rules: {
// 允许 rpx 单位(uni-app 响应式单位)
"unit-no-unknown": [
true,
{
ignoreUnits: ["rpx", "upx"],
ignoreUnits: [ "rpx", "upx" ],
},
],
// 允许未知的属性值(uni-app 特有值)
......@@ -27,23 +27,23 @@ export function configMiniprogram(): ConfigOverride[] {
"selector-type-no-unknown": [
true,
{
ignore: ["custom-elements"],
ignoreTypes: ["/^(page|view|text|image|button|input|scroll-view|swiper|navigator)/"],
ignore: [ "custom-elements" ],
ignoreTypes: [ "/^(page|view|text|image|button|input|scroll-view|swiper|navigator)/" ],
},
],
},
},
// Vue 和 HTML 中的样式块
{
files: ["**/apps/miniprogram/**/*.{vue,html}", "**/apps/uniapp/**/*.{vue,html}"],
files: [ "**/apps/miniprogram/**/*.{vue,html}", "**/apps/uniapp/**/*.{vue,html}" ],
customSyntax: "postcss-html",
extends: ["stylelint-config-recess-order"],
extends: [ "stylelint-config-recess-order" ],
rules: {
// 允许 rpx 单位
"unit-no-unknown": [
true,
{
ignoreUnits: ["rpx"],
ignoreUnits: [ "rpx" ],
},
],
// 允许未知的属性值
......@@ -54,22 +54,22 @@ export function configMiniprogram(): ConfigOverride[] {
"selector-type-no-unknown": [
true,
{
ignore: ["custom-elements"],
ignoreTypes: ["/^(page|view|text|image|button|input|scroll-view|swiper|navigator)/"],
ignore: [ "custom-elements" ],
ignoreTypes: [ "/^(page|view|text|image|button|input|scroll-view|swiper|navigator)/" ],
},
],
// Vue 的伪类选择器(如 :global, :deep)
"selector-pseudo-class-no-unknown": [
true,
{
ignorePseudoClasses: ["global", "deep"],
ignorePseudoClasses: [ "global", "deep" ],
},
],
// Vue 的伪元素选择器(如 v-deep, v-global)
"selector-pseudo-element-no-unknown": [
true,
{
ignorePseudoElements: ["v-deep", "v-global", "v-slotted"],
ignorePseudoElements: [ "v-deep", "v-global", "v-slotted" ],
},
],
},
......
......@@ -15,10 +15,10 @@ export default {
// 继承的预设配置
// stylelint-config-standard: 标准的 CSS 规则
// stylelint-config-recess-order: 声明属性顺序规则
extends: ["stylelint-config-standard", "stylelint-config-recess-order"],
extends: [ "stylelint-config-standard", "stylelint-config-recess-order" ],
// 忽略的文件类型(非样式文件)
ignoreFiles: ["**/*.js", "**/*.jsx", "**/*.tsx", "**/*.ts", "**/*.json", "**/*.md"],
ignoreFiles: [ "**/*.js", "**/*.jsx", "**/*.tsx", "**/*.ts", "**/*.json", "**/*.md" ],
// 针对不同文件类型的特殊配置覆盖
overrides: [
......@@ -27,20 +27,20 @@ export default {
{
// 使用 postcss-html 解析器处理 HTML/Vue 中的样式块
customSyntax: "postcss-html",
files: ["*.(html|vue)", "**/*.(html|vue)"],
files: [ "*.(html|vue)", "**/*.(html|vue)" ],
rules: {
// Vue 的伪类选择器(如 :global, :deep)
"selector-pseudo-class-no-unknown": [
true,
{
ignorePseudoClasses: ["global", "deep"],
ignorePseudoClasses: [ "global", "deep" ],
},
],
// Vue 的伪元素选择器(如 v-deep, v-global)
"selector-pseudo-element-no-unknown": [
true,
{
ignorePseudoElements: ["v-deep", "v-global", "v-slotted"],
ignorePseudoElements: [ "v-deep", "v-global", "v-slotted" ],
},
],
},
......@@ -49,8 +49,8 @@ export default {
{
// 使用 postcss-scss 解析器处理 SCSS 语法
customSyntax: "postcss-scss",
extends: ["stylelint-config-recommended-scss", "stylelint-config-recommended-vue/scss"],
files: ["*.scss", "**/*.scss"],
extends: [ "stylelint-config-recommended-scss", "stylelint-config-recommended-vue/scss" ],
files: [ "*.scss", "**/*.scss" ],
},
],
......@@ -139,7 +139,7 @@ export default {
"rule-empty-line-before": [
"always",
{
ignore: ["after-comment", "first-nested"],
ignore: [ "after-comment", "first-nested" ],
},
],
......
......@@ -3,5 +3,5 @@ import { defineBuildConfig } from "unbuild";
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ["src/index"],
entries: [ "src/index" ],
});
......@@ -24,7 +24,7 @@ async function getStagedFiles(): Promise<string[]> {
changedList = changedList.map((item) => path.resolve(process.cwd(), item));
const changedSet = new Set(changedList);
changedSet.delete("");
return [...changedSet];
return [ ...changedSet ];
} catch (error) {
console.error("Failed to get staged files:", error);
return [];
......
......@@ -3,7 +3,7 @@ import { defineBuildConfig } from "unbuild";
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ["src/index", "./src/postcss.config"],
entries: [ "src/index", "./src/postcss.config" ],
rollup: {
emitCJS: true,
},
......
......@@ -121,7 +121,7 @@ export default {
...tailwindPackages.map((item) => path.join(item, "src/**/*.{vue,js,ts,jsx,tsx,svelte,astro,html}")),
],
darkMode: "selector",
plugins: [animate, typographyPlugin, addDynamicIconSelectors(), enterAnimationPlugin],
plugins: [ animate, typographyPlugin, addDynamicIconSelectors(), enterAnimationPlugin ],
prefix: "",
theme: {
container: {
......@@ -194,7 +194,7 @@ export default {
},
},
},
safelist: ["dark"],
safelist: [ "dark" ],
} as Config;
function createColorsPalette(name: string) {
......
......@@ -6,7 +6,7 @@ export default {
// Specifying the config is not necessary in most cases, but it is included
autoprefixer: {},
// 修复 element-plus 和 ant-design-vue 的样式和tailwindcss冲突问题
"postcss-antd-fixes": { prefixes: ["ant", "el"] },
"postcss-antd-fixes": { prefixes: [ "ant", "el" ] },
"postcss-import": {},
"postcss-preset-env": {},
tailwindcss: { config },
......
......@@ -3,5 +3,5 @@ import { defineBuildConfig } from "unbuild";
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ["src/index"],
entries: [ "src/index" ],
});
......@@ -28,7 +28,7 @@ function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
archiver: true,
archiverPluginOptions: {},
compress: false,
compressTypes: ["brotli", "gzip"],
compressTypes: [ "brotli", "gzip" ],
devtools: true,
env,
extraAppConfig: true,
......@@ -71,9 +71,9 @@ function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
esbuild: {
drop: isBuild
? [
// 'console',
"debugger",
]
// 'console',
"debugger",
]
: [],
legalComments: "none",
},
......@@ -102,19 +102,19 @@ function createCssOptions(injectGlobalScss = true): CSSOptions {
return {
preprocessorOptions: injectGlobalScss
? {
scss: {
additionalData: (content: string, filepath: string) => {
const relativePath = relative(root, filepath);
// apps下的包注入全局样式
if (relativePath.startsWith(`apps${path.sep}`)) {
return `@use "@venus/styles/global" as *;\n${content}`;
}
return content;
},
// api: 'modern',
importers: [new NodePackageImporter()],
scss: {
additionalData: (content: string, filepath: string) => {
const relativePath = relative(root, filepath);
// apps下的包注入全局样式
if (relativePath.startsWith(`apps${path.sep}`)) {
return `@use "@venus/styles/global" as *;\n${content}`;
}
return content;
},
}
// api: 'modern',
importers: [ new NodePackageImporter() ],
},
}
: {},
};
}
......
......@@ -27,14 +27,14 @@ function defineLibraryConfig(userConfigPromise?: DefineLibraryOptions) {
const { dependencies = {}, peerDependencies = {} } = await readPackageJSON(root);
const externalPackages = [...Object.keys(dependencies), ...Object.keys(peerDependencies)];
const externalPackages = [ ...Object.keys(dependencies), ...Object.keys(peerDependencies) ];
const packageConfig: UserConfig = {
build: {
lib: {
entry: "src/index.ts",
fileName: () => "index.mjs",
formats: ["es"],
formats: [ "es" ],
},
rollupOptions: {
external: (id) => {
......
......@@ -53,7 +53,7 @@ async function viteExtraAppConfigPlugin({ isBuild, root }: PluginOptions): Promi
return {
html,
tags: [{ attrs: { src: appConfigSrc }, tag: "script" }],
tags: [ { attrs: { src: appConfigSrc }, tag: "script" } ],
};
},
};
......
......@@ -54,7 +54,7 @@ async function viteImportMapPlugin(pluginOptions?: pluginOptions): Promise<Plugi
{
debug: false,
defaultProvider: "jspm.io",
env: ["production", "browser", "module"],
env: [ "production", "browser", "module" ],
importmap: [],
},
pluginOptions,
......
......@@ -58,19 +58,19 @@ async function loadCommonPlugins(options: CommonPluginOptions): Promise<Conditio
{
condition: !isBuild && devtools,
plugins: () => [viteVueDevTools()],
plugins: () => [ viteVueDevTools() ],
},
{
condition: injectMetadata,
plugins: async () => [await viteMetadataPlugin()],
plugins: async () => [ await viteMetadataPlugin() ],
},
{
condition: isBuild && !!visualizer,
plugins: () => [<PluginOption>viteVisualizerPlugin({
filename: "./node_modules/.cache/visualizer/stats.html",
gzipSize: true,
open: true,
})],
plugins: () => [ <PluginOption>viteVisualizerPlugin({
filename: "./node_modules/.cache/visualizer/stats.html",
gzipSize: true,
open: true,
}) ],
},
];
}
......@@ -124,29 +124,29 @@ async function loadApplicationPlugins(options: ApplicationPluginOptions): Promis
{
condition: print,
plugins: async () => {
return [await vitePrintPlugin({ infoMap: printInfoMap })];
return [ await vitePrintPlugin({ infoMap: printInfoMap }) ];
},
},
{
condition: vxeTableLazyImport,
plugins: async () => {
return [await viteVxeTableImportsPlugin()];
return [ await viteVxeTableImportsPlugin() ];
},
},
{
condition: nitroMock,
plugins: async () => {
return [await viteNitroMockPlugin(nitroMockOptions)];
return [ await viteNitroMockPlugin(nitroMockOptions) ];
},
},
{
condition: injectAppLoading,
plugins: async () => [await viteInjectAppLoadingPlugin(!!isBuild, env)],
plugins: async () => [ await viteInjectAppLoadingPlugin(!!isBuild, env) ],
},
{
condition: license,
plugins: async () => [await viteLicensePlugin()],
plugins: async () => [ await viteLicensePlugin() ],
},
{
condition: pwa,
......@@ -180,22 +180,22 @@ async function loadApplicationPlugins(options: ApplicationPluginOptions): Promis
},
{
condition: !!html,
plugins: () => [viteHtmlPlugin({ minify: true })],
plugins: () => [ viteHtmlPlugin({ minify: true }) ],
},
{
condition: isBuild && importmap,
plugins: () => {
return [viteImportMapPlugin(importmapOptions)];
return [ viteImportMapPlugin(importmapOptions) ];
},
},
{
condition: isBuild && extraAppConfig,
plugins: async () => [await viteExtraAppConfigPlugin({ isBuild: true, root: process.cwd() })],
plugins: async () => [ await viteExtraAppConfigPlugin({ isBuild: true, root: process.cwd() }) ],
},
{
condition: archiver,
plugins: async () => {
return [await viteArchiverPlugin(archiverPluginOptions)];
return [ await viteArchiverPlugin(archiverPluginOptions) ];
},
},
]);
......@@ -213,7 +213,7 @@ async function loadLibraryPlugins(options: LibraryPluginOptions): Promise<Plugin
...commonPlugins,
{
condition: isBuild && !!dts,
plugins: () => [viteDtsPlugin({ logLevel: "error" })],
plugins: () => [ viteDtsPlugin({ logLevel: "error" }) ],
},
]);
}
......
......@@ -36,10 +36,10 @@ async function resolveMonorepoDependencies() {
for (const { packageJson } of packages) {
const { dependencies = {}, devDependencies = {} } = packageJson;
for (const [key, value] of Object.entries(dependencies)) {
for (const [ key, value ] of Object.entries(dependencies)) {
resultDependencies[key] = resolvePackageVersion(pkgsMeta, key, value, catalog);
}
for (const [key, value] of Object.entries(devDependencies)) {
for (const [ key, value ] of Object.entries(devDependencies)) {
resultDevDependencies[key] = resolvePackageVersion(pkgsMeta, key, value, catalog);
}
}
......
......@@ -32,7 +32,7 @@ async function viteLicensePlugin(root = process.cwd()): Promise<PluginOption | u
*/
`.trim();
for (const [, fileContent] of Object.entries(bundle)) {
for (const [ , fileContent ] of Object.entries(bundle)) {
if (fileContent.type === "chunk" && fileContent.isEntry) {
const chunkContent = fileContent as OutputChunk;
// 插入版权信息
......
......@@ -13,7 +13,7 @@ export const vitePrintPlugin = (options: PrintPluginOptions = {}): PluginOption
server.printUrls = () => {
_printUrls();
for (const [key, value] of Object.entries(infoMap)) {
for (const [ key, value ] of Object.entries(infoMap)) {
console.log(` ${colors.green("➜")} ${colors.bold(key)}: ${colors.cyan(value)}`);
}
};
......
......@@ -24,7 +24,7 @@ function getConfFiles() {
if (result) {
mode = result[1] as string;
}
return [".env", ".env.local", `.env.${mode}`, `.env.${mode}.local`];
return [ ".env", ".env.local", `.env.${mode}`, `.env.${mode}.local` ];
}
/**
......
......@@ -51,12 +51,12 @@ pre-commit:
glob: "*.md"
lint-vue:
glob: "*.vue"
run: sh -c "NODE_OPTIONS=--max-old-space-size=8192 pnpm eslint --cache --fix {staged_files} && NODE_OPTIONS=--max-old-space-size=8192 pnpm stylelint --fix --allow-empty-input {staged_files}"
run: pnpm eslint --cache --fix {staged_files}
lint-js:
run: sh -c "NODE_OPTIONS=--max-old-space-size=8192 pnpm eslint --cache --fix --no-warn-ignored . --ext .js,.jsx,.ts,.tsx"
run: pnpm eslint --cache --fix {staged_files}
glob: "*.{js,jsx,ts,tsx}"
lint-style:
run: sh -c "NODE_OPTIONS=--max-old-space-size=8192 pnpm stylelint --fix --allow-empty-input {staged_files}"
run: pnpm stylelint --fix --allow-empty-input {staged_files}
glob: "*.{scss,less,styl,html,vue,css,wxss}"
lint-package:
run: pnpm eslint --cache --fix {staged_files}
......
{
"extends": "../../tsconfig.json",
"extends": "@venus/tsconfig/web.json",
"compilerOptions": {
"composite": true,
"lib": ["ES2020"],
......
......@@ -2,6 +2,7 @@ import child_process from "node:child_process";
import fs from "node:fs";
import fsp from "node:fs/promises";
import path from "node:path";
import process from "node:process";
import { fileURLToPath } from "node:url";
import { cancel, confirm, isCancel, select, text } from "@clack/prompts";
......@@ -17,7 +18,7 @@ function parseArgs(argv: string[]): Flags {
if (!token || !token.startsWith("--")) continue;
const withoutDashes = token.slice(2);
if (withoutDashes.includes("=")) {
const [rawKey, rawVal] = withoutDashes.split("=");
const [ rawKey, rawVal ] = withoutDashes.split("=");
if (rawKey) {
out[rawKey.trim()] = (rawVal ?? "").trim() || true;
}
......@@ -66,7 +67,7 @@ function printHelp() {
function isTextFile(file: string) {
const ext = path.extname(file).toLowerCase();
return [".css", ".html", ".js", ".json", ".jsx", ".less", ".md", ".scss", ".ts", ".tsx", ".vue"].includes(ext);
return [ ".css", ".html", ".js", ".json", ".jsx", ".less", ".md", ".scss", ".ts", ".tsx", ".vue" ].includes(ext);
}
async function ensureDir(dir: string) {
......@@ -100,7 +101,7 @@ async function mergeJson(targetPath: string, mergeObj: Record<string, JsonValue>
function deepMerge(a: JsonValue, b: JsonValue | undefined): JsonValue {
if (b === undefined) return a;
if (Array.isArray(a) && Array.isArray(b)) {
return [...new Set([...a, ...b])];
return [ ...new Set([ ...a, ...b ]) ];
}
if (isPlainObject(a) && isPlainObject(b)) {
const aObj = a as Record<string, JsonValue>;
......@@ -130,7 +131,7 @@ async function replacePlaceholders(destRoot: string, replacements: Record<string
if (entry.isDirectory()) await walk(full);
else if (entry.isFile() && isTextFile(full)) {
let content = await fsp.readFile(full, "utf8");
for (const [from, to] of Object.entries(replacements)) {
for (const [ from, to ] of Object.entries(replacements)) {
content = content.split(from).join(to);
}
await fsp.writeFile(full, content);
......@@ -191,12 +192,11 @@ async function executeCreate(options: CreateOptions) {
const dirPrefix = dir || defaultDirPrefix;
const destRoot = path.resolve(rootDir, dirPrefix ? path.join(dirPrefix, name) : name);
const runtimeDir = typeof __dirname === "undefined" ? path.dirname(fileURLToPath(import.meta.url)) : __dirname;
const runtimeDir = path.dirname(fileURLToPath(import.meta.url));
const tplRoot = path.resolve(runtimeDir, "../templates", template);
if (!fs.existsSync(tplRoot)) {
console.error(`模板不存在: ${template},路径: ${tplRoot}`);
process.exit(1);
throw new Error(`模板不存在: ${template},路径: ${tplRoot}`);
}
// 非空目录保护
......@@ -205,12 +205,10 @@ async function executeCreate(options: CreateOptions) {
if (stat.isDirectory()) {
const files = await fsp.readdir(destRoot);
if (files.length > 0 && !force) {
console.error(`目标目录已存在且非空: ${destRoot}。如需覆盖请添加 --force`);
process.exit(1);
throw new Error(`目标目录已存在且非空: ${destRoot}。如需覆盖请添加 --force`);
}
} else {
console.error(`目标路径已存在且不是目录: ${destRoot}`);
process.exit(1);
throw new Error(`目标路径已存在且不是目录: ${destRoot}`);
}
}
await ensureDir(destRoot);
......@@ -264,12 +262,12 @@ async function executeCreate(options: CreateOptions) {
}
async function runCreate(argv: string[]) {
const [, , , name, ...rest] = argv;
const name = argv[3];
const rest = argv.slice(4);
const flags = parseArgs(rest);
if (!name) {
console.error("请输入项目名称,例如: venus create my-app --template react");
printHelp();
process.exit(1);
throw new Error("请输入项目名称,例如: venus create my-app --template react");
}
const options: CreateOptions = {
......@@ -304,11 +302,11 @@ async function runCreateInteractive() {
});
if (!projectName) {
cancel("项目名称不能为空");
process.exit(0);
throw new Error("项目名称不能为空");
}
if (isCancel(projectName)) {
cancel("操作已取消");
process.exit(0);
throw new Error("操作已取消");
}
// 步骤2: 选择模板类型
......@@ -322,7 +320,7 @@ async function runCreateInteractive() {
if (isCancel(template) || typeof template !== "string") {
cancel("操作已取消");
process.exit(0);
throw new Error("操作已取消");
}
// 步骤3: 输入构建目录
......@@ -336,7 +334,7 @@ async function runCreateInteractive() {
if (isCancel(dirInput)) {
cancel("操作已取消");
process.exit(0);
throw new Error("操作已取消");
}
// 步骤4: 选择是否安装依赖
......@@ -347,7 +345,7 @@ async function runCreateInteractive() {
if (isCancel(shouldInstall)) {
cancel("操作已取消");
process.exit(0);
throw new Error("操作已取消");
}
// 步骤5: 选择可选功能 - Router
......@@ -358,7 +356,7 @@ async function runCreateInteractive() {
if (isCancel(hasRouter)) {
cancel("操作已取消");
process.exit(0);
throw new Error("操作已取消");
}
// 步骤6: 选择可选功能 - Store
......@@ -369,11 +367,11 @@ async function runCreateInteractive() {
if (isCancel(hasStore)) {
cancel("操作已取消");
process.exit(0);
throw new Error("操作已取消");
}
// 步骤7: 选择 UI 库
const runtimeDir = typeof __dirname === "undefined" ? path.dirname(fileURLToPath(import.meta.url)) : __dirname;
const runtimeDir = path.dirname(fileURLToPath(import.meta.url));
const tplRoot = path.resolve(runtimeDir, "../templates", template);
const uiDir = path.join(tplRoot, "optional", "ui");
let selectedUi: string | undefined;
......@@ -385,12 +383,12 @@ async function runCreateInteractive() {
if (availableUis.length > 0) {
const uiChoice = await select<string>({
message: "请选择 UI 库 (可选):",
options: [{ value: "", label: "不使用 UI 库" }, ...availableUis],
options: [ { value: "", label: "不使用 UI 库" }, ...availableUis ],
});
if (isCancel(uiChoice) || typeof uiChoice !== "string") {
cancel("操作已取消");
process.exit(0);
throw new Error("操作已取消");
}
selectedUi = uiChoice === "" ? undefined : uiChoice;
......@@ -405,7 +403,7 @@ async function runCreateInteractive() {
if (isCancel(hasEslint)) {
cancel("操作已取消");
process.exit(0);
throw new Error("操作已取消");
}
// 执行创建
......@@ -426,8 +424,7 @@ async function runCreateInteractive() {
async function runBuild() {
const buildScript = path.resolve(process.cwd(), "scripts/build.js");
if (!fs.existsSync(buildScript)) {
console.error("未找到 scripts/build.js,请在 Venus 仓库根目录执行该命令。");
process.exit(1);
throw new Error("未找到 scripts/build.js,请在 Venus 仓库根目录执行该命令。");
}
try {
child_process.execSync(`node ${JSON.stringify(buildScript)}`, {
......@@ -435,7 +432,7 @@ async function runBuild() {
shell: process.platform === "win32" ? "powershell.exe" : "/bin/sh",
});
} catch {
process.exit(1);
throw new Error("构建失败");
}
}
......@@ -471,17 +468,16 @@ export async function main() {
}
// 自动执行
if (typeof process !== "undefined" && process.argv && process.argv[1]) {
if (process !== undefined && process.argv && process.argv[1]) {
// 在作为 bin 执行时运行 main
main();
}
async function runListTemplates() {
const runtimeDir = typeof __dirname === "undefined" ? path.dirname(fileURLToPath(import.meta.url)) : __dirname;
const runtimeDir = path.dirname(fileURLToPath(import.meta.url));
const base = path.resolve(runtimeDir, "../templates");
if (!fs.existsSync(base)) {
console.error("未找到模板目录");
process.exit(1);
throw new Error("未找到模板目录");
}
const templates = await fsp.readdir(base, { withFileTypes: true });
for (const t of templates) {
......
......@@ -2,5 +2,5 @@ import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [react()],
plugins: [ react() ],
});
......@@ -2,7 +2,7 @@ import type { RouteRecordRaw } from "vue-router";
import { createRouter, createWebHistory } from "vue-router";
const routes: RouteRecordRaw[] = [{ path: "/", component: () => import("./App.vue") }];
const routes: RouteRecordRaw[] = [ { path: "/", component: () => import("./App.vue") } ];
export const router = createRouter({
history: createWebHistory(),
......
<template>
<div id="micro-app" class="micro-app-container">
<header class="app-header">
<h1>🚀 Vue3 微前端子应用</h1>
<nav class="nav-menu">
<router-link class="nav-link" to="/">
首页
</router-link>
<router-link class="nav-link" to="/about">
关于
</router-link>
<router-link class="nav-link" to="/communication">
通信示例
</router-link>
<router-link class="nav-link" to="/user">
用户管理
</router-link>
<router-link class="nav-link" to="/settings">
系统设置
</router-link>
</nav>
</header>
<main class="app-main">
<router-view v-slot="{ Component }">
<transition mode="out-in" name="fade">
<component :is="Component" />
</transition>
</router-view>
</main>
<footer class="app-footer">
<p>© 2025 Venus 微前端子应用模板</p>
</footer>
</div>
</template>
<script setup lang="ts">
import { onMounted } from "vue";
......@@ -6,33 +43,6 @@ onMounted(() => {
});
</script>
<template>
<div id="micro-app" class="micro-app-container">
<header class="app-header">
<h1>🚀 Vue3 微前端子应用</h1>
<nav class="nav-menu">
<router-link to="/" class="nav-link">首页</router-link>
<router-link to="/about" class="nav-link">关于</router-link>
<router-link to="/communication" class="nav-link">通信示例</router-link>
<router-link to="/user" class="nav-link">用户管理</router-link>
<router-link to="/settings" class="nav-link">系统设置</router-link>
</nav>
</header>
<main class="app-main">
<router-view v-slot="{ Component }">
<transition name="fade" mode="out-in">
<component :is="Component" />
</transition>
</router-view>
</main>
<footer class="app-footer">
<p>© 2025 Venus 微前端子应用模板</p>
</footer>
</div>
</template>
<style scoped>
.micro-app-container {
display: flex;
......
/// <reference types="vite/client" />
// / <reference types="vite/client" />
......@@ -155,7 +155,7 @@ class SubAppCommunicationManager {
// 注意:这里需要基座的 communication manager 来处理通知添加逻辑
// 所以我们实际上是触发一个状态变化,让基座来处理
this.setGlobalState({
notifications: [newNotification] as any, // 基座会合并到现有通知列表
notifications: [ newNotification ] as any, // 基座会合并到现有通知列表
});
}
......
<script setup lang="ts">
// About 页面
</script>
<template>
<div class="about-view">
<div class="content-card">
<h1>📖 关于本应用</h1>
<section class="section">
<h2>技术栈</h2>
<ul class="tech-list">
<li>
<strong>Vue 3</strong>
- 渐进式 JavaScript 框架
</li>
<li>
<strong>TypeScript</strong>
- 类型安全的 JavaScript 超集
</li>
<li>
<strong>Vite</strong>
- 新一代前端构建工具
</li>
<li>
<strong>Vue Router</strong>
- 官方路由管理器
</li>
<li>
<strong>Pinia</strong>
- 新一代状态管理库
</li>
<li>
<strong>qiankun</strong>
- 微前端框架
</li>
</ul>
</section>
<section class="section">
<h2>功能特性</h2>
<ul class="feature-list">
<li>✅ 支持独立运行和基座集成</li>
<li>✅ 完整的 TypeScript 支持</li>
<li>✅ 自动导入 API 和组件</li>
<li>✅ 热模块替换 (HMR)</li>
<li>✅ 路由懒加载</li>
<li>✅ CSS 样式隔离</li>
</ul>
</section>
<section class="section">
<h2>快速开始</h2>
<div class="code-block">
<pre><code># 安装依赖
<div class="about-view">
<div class="content-card">
<h1>📖 关于本应用</h1>
<section class="section">
<h2>技术栈</h2>
<ul class="tech-list">
<li>
<strong>Vue 3</strong>
- 渐进式 JavaScript 框架
</li>
<li>
<strong>TypeScript</strong>
- 类型安全的 JavaScript 超集
</li>
<li>
<strong>Vite</strong>
- 新一代前端构建工具
</li>
<li>
<strong>Vue Router</strong>
- 官方路由管理器
</li>
<li>
<strong>Pinia</strong>
- 新一代状态管理库
</li>
<li>
<strong>qiankun</strong>
- 微前端框架
</li>
</ul>
</section>
<section class="section">
<h2>功能特性</h2>
<ul class="feature-list">
<li>✅ 支持独立运行和基座集成</li>
<li>✅ 完整的 TypeScript 支持</li>
<li>✅ 自动导入 API 和组件</li>
<li>✅ 热模块替换 (HMR)</li>
<li>✅ 路由懒加载</li>
<li>✅ CSS 样式隔离</li>
</ul>
</section>
<section class="section">
<h2>快速开始</h2>
<div class="code-block">
<pre>
<code>
# 安装依赖
pnpm install
# 启动开发服务器
pnpm dev
# 构建生产版本
pnpm build</code></pre>
</div>
</section>
</div>
</div>
pnpm build
</code>
</pre>
</div>
</section>
</div>
</div>
</template>
<script setup lang="ts">
// About 页面
</script>
<style scoped>
.about-view {
max-width: 900px;
......
<template>
<div class="notfound-view">
<div class="content-card">
<div class="error-code">
404
</div>
<h1>页面未找到</h1>
<p>抱歉,您访问的页面不存在或已被删除</p>
<button class="btn-home" @click="goHome">
🏠 返回首页
</button>
</div>
</div>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";
......@@ -8,17 +23,6 @@ const goHome = () => {
};
</script>
<template>
<div class="notfound-view">
<div class="content-card">
<div class="error-code">404</div>
<h1>页面未找到</h1>
<p>抱歉,您访问的页面不存在或已被删除</p>
<button @click="goHome" class="btn-home">🏠 返回首页</button>
</div>
</div>
</template>
<style scoped>
.notfound-view {
display: flex;
......
<template>
<div class="settings-view">
<div class="content-card">
<h1>⚙️ 系统设置</h1>
<div class="settings-grid">
<div class="setting-group">
<h2>🎨 主题设置</h2>
<div class="setting-item">
<label>主题色:</label>
<select v-model="settings.theme" class="select-input">
<option value="purple">
紫色
</option>
<option value="blue">
蓝色
</option>
<option value="green">
绿色
</option>
<option value="orange">
橙色
</option>
</select>
</div>
<div class="setting-item">
<label>暗黑模式:</label>
<input v-model="settings.darkMode"
class="checkbox-input"
type="checkbox" />
</div>
</div>
<div class="setting-group">
<h2>🔔 通知设置</h2>
<div class="setting-item">
<label>桌面通知:</label>
<input v-model="settings.notifications.desktop"
class="checkbox-input"
type="checkbox" />
</div>
<div class="setting-item">
<label>邮件通知:</label>
<input v-model="settings.notifications.email"
class="checkbox-input"
type="checkbox" />
</div>
<div class="setting-item">
<label>短信通知:</label>
<input v-model="settings.notifications.sms"
class="checkbox-input"
type="checkbox" />
</div>
</div>
<div class="setting-group">
<h2>🌐 语言设置</h2>
<div class="setting-item">
<label>界面语言:</label>
<select v-model="settings.language" class="select-input">
<option value="zh-CN">
简体中文
</option>
<option value="en-US">
English
</option>
<option value="ja-JP">
日本語
</option>
</select>
</div>
<div class="setting-item">
<label>时区:</label>
<select v-model="settings.timezone" class="select-input">
<option value="Asia/Shanghai">
北京时间 (UTC+8)
</option>
<option value="America/New_York">
纽约时间 (UTC-5)
</option>
<option value="Europe/London">
伦敦时间 (UTC+0)
</option>
</select>
</div>
</div>
<div class="setting-group">
<h2>🔒 安全设置</h2>
<div class="setting-item">
<label>双因素认证:</label>
<input v-model="settings.security.twoFactor"
class="checkbox-input"
type="checkbox" />
</div>
<div class="setting-item">
<label>会话超时 (分钟):</label>
<input v-model="settings.security.sessionTimeout"
class="number-input"
max="120"
min="5"
type="number" />
</div>
</div>
</div>
<div class="actions">
<button class="btn-save" @click="saveSettings">
💾 保存设置
</button>
<button class="btn-reset" @click="resetSettings">
🔄 重置默认
</button>
</div>
<div class="current-settings">
<h3>当前配置 (JSON)</h3>
<pre>{{ JSON.stringify(settings, null, 2) }}</pre>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { reactive } from "vue";
......@@ -37,107 +160,20 @@ const settings = reactive<Settings>({ ...defaultSettings });
const saveSettings = () => {
console.log("保存设置:", settings);
// eslint-disable-next-line
alert("设置已保存!");
};
const resetSettings = () => {
// eslint-disable-next-line
if (confirm("确定要重置为默认设置吗?")) {
Object.assign(settings, defaultSettings);
// eslint-disable-next-line
alert("已重置为默认设置!");
}
};
</script>
<template>
<div class="settings-view">
<div class="content-card">
<h1>⚙️ 系统设置</h1>
<div class="settings-grid">
<div class="setting-group">
<h2>🎨 主题设置</h2>
<div class="setting-item">
<label>主题色:</label>
<select v-model="settings.theme" class="select-input">
<option value="purple">紫色</option>
<option value="blue">蓝色</option>
<option value="green">绿色</option>
<option value="orange">橙色</option>
</select>
</div>
<div class="setting-item">
<label>暗黑模式:</label>
<input type="checkbox" v-model="settings.darkMode" class="checkbox-input" />
</div>
</div>
<div class="setting-group">
<h2>🔔 通知设置</h2>
<div class="setting-item">
<label>桌面通知:</label>
<input type="checkbox" v-model="settings.notifications.desktop" class="checkbox-input" />
</div>
<div class="setting-item">
<label>邮件通知:</label>
<input type="checkbox" v-model="settings.notifications.email" class="checkbox-input" />
</div>
<div class="setting-item">
<label>短信通知:</label>
<input type="checkbox" v-model="settings.notifications.sms" class="checkbox-input" />
</div>
</div>
<div class="setting-group">
<h2>🌐 语言设置</h2>
<div class="setting-item">
<label>界面语言:</label>
<select v-model="settings.language" class="select-input">
<option value="zh-CN">简体中文</option>
<option value="en-US">English</option>
<option value="ja-JP">日本語</option>
</select>
</div>
<div class="setting-item">
<label>时区:</label>
<select v-model="settings.timezone" class="select-input">
<option value="Asia/Shanghai">北京时间 (UTC+8)</option>
<option value="America/New_York">纽约时间 (UTC-5)</option>
<option value="Europe/London">伦敦时间 (UTC+0)</option>
</select>
</div>
</div>
<div class="setting-group">
<h2>🔒 安全设置</h2>
<div class="setting-item">
<label>双因素认证:</label>
<input type="checkbox" v-model="settings.security.twoFactor" class="checkbox-input" />
</div>
<div class="setting-item">
<label>会话超时 (分钟):</label>
<input
type="number"
v-model="settings.security.sessionTimeout"
class="number-input"
min="5"
max="120" />
</div>
</div>
</div>
<div class="actions">
<button @click="saveSettings" class="btn-save">💾 保存设置</button>
<button @click="resetSettings" class="btn-reset">🔄 重置默认</button>
</div>
<div class="current-settings">
<h3>当前配置 (JSON)</h3>
<pre>{{ JSON.stringify(settings, null, 2) }}</pre>
</div>
</div>
</div>
</template>
<style scoped>
.settings-view {
max-width: 1200px;
......
<template>
<div class="user-view">
<div class="content-card">
<h1>👥 用户管理</h1>
<div class="toolbar">
<button class="btn-add" @click="addUser">
➕ 新增用户
</button>
</div>
<div class="table-container">
<table class="user-table">
<thead>
<tr>
<th>ID</th>
<th>姓名</th>
<th>邮箱</th>
<th>角色</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="user in users" :key="user.id">
<td>{{ user.id }}</td>
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
<td>
<span class="badge" :class="`badge-${user.role}`">
{{ user.role }}
</span>
</td>
<td>
<span class="status" :class="user.active ? 'status-active' : 'status-inactive'">
{{ user.active ? "在线" : "离线" }}
</span>
</td>
<td>
<button class="btn-edit" @click="editUser(user)">
编辑
</button>
<button class="btn-delete" @click="deleteUser(user.id)">
删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
......@@ -53,65 +107,19 @@ const addUser = () => {
const editUser = (user: User) => {
console.log("编辑用户:", user);
// eslint-disable-next-line
alert(`编辑用户: ${user.name}`);
};
const deleteUser = (id: number) => {
const index = users.value.findIndex((u) => u.id === id);
// eslint-disable-next-line
if (index !== -1 && confirm(`确定要删除用户 ${users.value[index].name} 吗?`)) {
users.value.splice(index, 1);
}
};
</script>
<template>
<div class="user-view">
<div class="content-card">
<h1>👥 用户管理</h1>
<div class="toolbar">
<button @click="addUser" class="btn-add">➕ 新增用户</button>
</div>
<div class="table-container">
<table class="user-table">
<thead>
<tr>
<th>ID</th>
<th>姓名</th>
<th>邮箱</th>
<th>角色</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="user in users" :key="user.id">
<td>{{ user.id }}</td>
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
<td>
<span class="badge" :class="`badge-${user.role}`">
{{ user.role }}
</span>
</td>
<td>
<span class="status" :class="user.active ? 'status-active' : 'status-inactive'">
{{ user.active ? "在线" : "离线" }}
</span>
</td>
<td>
<button @click="editUser(user)" class="btn-edit">编辑</button>
<button @click="deleteUser(user.id)" class="btn-delete">删除</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<style scoped>
.user-view {
max-width: 1200px;
......
......@@ -21,7 +21,7 @@ export default defineConfig(({ mode, command }) => {
vueJsx(),
// 自动导入 Vue 相关函数
AutoImport({
imports: ["vue", "vue-router", "pinia"],
imports: [ "vue", "vue-router", "pinia" ],
dts: "src/auto-imports.d.ts",
eslintrc: {
enabled: false,
......@@ -38,7 +38,7 @@ export default defineConfig(({ mode, command }) => {
],
resolve: {
alias: {
"@": resolve(__dirname, "src"),
"@": resolve(import.meta.dirname, "src"),
},
},
server: {
......
......@@ -3,6 +3,6 @@ import { defineBuildConfig } from "unbuild";
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ["src/index"],
externals: ["vue", "element-plus", "@vueuse/core"],
entries: [ "src/index" ],
externals: [ "vue", "element-plus", "@vueuse/core" ],
});
......@@ -36,6 +36,11 @@
}
}
},
"peerDependencies": {
"@element-plus/icons-vue": ">=2.0.0",
"element-plus": ">=2.0.0",
"vue": ">=3.3.0"
},
"dependencies": {
"@element-plus/icons-vue": "catalog:",
"@vueuse/core": "catalog:",
......@@ -46,10 +51,5 @@
"@types/node": "catalog:",
"typescript": "catalog:",
"unbuild": "catalog:"
},
"peerDependencies": {
"@element-plus/icons-vue": ">=2.0.0",
"element-plus": ">=2.0.0",
"vue": ">=3.3.0"
}
}
import VButton from "./index.vue";
export { VButton };
export default VButton;
export { default, default as VButton } from "./index.vue";
\ No newline at end of file
<template>
<!-- 用计算属性过滤并批量绑定 -->
<ElButton v-bind="elButtonProps" @click="debouncedClick">
<slot />
</ElButton>
</template>
<script setup lang="ts">
import type { VButtonProps } from "../../types";
import { computed, ref } from "vue";
import { ElButton, ElMessageBox } from "element-plus";
import { useDebounceFn } from "@vueuse/core";
import type { VButtonProps } from "../../types";
import { ElButton, ElMessageBox } from "element-plus";
/**
* VButton - 增强型按钮组件
......@@ -74,10 +83,3 @@ const handleClick = async (event: MouseEvent) => {
// 防抖处理
const debouncedClick = props.debounce ? useDebounceFn(handleClick, props.debounce) : handleClick;
</script>
<template>
<!-- 用计算属性过滤并批量绑定 -->
<ElButton v-bind="elButtonProps" @click="debouncedClick">
<slot />
</ElButton>
</template>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!