Commit c6b27312 by liimin

1

1 parent 97e4615d
Showing 42 changed files with 2993 additions and 26 deletions
{
"generator": "scripts/ai-direct-apply-output.mjs",
"generatedAt": "2026-06-05T08:31:46.360Z",
"model": "qwen3.7-max",
"provider": "openai-compatible",
"files": [
{
"path": "apps/web/ai-previews/diaobo-preview/src/views/diaobo/components/TransferPanel.vue",
"language": "vue",
"purpose": "调拨管理核心面板:调出方/调入方选择表单 + 工具栏 + 调拨列表表格",
"coAuthor": "@ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T04:23:39.988Z",
"action": "updated"
},
{
"path": "apps/web/ai-previews/diaobo-preview/src/views/db/components/DiaoboConfirmTable.vue",
"language": "vue",
"purpose": "调拨确认单表格组件,展示调拨商品列表信息",
"coAuthor": "@ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T05:46:56.354Z",
"action": "updated"
},
{
"path": "apps/web/ai-previews/diaobo-preview/src/views/dd.vue",
"language": "vue",
"purpose": "调拨确认单管理页面,展示商品调拨数据表格",
"coAuthor": "@ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T06:40:05.054Z",
"action": "created"
},
{
"path": "apps/web/ai-previews/diaobo-preview/src/views/Aa.vue",
"language": "vue",
"purpose": "调拨确认单页面,包含标题、数据表格和分页器",
"coAuthor": "@ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T08:31:36.839Z",
"action": "created"
}
]
}
# 寮€鍙戠幆澧冮厤缃?
# 搴旂敤鍩烘湰淇℃伅
VITE_APP_NAME=寰簲鐢ㄦā鏉?VITE_APP_VERSION=1.0.0
# 寰簲鐢ㄥ悕绉帮紙涓庡熀搴ч厤缃繚鎸佷竴鑷达級
VITE_MICRO_APP_NAME=subapp-vue
# 鏈嶅姟绔彛
VITE_PORT=8081
# API 鍩虹璺緞
VITE_API_BASE_URL=http://localhost:3000/api
VITE_API_TIMEOUT=30000
# 璺敱鍩虹璺緞
VITE_BASE_URL=/subapp-vue
VITE_ROUTER_BASE=/subapp-vue
# 寰簲鐢ㄨ闂矾寰?VITE_PUBLIC_PATH=http://localhost:8081/
# 鏄惁涓哄紑鍙戞ā寮?VITE_USE_DEV_MODE=true
# 鏄惁鍚敤Mock鏁版嵁
VITE_USE_MOCK=false
# 鏄惁鍚敤璋冭瘯妯″紡
VITE_DEBUG=true
# 鍩哄骇搴旂敤鍦板潃
VITE_MAIN_APP_URL=http://localhost:8080
# 鏂囦欢涓婁紶鍦板潃
VITE_UPLOAD_URL=http://localhost:3000/api/upload
# 寮€鍙戠幆澧冩爣璇?NODE_ENV=development
# 鐢熶骇鐜閰嶇疆
# 鐢熶骇鐜鍩虹璺緞
VITE_BASE_URL=/subapp-vue/
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# Auto-generated files
src/auto-imports.d.ts
src/components.d.ts
# **APP_NAME**
该项目由 Venus CLI 脚手架生成,使用 Vite + Vue 3 + TypeScript。
- 可选 ESLint:注入 `eslint.config.mjs`、`lint` 脚本,以及 `@venus/eslint-config`
/// <reference types="vite/client" />
/// <reference types="vue/jsx" />
declare module "*.vue" {
import type { DefineComponent } from "vue";
const component: DefineComponent<object, object, any>;
export default component;
}
// vue-router 类型声明(模板开发时使用,避免类型错误)
declare module "vue-router" {
export interface RouteMeta {
[key: string]: unknown;
title?: string;
}
export interface RouteLocationNormalized {
[key: string]: unknown;
meta: RouteMeta;
name?: null | string | symbol;
path: string;
}
export type NavigationGuardNext = (to?: false | string) => void;
export interface RouteRecordRaw {
[key: string]: unknown;
component?: unknown;
meta?: RouteMeta;
name?: string | symbol;
path: string;
}
export interface Router {
[key: string]: unknown;
afterEach(guard: (to: RouteLocationNormalized, from: RouteLocationNormalized) => void): () => void;
beforeEach(
guard: (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => void,
): () => void;
}
export function createRouter(options: { history: unknown; routes: RouteRecordRaw[] }): Router;
export function createWebHistory(base?: string): unknown;
// 导出所有需要的类型
export type { NavigationGuardNext, RouteLocationNormalized, Router, RouteRecordRaw };
}
// qiankun 相关类型
declare global {
interface Window {
__INJECTED_PUBLIC_PATH_BY_QIANKUN__?: string;
__POWERED_BY_QIANKUN__?: boolean;
}
}
export {};
// @ts-check
// 模板文件在仓库内校验时不会自动拥有生成后项目的依赖图。
// eslint-disable-next-line n/no-extraneous-import
import { defineConfig } from "@venus/eslint-config";
export default defineConfig([
{
files: ["**/*.ts", "**/*.tsx", "**/*.vue"],
languageOptions: {
parserOptions: {
project: ["./tsconfig.json", "./tsconfig.node.json"],
tsconfigRootDir: import.meta.dirname,
},
},
},
]);
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vue3 微前端子应用</title>
<meta name="description" content="基于 qiankun + Vue3 + Vite 的微前端子应用模板" />
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
{
"name": "@venus/diaobo-preview",
"version": "1.0.0",
"description": "Vue3 微前端子应用模板,用于与 qiankun 基座集成",
"private": true,
"type": "module",
"scripts": {
"dev": "vite --port 8081 --host",
"build": "vue-tsc && vite build",
"preview": "vite preview --port 8081",
"type-check": "vue-tsc --noEmit",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@vueuse/core": "catalog:",
"@vui/vue": "workspace:*",
"element-plus": "catalog:",
"pinia": "catalog:",
"vue": "catalog:",
"vue-router": "catalog:"
},
"devDependencies": {
"@types/node": "catalog:",
"@venus/eslint-config": "workspace:*",
"@vitejs/plugin-vue": "catalog:",
"@vitejs/plugin-vue-jsx": "catalog:",
"eslint": "catalog:",
"typescript": "catalog:",
"unplugin-auto-import": "catalog:",
"unplugin-vue-components": "catalog:",
"vite": "catalog:",
"vite-plugin-qiankun": "catalog:",
"vue-tsc": "catalog:"
}
}
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
<template>
<div id="micro-app" class="micro-app-container">
<main class="app-main">
<router-view v-slot="{ Component }">
<transition mode="out-in" name="fade">
<component :is="Component" />
</transition>
</router-view>
</main>
</div>
</template>
<style scoped>
.micro-app-container {
display: flex;
flex-direction: column;
min-height: 100vh;
background: #f5f7fa;
}
.app-main {
flex: 1;
padding: 24px;
}
/* 路由过渡动画 */
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.3s ease;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
@media (max-width: 768px) {
.app-main {
padding: 16px;
}
}
</style>
// / <reference types="vite/client" />
import type { QiankunProps } from "vite-plugin-qiankun/dist/helper";
import type { App as VueApp } from "vue";
import { createApp } from "vue";
import { createPinia } from "pinia";
import { qiankunWindow, renderWithQiankun } from "vite-plugin-qiankun/dist/helper";
import App from "./App.vue";
import { createRouter } from "./router";
import { setupUI } from "./ui";
import "element-plus/dist/index.css";
import "./style.css";
let app: null | VueApp<Element> = null;
let router: any = null;
/**
* 渲染函数
* @param props qiankun 传递的参数
*/
async function render(props: QiankunProps = {}) {
const { container } = props;
app = createApp(App);
// 配置 Pinia
app.use(createPinia());
setupUI(app);
// 配置路由 - 根据是否在 qiankun 环境中使用不同的 base
const routerBase = qiankunWindow.__POWERED_BY_QIANKUN__ ? props.routerBase || "/subapp-vue" : "/";
router = createRouter(routerBase);
app.use(router);
// 初始化通信管理器(仅在 qiankun 环境中)
if (qiankunWindow.__POWERED_BY_QIANKUN__ && props.onGlobalStateChange) {
const { subAppCommunication } = await import("./utils/communication");
subAppCommunication.init(props);
// 将通信管理器挂载到全局属性,方便组件使用
app.config.globalProperties.$communication = subAppCommunication;
}
// 挂载应用
const containerEl = container ? container.querySelector("#app") : document.querySelector("#app");
if (containerEl) {
app.mount(containerEl as Element);
} else {
console.error("[Vue3 微应用] 挂载容器未找到");
}
}
/**
* 独立运行时
* 直接访问子应用时,不是通过基座加载
*/
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
console.log("独立运行模式");
render();
}
/**
* qiankun 生命周期钩子 - bootstrap
* 只会在微应用初始化的时候调用一次,下次微应用重新进入时会直接调用 mount 钩子
*/
export async function bootstrap() {
console.log("[Vue3 微应用] bootstrap");
}
/**
* qiankun 生命周期钩子 - mount
* 应用每次进入都会调用 mount 方法,通常在这里触发应用的渲染方法
*/
export async function mount(props: QiankunProps) {
console.log("Vue3 微应用 mount", props);
render(props);
}
/**
* qiankun 生命周期钩子 - unmount
* 应用每次切出/卸载都会调用 unmount 方法
*/
export async function unmount(props: QiankunProps) {
console.log("[Vue3 微应用] unmount", props);
// 销毁通信管理器
if (qiankunWindow.__POWERED_BY_QIANKUN__) {
const { subAppCommunication } = await import("./utils/communication");
subAppCommunication.destroy();
}
if (app) {
app.unmount();
app = null;
}
if (router) {
router = null;
}
}
/**
* qiankun 生命周期钩子 - update (可选)
* 主应用向子应用下发新的props时触发
*/
export async function update(props: QiankunProps) {
console.log("[Vue3 微应用] update", props);
}
// 使用 vite-plugin-qiankun 提供的渲染函数
renderWithQiankun({
bootstrap,
mount,
unmount,
update,
});
import type { Router } from "vue-router";
import {
createRouter as _createRouter,
createWebHistory,
} from "vue-router";
const routes = [
{
path: "/",
name: "Home",
component: () => import("../views/Home.vue"),
},
{
path: "/about",
name: "About",
component: () => import("@/views/About.vue"),
meta: {
title: "About",
},
},
{
path: "/communication",
name: "Communication",
component: () => import("@/views/Communication.vue"),
meta: {
title: "Communication",
},
},
{
path: "/",
name: "Home",
component: () => import("@/views/Home.vue"),
meta: {
title: "Home",
},
},
{
path: "/settings",
name: "Settings",
component: () => import("@/views/Settings.vue"),
meta: {
title: "Settings",
},
},
{
path: "/user",
name: "User",
component: () => import("@/views/User.vue"),
meta: {
title: "User",
},
},
{
path: "/aa",
name: "Aa",
component: () => import("@/views/Aa.vue"),
meta: {
title: "Aa",
},
},
];
export function createRouter(base = "/"): Router {
return _createRouter({
history: createWebHistory(base),
routes,
});
}
const router = createRouter();
export default router;
import { createPinia } from "pinia";
export const pinia = createPinia();
/* 全局样式 */
* {
box-sizing: border-box;
}
:root {
font-family:
"PingFang SC",
"Microsoft YaHei",
Inter,
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
sans-serif;
font-weight: 400;
line-height: 1.5;
color: #1f2329;
background-color: #f5f7fa;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
html,
body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
body {
min-width: 320px;
min-height: 100vh;
margin: 0;
color: #1f2329;
background: #f5f7fa;
}
#app {
width: 100%;
min-height: 100vh;
}
/* 滚动条样式 */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: #eef1f5;
}
::-webkit-scrollbar-thumb {
background: #c4cad4;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #aab2bf;
}
/* 选中文本样式 */
::selection {
color: #ffffff;
background: rgb(64 158 255 / 75%);
}
/* 响应式 */
@media (max-width: 768px) {
body {
font-size: 14px;
}
}
import type { App } from "vue";
import { VButton, VDialog, VInput, VSelect, VTable } from "@vui/vue";
import ElementPlus from "element-plus";
export function setupUI(app: App) {
app.use(ElementPlus);
app.component("VButton", VButton);
app.component("VDialog", VDialog);
app.component("VInput", VInput);
app.component("VSelect", VSelect);
app.component("VTable", VTable);
}
import { onUnmounted } from "vue";
/**
* 全局状态接口定义(与基座保持一致)
*/
export interface GlobalState {
config: {
apiBaseUrl: string;
timeout: number;
};
notifications: Notification[];
theme: {
mode: "dark" | "light";
primaryColor: string;
};
user: null | {
avatar: string;
id: string;
name: string;
permissions: string[];
role: string;
};
}
/**
* 通知消息接口
*/
export interface Notification {
from?: string;
id: string;
message: string;
timestamp: number;
title: string;
type: "error" | "info" | "success" | "warning";
}
/**
* qiankun Props 类型定义
*/
export interface QiankunProps {
[key: string]: any;
container?: HTMLElement;
onGlobalStateChange?: (
callback: (state: GlobalState, prev: GlobalState) => void,
fireImmediately?: boolean,
) => void;
routerBase?: string;
setGlobalState?: (state: Partial<GlobalState>) => void;
}
/**
* 子应用通信管理器
*/
class SubAppCommunicationManager {
private currentState: GlobalState | null = null; // 缓存当前状态
private listeners: Array<(state: GlobalState, prev: GlobalState) => void> = [];
private props: null | QiankunProps = null;
private unsubscribe: (() => void) | null = null;
/**
* 销毁
*/
destroy() {
if (this.unsubscribe) {
this.unsubscribe();
this.unsubscribe = null;
}
this.listeners = [];
this.props = null;
console.log("[子应用通信] 通信管理器已销毁");
}
/**
* 获取当前全局状态
*/
getCurrentState(): GlobalState | null {
return this.currentState;
}
/**
* 初始化通信管理器
* @param props qiankun 传递的 props
*/
init(props: QiankunProps) {
this.props = props;
// 监听全局状态变化
if (props.onGlobalStateChange) {
const unsubscribeFn = props.onGlobalStateChange(
(state: GlobalState, prev: GlobalState) => {
console.log("[子应用通信] 全局状态变化:", state, prev);
// 缓存当前状态
this.currentState = state;
// 触发所有监听器
this.listeners.forEach((listener) => {
listener(state, prev);
});
},
true, // 立即触发,获取当前状态 - 这确保了微应用一加载就能获取主应用的数据
);
// 只在返回值是函数时才赋值
if (typeof unsubscribeFn === "function") {
this.unsubscribe = unsubscribeFn;
}
}
}
/**
* 监听全局状态变化
* @param callback 回调函数
* @returns 取消监听的函数
*/
onStateChange(callback: (state: GlobalState, prev: GlobalState) => void): () => void {
this.listeners.push(callback);
// 如果已经有缓存的状态,立即调用一次回调
if (this.currentState) {
console.log("[子应用通信] 立即触发回调,使用缓存的全局状态");
callback(this.currentState, {} as GlobalState);
}
return () => {
const index = this.listeners.indexOf(callback);
if (index !== -1) {
this.listeners.splice(index, 1);
}
};
}
/**
* 向基座发送通知
* @param notification 通知消息
*/
sendNotification(notification: Omit<Notification, "id" | "timestamp">) {
if (!this.props?.setGlobalState) {
console.warn("[子应用通信] 无法发送通知,setGlobalState 方法不可用");
return;
}
// 获取当前通知列表(需要通过 props 或缓存获取)
// 这里简化处理,直接通过 state 添加
const newNotification: Notification = {
...notification,
id: Date.now().toString(),
timestamp: Date.now(),
from: notification.from || "Vue子应用",
};
// 通过修改全局状态来添加通知
// 注意:这里需要基座的 communication manager 来处理通知添加逻辑
// 所以我们实际上是触发一个状态变化,让基座来处理
this.setGlobalState({
notifications: [ newNotification ] as any, // 基座会合并到现有通知列表
});
}
/**
* 设置全局状态(向基座发送数据)
* @param state 要更新的状态
*/
setGlobalState(state: Partial<GlobalState>) {
if (this.props?.setGlobalState) {
this.props.setGlobalState(state);
console.log("[子应用通信] 全局状态已更新:", state);
} else {
console.warn("[子应用通信] setGlobalState 方法不可用");
}
}
}
// 导出单例
export const subAppCommunication = new SubAppCommunicationManager();
/**
* Vue 组合式 API - 使用全局状态
* @param callback 状态变化回调
*/
export function useGlobalState(callback: (state: GlobalState, prev: GlobalState) => void) {
const unsubscribe = subAppCommunication.onStateChange(callback);
// 在组件卸载时自动取消订阅
onUnmounted(() => {
unsubscribe();
});
return unsubscribe;
}
/**
* 便捷方法:发送通知到基座
*/
export function notify(type: Notification["type"], title: string, message: string) {
subAppCommunication.sendNotification({
type,
title,
message,
});
}
// @ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T08:31:36.839Z
<template>
<div class="transfer-confirm-page">
<div class="page-header">
<span class="page-title">调拨确认单</span>
</div>
<div class="table-wrapper">
<v-table :columns="columns"
:data="tableData"
row-key="index">
<template #actions="{ row }">
<span class="action-link"
@click="handleCancel(row)">
取消
</span>
</template>
</v-table>
</div>
<div class="pagination-wrapper">
<ElPagination v-model:current-page="currentPage"
v-model:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:page-sizes="[10, 20, 50, 100]"
:total="total"
@current-change="handlePageChange"
@size-change="handleSizeChange" />
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { ElPagination } from "element-plus";
interface TableRow {
category: string;
index: number;
productCode: string;
productName: string;
rollNumber: string;
series: string;
spec: string;
stock: string;
}
const columns = [
{ key: "index", label: "序号", width: 60, align: "center" as const },
{ key: "productName", label: "商品名称", width: 140 },
{ key: "spec", label: "规格" },
{ key: "productCode", label: "商品编码" },
{ key: "series", label: "系列" },
{ key: "category", label: "所属分类" },
{ key: "stock", label: "调拨库存", width: 100, align: "center" as const },
{ key: "rollNumber", label: "膜卷号" },
{ key: "actions", label: "操作", width: 80, align: "center" as const },
];
const tableData = ref<TableRow[]>([
{
index: 1,
productName: "商品名称商品名称\n商品名称",
spec: "A/B",
productCode: "12345678...",
series: "太阳膜多规格\n商品",
category: "太阳膜",
stock: "2米",
rollNumber: "1234,5678...",
},
{
index: 2,
productName: "商品名称商品名称\n商品名称",
spec: "A/B",
productCode: "-",
series: "太阳膜多规格\n商品",
category: "太阳膜",
stock: "2米",
rollNumber: "-",
},
{
index: 3,
productName: "商品名称商品名称\n商品名称",
spec: "五座下层纳\n帕皮上层弯头纱",
productCode: "JC-JP-0077",
series: "太阳膜多规格\n商品",
category: "太阳膜",
stock: "2米",
rollNumber: "JC-JP-0077",
},
{
index: 4,
productName: "商品名称商品名称\n商品名称",
spec: "灰色/中/muji",
productCode: "M000077",
series: "太阳膜多规格\n商品",
category: "自建商品\n-精品",
stock: "2米",
rollNumber: "M000077",
},
{
index: 5,
productName: "商品名称商品名称\n商品名称",
spec: "灰色/中/muji",
productCode: "XXXXXXXX",
series: "太阳膜多规格\n商品",
category: "精品",
stock: "3件",
rollNumber: "XXXXXXXX",
},
{
index: 6,
productName: "商品名称商品名称\n商品名称",
spec: "灰色/中/muji",
productCode: "XXXXXXXX",
series: "XXXXXXXX",
category: "权益服务",
stock: "1件",
rollNumber: "XXXXXXXX",
},
{
index: 7,
productName: "商品名称商品名称\n商品名称",
spec: "灰色/中/muji",
productCode: "XXXXXXXX",
series: "XXXXXXXX",
category: "太阳膜",
stock: "2米",
rollNumber: "XXXXXXXX",
},
{
index: 8,
productName: "商品名称商品名称\n商品名称",
spec: "灰色/中/muji",
productCode: "XXXXXXXX",
series: "XXXXXXXX",
category: "自建商品\n-精品",
stock: "3件",
rollNumber: "XXXXXXXX",
},
{
index: 9,
productName: "商品名称商品名称\n商品名称",
spec: "灰色/中/muji",
productCode: "XXXXXXXX",
series: "XXXXXXXX",
category: "精品",
stock: "1件",
rollNumber: "XXXXXXXX",
},
{
index: 10,
productName: "商品名称商品名称\n商品名称",
spec: "灰色/中/muji",
productCode: "XXXXXXXX",
series: "XXXXXXXX",
category: "权益服务",
stock: "1件",
rollNumber: "XXXXXXXX",
},
]);
const currentPage = ref(1);
const pageSize = ref(10);
const total = ref(800);
function handlePageChange(page: number): void {
currentPage.value = page;
}
function handleSizeChange(size: number): void {
pageSize.value = size;
}
function handleCancel(row: TableRow): void {
console.log("取消调拨", row.index);
}
</script>
<style scoped>
.transfer-confirm-page {
display: flex;
flex-direction: column;
gap: 16px;
padding: 20px;
background: rgb(255 255 255 / 100%);
box-shadow: 0 4px 4px 0 rgb(0 0 0 / 25%);
}
.page-header {
display: flex;
align-items: center;
padding: 12px 16px;
background: rgb(244 246 252 / 100%);
border-radius: 4px;
}
.page-title {
font-size: 16px;
font-weight: 500;
line-height: 24px;
color: rgb(51 51 51 / 100%);
}
.table-wrapper {
width: 100%;
overflow-x: auto;
}
.table-wrapper :deep(th) {
font-size: 14px;
font-weight: 500;
line-height: 16px;
color: rgb(51 51 51 / 100%);
background: rgb(244 246 252 / 100%) !important;
border: 1px solid rgb(229 229 229 / 100%) !important;
}
.table-wrapper :deep(td) {
font-size: 14px;
font-weight: 400;
line-height: 16px;
color: rgb(102 102 102 / 100%);
white-space: pre-line;
background: rgb(255 255 255 / 100%);
border: 1px solid rgb(229 229 229 / 100%) !important;
}
.action-link {
font-size: 14px;
font-weight: 400;
line-height: 16px;
color: rgb(88 80 255 / 100%);
cursor: pointer;
}
.action-link:hover {
opacity: 0.8;
}
.pagination-wrapper {
display: flex;
justify-content: flex-end;
padding: 8px 0;
}
</style>
<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>
# 安装依赖
pnpm install
# 启动开发服务器
pnpm dev
# 构建生产版本
pnpm build
</code>
</pre>
</div>
</section>
</div>
</div>
</template>
<script setup lang="ts">
// About 页面
</script>
<style scoped>
.about-view {
max-width: 900px;
margin: 0 auto;
}
.content-card {
padding: 2.5rem;
background: rgb(255 255 255 / 10%);
border: 1px solid rgb(255 255 255 / 20%);
border-radius: 1rem;
backdrop-filter: blur(10px);
}
.content-card h1 {
margin: 0 0 2rem;
font-size: 2rem;
}
.section {
margin-bottom: 2rem;
}
.section h2 {
margin: 0 0 1rem;
font-size: 1.5rem;
color: rgb(255 255 255 / 95%);
}
.tech-list,
.feature-list {
padding: 0;
margin: 0;
list-style: none;
}
.tech-list li,
.feature-list li {
padding: 0.5rem 0;
line-height: 1.6;
opacity: 0.9;
}
.code-block {
padding: 1.5rem;
overflow-x: auto;
background: rgb(0 0 0 / 30%);
border: 1px solid rgb(255 255 255 / 10%);
border-radius: 0.5rem;
}
.code-block pre {
margin: 0;
font-family: "Courier New", monospace;
font-size: 0.9rem;
line-height: 1.6;
}
.code-block code {
color: #a8e6cf;
}
</style>
<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";
const router = useRouter();
const goHome = () => {
router.push("/");
};
</script>
<style scoped>
.notfound-view {
display: flex;
align-items: center;
justify-content: center;
max-width: 600px;
min-height: 400px;
margin: 0 auto;
}
.content-card {
padding: 3rem;
text-align: center;
background: rgb(255 255 255 / 10%);
border: 1px solid rgb(255 255 255 / 20%);
border-radius: 1rem;
backdrop-filter: blur(10px);
}
.error-code {
margin-bottom: 1rem;
font-size: 6rem;
font-weight: 700;
background: linear-gradient(45deg, #fff, rgb(255 255 255 / 60%));
background-clip: text;
-webkit-text-fill-color: transparent;
}
.content-card h1 {
margin: 0 0 1rem;
font-size: 2rem;
}
.content-card p {
margin: 0 0 2rem;
opacity: 0.9;
}
.btn-home {
padding: 0.75rem 2rem;
font-size: 1rem;
font-weight: 600;
color: white;
cursor: pointer;
background: rgb(76 175 80 / 80%);
border: none;
border-radius: 0.5rem;
transition: all 0.3s ease;
}
.btn-home:hover {
background: rgb(76 175 80 / 100%);
transform: translateY(-2px);
}
</style>
<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";
interface Settings {
darkMode: boolean;
language: string;
notifications: {
desktop: boolean;
email: boolean;
sms: boolean;
};
security: {
sessionTimeout: number;
twoFactor: boolean;
};
theme: string;
timezone: string;
}
const defaultSettings: Settings = {
theme: "purple",
darkMode: false,
notifications: {
desktop: true,
email: true,
sms: false,
},
language: "zh-CN",
timezone: "Asia/Shanghai",
security: {
twoFactor: false,
sessionTimeout: 30,
},
};
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>
<style scoped>
.settings-view {
max-width: 1200px;
margin: 0 auto;
}
.content-card {
padding: 2.5rem;
background: rgb(255 255 255 / 10%);
border: 1px solid rgb(255 255 255 / 20%);
border-radius: 1rem;
backdrop-filter: blur(10px);
}
.content-card h1 {
margin: 0 0 2rem;
font-size: 2rem;
}
.settings-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
margin-bottom: 2rem;
}
.setting-group {
padding: 1.5rem;
background: rgb(255 255 255 / 5%);
border: 1px solid rgb(255 255 255 / 10%);
border-radius: 0.75rem;
}
.setting-group h2 {
margin: 0 0 1rem;
font-size: 1.2rem;
color: rgb(255 255 255 / 95%);
}
.setting-item {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1rem;
}
.setting-item label {
font-weight: 500;
}
.select-input,
.number-input {
padding: 0.5rem;
font-size: 0.9rem;
color: white;
background: rgb(255 255 255 / 10%);
border: 1px solid rgb(255 255 255 / 20%);
border-radius: 0.5rem;
}
.number-input {
width: 80px;
}
.checkbox-input {
width: 20px;
height: 20px;
cursor: pointer;
}
.actions {
display: flex;
gap: 1rem;
margin-bottom: 2rem;
}
.btn-save,
.btn-reset {
padding: 0.75rem 2rem;
font-weight: 600;
cursor: pointer;
border: none;
border-radius: 0.5rem;
transition: all 0.3s ease;
}
.btn-save {
color: white;
background: rgb(76 175 80 / 80%);
}
.btn-save:hover {
background: rgb(76 175 80 / 100%);
transform: translateY(-2px);
}
.btn-reset {
color: white;
background: rgb(158 158 158 / 80%);
}
.btn-reset:hover {
background: rgb(158 158 158 / 100%);
transform: translateY(-2px);
}
.current-settings {
padding: 1.5rem;
background: rgb(0 0 0 / 30%);
border: 1px solid rgb(255 255 255 / 10%);
border-radius: 0.75rem;
}
.current-settings h3 {
margin: 0 0 1rem;
font-size: 1.1rem;
}
.current-settings pre {
margin: 0;
overflow-x: auto;
font-family: "Courier New", monospace;
font-size: 0.9rem;
line-height: 1.6;
color: #a8e6cf;
}
</style>
<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";
interface User {
active: boolean;
email: string;
id: number;
name: string;
role: "admin" | "guest" | "user";
}
const users = ref<User[]>([
{
id: 1,
name: "张三",
email: "zhangsan@example.com",
role: "admin",
active: true,
},
{
id: 2,
name: "李四",
email: "lisi@example.com",
role: "user",
active: true,
},
{
id: 3,
name: "王五",
email: "wangwu@example.com",
role: "user",
active: false,
},
{
id: 4,
name: "赵六",
email: "zhaoliu@example.com",
role: "guest",
active: true,
},
]);
const addUser = () => {
const newUser: User = {
id: users.value.length + 1,
name: `新用户${users.value.length + 1}`,
email: `user${users.value.length + 1}@example.com`,
role: "user",
active: true,
};
users.value.push(newUser);
};
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>
<style scoped>
.user-view {
max-width: 1200px;
margin: 0 auto;
}
.content-card {
padding: 2.5rem;
background: rgb(255 255 255 / 10%);
border: 1px solid rgb(255 255 255 / 20%);
border-radius: 1rem;
backdrop-filter: blur(10px);
}
.content-card h1 {
margin: 0 0 1.5rem;
font-size: 2rem;
}
.toolbar {
margin-bottom: 1.5rem;
}
.btn-add {
padding: 0.75rem 1.5rem;
font-weight: 600;
color: white;
cursor: pointer;
background: rgb(76 175 80 / 80%);
border: none;
border-radius: 0.5rem;
transition: all 0.3s ease;
}
.btn-add:hover {
background: rgb(76 175 80 / 100%);
transform: translateY(-2px);
}
.table-container {
overflow-x: auto;
}
.user-table {
width: 100%;
border-collapse: collapse;
}
.user-table thead {
background: rgb(255 255 255 / 10%);
}
.user-table th,
.user-table td {
padding: 1rem;
text-align: left;
border-bottom: 1px solid rgb(255 255 255 / 10%);
}
.user-table th {
font-weight: 600;
color: rgb(255 255 255 / 95%);
}
.user-table tbody tr {
transition: background 0.3s ease;
}
.user-table tbody tr:hover {
background: rgb(255 255 255 / 5%);
}
.badge {
padding: 0.25rem 0.75rem;
font-size: 0.85rem;
font-weight: 600;
border-radius: 1rem;
}
.badge-admin {
background: rgb(244 67 54 / 80%);
}
.badge-user {
background: rgb(33 150 243 / 80%);
}
.badge-guest {
background: rgb(158 158 158 / 80%);
}
.status {
padding: 0.25rem 0.75rem;
font-size: 0.85rem;
font-weight: 600;
border-radius: 1rem;
}
.status-active {
background: rgb(76 175 80 / 80%);
}
.status-inactive {
background: rgb(158 158 158 / 80%);
}
.btn-edit,
.btn-delete {
padding: 0.5rem 1rem;
margin-right: 0.5rem;
font-weight: 600;
cursor: pointer;
border: none;
border-radius: 0.5rem;
transition: all 0.3s ease;
}
.btn-edit {
color: white;
background: rgb(33 150 243 / 80%);
}
.btn-edit:hover {
background: rgb(33 150 243 / 100%);
}
.btn-delete {
color: white;
background: rgb(244 67 54 / 80%);
}
.btn-delete:hover {
background: rgb(244 67 54 / 100%);
}
</style>
{
"compilerOptions": {
"target": "ES2020",
"jsx": "preserve",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"useDefineForClassFields": true,
/* Path Alias */
"baseUrl": ".",
"module": "ESNext",
/* Bundler mode */
"moduleResolution": "bundler",
"paths": {
"@/*": ["src/*"]
},
"resolveJsonModule": true,
"allowImportingTsExtensions": true,
/* Linting */
"strict": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noEmit": true,
"isolatedModules": true,
"skipLibCheck": true
},
"references": [{ "path": "./tsconfig.node.json" }],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "env.d.ts"]
}
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": ["vite.config.ts"]
}
import { resolve } from "node:path";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { defineConfig } from "vite";
import qiankun from "vite-plugin-qiankun";
const PORT = 8081;
const APP_NAME = "subapp-vue"; // 与基座配置的 name 一致
export default defineConfig(({ mode, command }) => {
const isDev = mode === "development";
const isServe = command === "serve";
return {
base: isDev && isServe ? `http://localhost:${PORT}/` : `/${APP_NAME}/`, // 生产环境使用应用名作为基础路径
plugins: [
vue(),
vueJsx(),
// 自动导入 Vue 相关函数
AutoImport({
imports: [ "vue", "vue-router", "pinia" ],
dts: "src/auto-imports.d.ts",
eslintrc: {
enabled: false,
},
}),
// 自动导入组件
Components({
dts: "src/components.d.ts",
}),
// qiankun 插件配置
qiankun(APP_NAME, {
useDevMode: isDev, // 根据实际环境动态设置
}),
],
resolve: {
alias: {
"@": resolve(import.meta.dirname, "src"),
},
},
server: {
port: PORT,
cors: true, // 允许跨域
host: true,
origin: `http://localhost:${PORT}`, // 设置资源加载的 origin
headers: {
"Access-Control-Allow-Origin": "*", // 允许所有来源
},
},
build: {
target: "esnext",
minify: false, // 开发环境不压缩,便于调试
cssCodeSplit: false, // css 不拆分
rollupOptions: {
output: {
// qiankun 需要的输出格式
format: "umd",
// UMD 库名称,必须与应用名称一致
name: `qiankunApp_${APP_NAME.replaceAll("-", "_")}`,
entryFileNames: "assets/[name].js",
chunkFileNames: "assets/[name].[hash].js",
assetFileNames: "assets/[name].[hash].[ext]",
},
},
},
};
});
{
"generator": "scripts/ai-direct-apply-output.mjs",
"generatedAt": "2026-06-05T03:45:00.662Z",
"generatedAt": "2026-06-05T08:48:51.791Z",
"model": "qwen3.7-max",
"provider": "openai-compatible",
"files": [
......@@ -59,6 +59,41 @@
"purpose": "底部竞拍操作栏,包含固定定位的白色底栏和蓝色",
"coAuthor": "@ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T03:44:52.996Z",
"action": "created"
},
{
"path": "apps/web/ai-previews/testpage-preview/src/views/dd/components/Detailnavbar.vue",
"language": "vue",
"purpose": "参拍详情页顶部导航栏,包含返回按钮和页面标题",
"coAuthor": "@ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T04:10:37.869Z",
"action": "created"
},
{
"path": "apps/web/ai-previews/testpage-preview/src/views/dd/components/Cargallery.vue",
"language": "vue",
"purpose": "二手车图片画廊组件,包含图片展示、拍卖规则标签、外观/内饰切换和照片计数",
"coAuthor": "@ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T04:11:31.541Z",
"action": "created"
},
{
"path": "apps/web/ai-previews/testpage-preview/src/views/dd/components/Cardetailcard.vue",
"language": "vue",
"purpose": "二手车商品详情卡片组件,展示车辆图片、标题、标签、车源号、起拍价和倒计时",
"coAuthor": "@ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T04:12:45.067Z",
"action": "created"
},
{
"path": "apps/web/ai-previews/testpage-preview/src/views/dd/components/Vehicleinfocard.vue",
"language": "vue",
"purpose": "车辆信息详情卡片,包含上牌概览和详细参数键值对",
"coAuthor": "@ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T04:13:45.817Z",
"action": "created"
},
{
"path": "apps/web/ai-previews/testpage-preview/src/views/aa.vue",
"language": "vue",
"purpose": "广联二手车油车详情页,包含图片轮播、车辆信息、检测报告等完整模块",
"coAuthor": "@ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T08:48:42.712Z",
"action": "created"
}
]
}
......@@ -17,6 +17,24 @@ const routes = [
title: "Home",
},
},
{
path: "/dd",
name: "dd",
component: () => import("@/views/dd/index.vue"),
meta: {
title: "dd",
},
},
{
path: "/aa",
name: "aa",
component: () => import("@/views/aa.vue"),
meta: {
title: "aa",
},
},
];
export function createRouter(): Router {
......
{
"pageName": "dd",
"componentNames": {},
"batches": [
{
"url": "https://www.figma.com/design/ZbhoA04cGHI9DMjknZ8FNB/%E5%B9%BF%E8%81%94%E4%BA%8C%E6%89%8B%E8%BD%A6%EF%BC%88%E8%AE%BE%EF%BC%89?node-id=640-708&t=UoZ7GaEcYn9o0fel-4",
"urlIndex": 0,
"batchIndex": 0
},
{
"url": "https://www.figma.com/design/ZbhoA04cGHI9DMjknZ8FNB/%E5%B9%BF%E8%81%94%E4%BA%8C%E6%89%8B%E8%BD%A6%EF%BC%88%E8%AE%BE%EF%BC%89?node-id=597-1297&t=UoZ7GaEcYn9o0fel-4",
"urlIndex": 1,
"batchIndex": 1
},
{
"url": "https://www.figma.com/design/ZbhoA04cGHI9DMjknZ8FNB/%E5%B9%BF%E8%81%94%E4%BA%8C%E6%89%8B%E8%BD%A6%EF%BC%88%E8%AE%BE%EF%BC%89?node-id=597-1239&t=UoZ7GaEcYn9o0fel-4",
"urlIndex": 2,
"batchIndex": 2
},
{
"url": "https://www.figma.com/design/ZbhoA04cGHI9DMjknZ8FNB/%E5%B9%BF%E8%81%94%E4%BA%8C%E6%89%8B%E8%BD%A6%EF%BC%88%E8%AE%BE%EF%BC%89?node-id=437-1036&t=UoZ7GaEcYn9o0fel-4",
"urlIndex": 3,
"batchIndex": 3
}
]
}
\ No newline at end of file
// @ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T04:12:45.067Z
<template>
<div class="car-detail-card">
<div class="car-image-wrapper">
<div class="car-image-placeholder">
<svg class="car-icon"
fill="none"
viewBox="0 0 64 64"
xmlns="http://www.w3.org/2000/svg">
<rect fill="#E0E0E0"
height="24"
rx="4"
width="48"
x="8"
y="20" />
<circle cx="20"
cy="44"
fill="#BDBDBD"
r="5" />
<circle cx="44"
cy="44"
fill="#BDBDBD"
r="5" />
</svg>
</div>
</div>
<div class="car-info">
<h3 class="car-title">
宝马5系 2023款 改款 530Li 领先型 M运动套装
</h3>
<div class="tag-list">
<span class="tag tag--primary">原厂质保</span>
<span class="tag tag--secondary">同款低价</span>
<span class="tag tag--secondary">准新车</span>
</div>
<div class="source-row">
<span class="source-text">车源号:321867</span>
<button class="copy-btn"
type="button"
@click="handleCopy">
<svg fill="none"
height="14"
viewBox="0 0 14 14"
width="14"
xmlns="http://www.w3.org/2000/svg">
<rect height="8"
rx="1"
stroke="#676D7D"
stroke-width="1.2"
width="8"
x="4"
y="4" />
<path d="M10 4V3C10 2.44772 9.55228 2 9 2H3C2.44772 2 2 2.44772 2 3V9C2 9.55228 2.44772 10 3 10H4"
stroke="#676D7D"
stroke-width="1.2" />
</svg>
</button>
</div>
<div class="price-row">
<div class="price-group">
<span class="price-value">7.80</span>
<span class="price-unit">万</span>
</div>
<div class="fire-icon">
<svg fill="none"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg">
<path d="M8 1C8 1 4 5 4 9C4 11.2091 5.79086 13 8 13C10.2091 13 12 11.2091 12 9C12 5 8 1 8 1Z"
fill="url(#fireGrad)" />
<defs>
<linearGradient id="fireGrad"
gradientUnits="userSpaceOnUse"
x1="8"
x2="8"
y1="1"
y2="13">
<stop stop-color="#FF5A00" />
<stop offset="1"
stop-color="#EC0000" />
</linearGradient>
</defs>
</svg>
</div>
<span class="price-label">起拍</span>
</div>
<div class="countdown-badge">
<span class="countdown-text">距离开始</span>
<span class="countdown-time">11:13:28</span>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
defineOptions({
name: "CarDetailCard",
});
const copied = ref(false);
function handleCopy(): void {
const text = "321867";
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(() => {
copied.value = true;
setTimeout(() => {
copied.value = false;
}, 2000);
});
}
}
</script>
<style scoped>
.car-detail-card {
display: flex;
width: 100%;
padding: 12px;
background: #fff;
border-radius: 10px;
box-shadow: 0 1px 4px rgb(0 0 0 / 6%);
}
.car-image-wrapper {
flex-shrink: 0;
width: 110px;
height: 82px;
margin-right: 12px;
overflow: hidden;
border-radius: 10px;
}
.car-image-placeholder {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
background: #f5f6fa;
}
.car-icon {
width: 48px;
height: 48px;
opacity: 0.5;
}
.car-info {
display: flex;
flex: 1;
flex-direction: column;
min-width: 0;
}
.car-title {
margin: 0;
overflow: hidden;
text-overflow: ellipsis;
font-family: "PingFang SC", sans-serif;
font-size: 18px;
font-weight: 500;
line-height: 27px;
color: #141e34;
white-space: nowrap;
}
.tag-list {
display: flex;
gap: 6px;
margin-top: 6px;
}
.tag {
display: inline-flex;
align-items: center;
padding: 2px 6px;
font-family: "PingFang SC", sans-serif;
font-size: 12px;
font-weight: 400;
line-height: 16.8px;
border-radius: 2px;
}
.tag--primary {
color: #ff4800;
background: #ffefeb;
}
.tag--secondary {
color: #828ca0;
background: #f5f6fa;
}
.source-row {
display: flex;
align-items: center;
justify-content: flex-end;
margin-top: 4px;
}
.source-text {
font-family: "PingFang SC", sans-serif;
font-size: 13px;
font-weight: 400;
line-height: 18.2px;
color: #676d7d;
}
.copy-btn {
display: flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
padding: 0;
margin-left: 4px;
cursor: pointer;
background: transparent;
border: none;
}
.price-row {
display: flex;
align-items: baseline;
margin-top: 6px;
}
.price-group {
display: flex;
align-items: baseline;
}
.price-value {
font-family: "PingFang SC", sans-serif;
font-size: 15px;
font-weight: 600;
line-height: 26px;
color: #ff4800;
}
.price-unit {
font-family: "PingFang SC", sans-serif;
font-size: 12px;
font-weight: 400;
line-height: 16.8px;
color: #ff4800;
}
.fire-icon {
display: flex;
align-items: center;
margin-left: 4px;
}
.price-label {
margin-left: 4px;
font-family: "PingFang SC", sans-serif;
font-size: 14px;
font-weight: 400;
line-height: 19.6px;
color: #141e34;
}
.countdown-badge {
display: inline-flex;
gap: 4px;
align-items: center;
align-self: flex-start;
padding: 3px 8px;
margin-top: 8px;
background: rgb(24 94 254 / 10%);
border-radius: 4px;
}
.countdown-text {
font-family: "PingFang SC", sans-serif;
font-size: 12px;
font-weight: 400;
line-height: 16.8px;
color: #185efe;
}
.countdown-time {
font-family: "PingFang SC", sans-serif;
font-size: 12px;
font-weight: 400;
line-height: 16.8px;
color: #185efe;
}
</style>
// @ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T04:11:31.541Z
<template>
<div class="car-gallery">
<!-- 图片展示区域 -->
<div class="gallery-image-area">
<div class="image-placeholder">
<img alt="车辆图片"
class="car-image"
src="https://via.placeholder.com/375x280/d8d8d8/999999?text=车辆图片" />
</div>
<!-- 拍卖规则标签 -->
<div class="auction-rule-tag">
<span class="tag-text">拍卖规则</span>
</div>
</div>
<!-- 底部控制栏 -->
<div class="gallery-bottom-bar">
<!-- 标签切换器 -->
<div class="tab-switcher">
<div class="tab-item"
:class="{ active: activeTab === 'exterior' }"
@click="activeTab = 'exterior'">
<span class="tab-text">外观</span>
</div>
<div class="tab-item"
:class="{ active: activeTab === 'interior' }"
@click="activeTab = 'interior'">
<span class="tab-text">内饰</span>
</div>
</div>
<!-- 照片计数器 -->
<div class="photo-counter">
<span class="counter-text">{{ currentIndex }}/{{ totalCount }}</span>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
defineOptions({
name: "CarGallery",
});
const activeTab = ref<"exterior" | "interior">("exterior");
const currentIndex = ref<number>(5);
const totalCount = ref<number>(10);
</script>
<style scoped>
.car-gallery {
position: relative;
display: flex;
flex-direction: column;
width: 100%;
overflow: hidden;
background: #fff;
}
.gallery-image-area {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 280px;
overflow: hidden;
background: #d8d8d8;
}
.image-placeholder {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
.car-image {
width: 100%;
height: 100%;
object-fit: cover;
}
.auction-rule-tag {
position: absolute;
top: 50%;
left: 0;
z-index: 2;
display: flex;
align-items: center;
padding: 6px 12px;
background: rgb(255 255 255 / 90%);
border-radius: 16px 0 0 16px;
box-shadow: 0 2px 4px 0 rgb(51 51 51 / 10%);
transform: translateY(-50%);
}
.tag-text {
font-size: 12px;
font-weight: 400;
line-height: 16.8px;
color: #333;
white-space: nowrap;
}
.gallery-bottom-bar {
position: absolute;
right: 12px;
bottom: 12px;
left: 12px;
z-index: 3;
display: flex;
align-items: center;
justify-content: space-between;
}
.tab-switcher {
display: flex;
align-items: center;
overflow: hidden;
background: rgb(51 51 51 / 80%);
border-radius: 17px;
}
.tab-item {
display: flex;
align-items: center;
justify-content: center;
padding: 6px 16px;
cursor: pointer;
border-radius: 17px;
transition: background-color 0.2s ease;
}
.tab-item.active {
background: #fff;
border-radius: 11px;
}
.tab-text {
font-size: 11px;
font-weight: 400;
line-height: 15.4px;
color: #fff;
white-space: nowrap;
}
.tab-item.active .tab-text {
color: #000;
}
.photo-counter {
display: flex;
align-items: center;
justify-content: center;
padding: 4px 10px;
background: rgb(51 51 51 / 80%);
border-radius: 11px;
}
.counter-text {
font-size: 11px;
font-weight: 400;
line-height: 15.4px;
color: #fff;
white-space: nowrap;
}
</style>
// @ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T04:10:37.869Z
<template>
<div class="detail-nav-bar">
<VNavBar left-arrow
title="参拍详情"
@click-left="handleClickLeft" />
</div>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";
const router = useRouter();
const handleClickLeft = (): void => {
router.back();
};
</script>
<style scoped>
.detail-nav-bar {
position: sticky;
top: 0;
z-index: 100;
background: rgb(255 255 255 / 100%);
}
</style>
// @ai-co-author venus-ai-direct | openai-compatible/qwen3.7-max | 2026-06-05T04:13:45.817Z
<template>
<div class="vehicle-info-card">
<!-- 顶部四列概览区 -->
<div class="overview-section">
<div class="overview-bg">
<div class="overview-grid">
<div class="overview-item">
<span class="overview-label">首次上牌</span>
<span class="overview-value">2022.02</span>
</div>
<div class="overview-item">
<span class="overview-label">表显里程</span>
<span class="overview-value">23.75万公里</span>
</div>
<div class="overview-item">
<span class="overview-label">过户次数</span>
<span class="overview-value">0次</span>
</div>
<div class="overview-item">
<span class="overview-label">使用性质</span>
<span class="overview-value">非营运</span>
</div>
</div>
</div>
</div>
<!-- 分隔线 -->
<div class="divider" />
<!-- 详情键值对区 -->
<div class="detail-section">
<div class="detail-row">
<div class="detail-col">
<span class="detail-label">是否有抵押</span>
<span class="detail-value">无</span>
</div>
<div class="detail-col">
<span class="detail-label">所有人性质</span>
<span class="detail-value">无</span>
</div>
</div>
<div class="detail-row">
<div class="detail-col">
<span class="detail-label">出厂时间</span>
<span class="detail-value">2021.08</span>
</div>
<div class="detail-col">
<span class="detail-label">历史所有人性质</span>
<span class="detail-value">2021.08</span>
</div>
</div>
<div class="detail-row">
<div class="detail-col">
<span class="detail-label">年检到期</span>
<span class="detail-value">2027.08</span>
</div>
<div class="detail-col">
<span class="detail-label">交强险到期</span>
<span class="detail-value">-</span>
</div>
</div>
<div class="detail-row">
<div class="detail-col">
<span class="detail-label">最近过户</span>
<span class="detail-value">-</span>
</div>
<div class="detail-col">
<span class="detail-label">燃料系统</span>
<span class="detail-value">汽油+48V轻混系统</span>
</div>
</div>
<div class="detail-row">
<div class="detail-col">
<span class="detail-label">排放标准</span>
<span class="detail-value">国6</span>
</div>
<div class="detail-col">
<span class="detail-label">车身颜色</span>
<span class="detail-value">其他</span>
</div>
</div>
<div class="detail-row">
<div class="detail-col">
<span class="detail-label">登记证</span>
<span class="detail-value">检测时已带</span>
</div>
<div class="detail-col">
<span class="detail-label">登记证颜色</span>
<span class="detail-value">黄色</span>
</div>
</div>
<div class="detail-row">
<div class="detail-col">
<span class="detail-label">座位数</span>
<span class="detail-value">-</span>
</div>
<div class="detail-col" />
</div>
</div>
</div>
</template>
<script setup lang="ts">
defineOptions({
name: "VehicleInfoCard",
});
</script>
<style scoped>
.vehicle-info-card {
box-sizing: border-box;
width: 100%;
padding: 12px;
background: rgb(255 255 255 / 100%);
border: 1px solid rgb(151 151 151 / 100%);
border-radius: 8px;
}
.overview-section {
margin-bottom: 12px;
}
.overview-bg {
padding: 12px 8px;
background: rgb(245 249 255 / 100%);
border: 1px solid rgb(255 255 255 / 100%);
border-radius: 4px;
}
.overview-grid {
display: flex;
justify-content: space-between;
}
.overview-item {
display: flex;
flex: 1;
flex-direction: column;
gap: 4px;
align-items: center;
}
.overview-label {
font-family: "PingFang SC", sans-serif;
font-size: 11px;
font-weight: 400;
line-height: 15.4px;
color: rgb(153 153 153 / 100%);
text-align: center;
}
.overview-value {
font-family: "PingFang SC", sans-serif;
font-size: 14px;
font-weight: 500;
line-height: 19.6px;
color: rgb(51 51 51 / 100%);
text-align: center;
}
.divider {
height: 1px;
margin: 12px 0;
background: rgb(216 216 216 / 100%);
}
.detail-section {
display: flex;
flex-direction: column;
gap: 14px;
}
.detail-row {
display: flex;
justify-content: space-between;
}
.detail-col {
display: flex;
flex: 1;
gap: 8px;
align-items: center;
}
.detail-label {
flex-shrink: 0;
font-family: "PingFang SC", sans-serif;
font-size: 14px;
font-weight: 400;
line-height: 14px;
color: rgb(153 153 153 / 100%);
text-align: left;
letter-spacing: 0.4px;
}
.detail-value {
font-family: "PingFang SC", sans-serif;
font-size: 14px;
font-weight: 400;
line-height: 14px;
color: rgb(51 51 51 / 100%);
text-align: left;
letter-spacing: 0.4px;
}
</style>
<script setup lang="ts">
import Detailnavbar from "./components/Detailnavbar.vue";
import Cargallery from "./components/Cargallery.vue";
import Cardetailcard from "./components/Cardetailcard.vue";
import Vehicleinfocard from "./components/Vehicleinfocard.vue";
</script>
<template>
<div class="dd-page">
<Detailnavbar />
<Cargallery />
<Cardetailcard />
<Vehicleinfocard />
</div>
</template>
<style scoped>
.dd-page {
display: flex;
flex-direction: column;
}
</style>
......@@ -796,6 +796,61 @@ importers:
specifier: ^1.13.0
version: 1.14.0
apps/web/ai-previews/diaobo-preview:
dependencies:
'@vueuse/core':
specifier: 'catalog:'
version: 13.9.0(vue@3.5.26(typescript@5.9.3))
'@vui/vue':
specifier: workspace:*
version: link:../../../../packages/vui/vue
element-plus:
specifier: 'catalog:'
version: 2.13.0(vue@3.5.26(typescript@5.9.3))
pinia:
specifier: ^3.0.3
version: 3.0.4(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3))
vue:
specifier: ^3.5.17
version: 3.5.26(typescript@5.9.3)
vue-router:
specifier: 'catalog:'
version: 4.6.4(vue@3.5.26(typescript@5.9.3))
devDependencies:
'@types/node':
specifier: ^24.9.2
version: 24.10.4
'@venus/eslint-config':
specifier: workspace:*
version: link:../../../../internal/lint-configs/eslint-config
'@vitejs/plugin-vue':
specifier: 'catalog:'
version: 6.0.3(vite@7.3.1(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.31.1)(sass@1.97.2)(terser@5.44.1)(yaml@2.8.2))(vue@3.5.26(typescript@5.9.3))
'@vitejs/plugin-vue-jsx':
specifier: 'catalog:'
version: 5.1.3(vite@7.3.1(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.31.1)(sass@1.97.2)(terser@5.44.1)(yaml@2.8.2))(vue@3.5.26(typescript@5.9.3))
eslint:
specifier: 'catalog:'
version: 9.39.2(jiti@2.6.1)
typescript:
specifier: 'catalog:'
version: 5.9.3
unplugin-auto-import:
specifier: 'catalog:'
version: 0.17.8(@vueuse/core@13.9.0(vue@3.5.26(typescript@5.9.3)))(rollup@4.55.1)
unplugin-vue-components:
specifier: 'catalog:'
version: 0.26.0(@babel/parser@7.29.0)(rollup@4.55.1)(vue@3.5.26(typescript@5.9.3))
vite:
specifier: 'catalog:'
version: 7.3.1(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.31.1)(sass@1.97.2)(terser@5.44.1)(yaml@2.8.2)
vite-plugin-qiankun:
specifier: 'catalog:'
version: 1.0.15(typescript@5.9.3)(vite@7.3.1(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.31.1)(sass@1.97.2)(terser@5.44.1)(yaml@2.8.2))
vue-tsc:
specifier: 'catalog:'
version: 2.2.10(typescript@5.9.3)
apps/web/ai-previews/testpage-preview:
dependencies:
'@vueuse/core':
......
......@@ -35,6 +35,7 @@ function parseCliArgs() {
appendMode: false,
pageName: "",
batchUrls: [],
singlePageMode: false,
};
for (let index = 0; index < args.length; index++) {
......@@ -55,6 +56,8 @@ function parseCliArgs() {
index++;
} else if (arg === "--append-mode") {
parsed.appendMode = true;
} else if (arg === "--single-page-mode") {
parsed.singlePageMode = true;
} else if (arg === "--page-name" && next) {
parsed.pageName = next;
index++;
......@@ -326,6 +329,66 @@ function collectVueViews(srcDir) {
return views;
}
// 自动为有 components/ 目录但缺少 index.vue 的页面目录生成组合页
function ensurePageIndexForPageDirs(projectRoot) {
const viewsDir = path.join(projectRoot, "src", "views");
if (!fs.existsSync(viewsDir)) return [];
const created = [];
const entries = fs.readdirSync(viewsDir, { withFileTypes: true });
for (const entry of entries) {
if (!entry.isDirectory()) continue;
const pageDir = path.join(viewsDir, entry.name);
const componentsDir = path.join(pageDir, "components");
const indexPath = path.join(pageDir, "index.vue");
// 只处理有 components/ 目录但缺少 index.vue 的页面
if (!fs.existsSync(componentsDir)) continue;
if (fs.existsSync(indexPath)) continue;
// 扫描 components/ 下的 .vue 文件
const componentFiles = fs.readdirSync(componentsDir)
.filter((f) => f.endsWith(".vue"))
.map((f) => f.replace(/\.vue$/, ""));
if (componentFiles.length === 0) continue;
// 生成 index.vue,引入并组合所有子组件
const pageName = entry.name;
const pageClass = `${pageName}-page`;
const imports = componentFiles
.map((name) => `import ${toPascalCase(name)} from "./components/${name}.vue";`)
.join("\n");
const templateParts = componentFiles
.map((name) => ` <${toPascalCase(name)} />`)
.join("\n");
const content = `<script setup lang="ts">
${imports}
</script>
<template>
<div class="${pageClass}">
${templateParts}
</div>
</template>
<style scoped>
.${pageClass} {
display: flex;
flex-direction: column;
}
</style>
`;
fs.writeFileSync(indexPath, content, "utf8");
_log(`[ensurePageIndexForPageDirs] ✓ 自动生成 ${entry.name}/index.vue(包含 ${componentFiles.length} 个组件)`);
created.push(entry.name);
}
return created;
}
function registerRoutesInRouter(projectRoot) {
const routerCandidates = [
path.join(projectRoot, "src", "router", "index.ts"),
......@@ -342,7 +405,10 @@ function registerRoutesInRouter(projectRoot) {
const srcDir = path.join(projectRoot, "src");
const views = collectVueViews(srcDir);
if (views.length === 0) return { count: 0, routerFile };
if (views.length === 0) {
const cleanedUp = cleanupStaleRoutes(routerFile, projectRoot);
return { count: 0, routerFile, staleRoutesRemoved: cleanedUp };
}
let routerContent = fs.readFileSync(routerFile, "utf8");
......@@ -360,7 +426,11 @@ function registerRoutesInRouter(projectRoot) {
}
const newViews = views.filter((v) => !registeredComponents.has(v.viewPath));
if (newViews.length === 0) return { count: 0, routerFile };
if (newViews.length === 0) {
// 没有新路由要注册,但仍需清理失效路由
const cleanedUp = cleanupStaleRoutes(routerFile, projectRoot);
return { count: 0, routerFile, staleRoutesRemoved: cleanedUp };
}
const routeEntries = newViews.map((v) => {
const routePath = v.name === "Home" ? "/" : `/${toKebabCase(v.name)}`;
......@@ -388,7 +458,55 @@ function registerRoutesInRouter(projectRoot) {
}
fs.writeFileSync(routerFile, routerContent, "utf8");
return { count: newViews.length, routerFile };
// 清理指向不存在文件的路由(处理前批次残留目录被清理后的脏路由)
const cleanedUp = cleanupStaleRoutes(routerFile, projectRoot);
return { count: newViews.length, routerFile, staleRoutesRemoved: cleanedUp };
}
// 移除路由文件中指向不存在文件的路由条目
function cleanupStaleRoutes(routerFile, projectRoot) {
let content = fs.readFileSync(routerFile, "utf8");
const srcDir = path.join(projectRoot, "src");
let removed = 0;
// 匹配所有 import("...") 路径,检查文件是否存在
const routeImportPattern = /import\(["']((?:@\/views\/|\.\.\/views\/)[^"']+)["']\)/g;
let routeMatch;
const stalePaths = [];
while ((routeMatch = routeImportPattern.exec(content)) !== null) {
const importPath = routeMatch[1];
// 将 @/views/xxx 或 ../views/xxx 解析为实际文件路径
const relativePart = importPath.replace(/^@\/views\//, "").replace(/^\.\.\/views\//, "");
const filePath = path.join(srcDir, "views", relativePart);
if (!fs.existsSync(filePath)) {
stalePaths.push(importPath);
}
}
for (const stalePath of stalePaths) {
// 匹配包含这个 import 的整个路由对象 { ... }
const escapedPath = stalePath.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
// 匹配从 { 到 }, 的路由块,包含该 import 路径
const routeBlockPattern = new RegExp(
`\\{[^{}]*?import\\(["']${escapedPath}["']\\)[^{}]*?\\},?\\s*`,
"g",
);
const before = content;
content = content.replaceAll(routeBlockPattern, "");
if (content !== before) {
removed++;
}
}
if (removed > 0) {
fs.writeFileSync(routerFile, content, "utf8");
_log(`[cleanupStaleRoutes] ✓ 移除 ${removed} 条失效路由(指向不存在的文件)`);
}
return removed;
}
// 立即更新 index.vue:添加组件 import 和使用
......@@ -478,6 +596,7 @@ function run() {
throw new Error("--register-routes-only 模式需要提供 --project-root");
}
console.log(`[ai-direct-apply-output] 仅注册路由模式: ${args.projectRoot}`);
ensurePageIndexForPageDirs(args.projectRoot);
const routerResult = registerRoutesInRouter(args.projectRoot);
if (routerResult.count > 0) {
console.log(`[ai-direct-apply-output] ✓ 自动注册路由: ${routerResult.count} 个新页面`);
......@@ -534,28 +653,52 @@ function run() {
const skippedRouterFiles = [];
const writtenFiles = [];
// 单页面模式(追加模式 + 单 URL):直接写入 views/ 下,不走 components + index 模式
if (args.appendMode && args.singlePageMode) {
const viewsDir = path.join(projectRoot, "src", "views");
ensureDir(viewsDir);
for (const file of response.files || []) {
const normalized = (file.path || "").replaceAll("\\", "/");
if (routerFilePatterns.has(normalized)) {
skippedRouterFiles.push(normalized);
continue;
}
if (!normalized.endsWith(".vue")) continue;
// 直接使用 AI 返回的路径(AI 被指示生成 src/views/{PageName}.vue)
const targetPath = path.join(projectRoot, normalized);
ensureDir(path.dirname(targetPath));
fs.writeFileSync(targetPath, file.content, "utf8");
prependCoAuthorHeader(targetPath, coAuthorHeader.line);
const relativePath = normalizePath(path.relative(repoRoot, targetPath));
writtenFiles.push({
path: relativePath,
language: file.language,
purpose: file.purpose,
});
attributionEntries.push({
path: relativePath,
language: file.language,
purpose: file.purpose,
coAuthor: coAuthorHeader.text,
action: "created",
});
}
if (skippedRouterFiles.length > 0) {
console.log(`[ai-direct-apply-output] 跳过路由文件: ${skippedRouterFiles.join(", ")}`);
}
console.log(`[ai-direct-apply-output] ✓ 单页面模式: ${writtenFiles.length} 个页面写入 ${viewsDir}`);
}
// 多批次模式:管道控制文件组织,忽略 AI 的路径
if (args.appendMode && args.pageName && args.batchUrls.length > 0) {
else if (args.appendMode && args.pageName && args.batchUrls.length > 0) {
const viewsDir = path.join(projectRoot, "src", "views");
const componentsDir = path.join(viewsDir, args.pageName, "components");
ensureDir(componentsDir);
// 生成组件名:优先使用用户自定义名称,否则从 URL 推导
const componentNames = args.batchUrls.map((url, idx) => {
// 优先使用用户自定义名称
if (args.componentNames && args.componentNames[url]) {
return args.componentNames[url];
}
// 从 Figma URL 提取节点名,如 "node-123:456" 或页面标题
const nodeMatch = url.match(/node-id=([^&]+)/);
if (nodeMatch) {
const nodeId = nodeMatch[1].replaceAll(":", "").replaceAll("-", "");
return `Node${nodeId}`;
}
// 兜底:用批次索引
return `Component${args.batchIndex || 0}_${idx}`;
});
let fileIndex = 0;
for (const file of response.files || []) {
......@@ -568,10 +711,34 @@ function run() {
// 只处理 .vue 文件,忽略其他
if (!normalized.endsWith(".vue")) continue;
// 管道决定文件名:按 URL 顺序或批次索引
const componentName = fileIndex < componentNames.length
? componentNames[fileIndex]
: `Component${args.batchIndex || 0}_${fileIndex}`;
// 管道决定文件名:优先使用用户自定义名称,其次使用 AI 返回的文件名,最后兜底
const batchUrl = fileIndex < args.batchUrls.length ? args.batchUrls[fileIndex] : null;
let componentName;
if (batchUrl && args.componentNames && args.componentNames[batchUrl]) {
// 1. 用户通过 --component-names 显式指定
componentName = args.componentNames[batchUrl];
} else if (normalized) {
// 2. 使用 AI 返回的 files[].path 中的文件名(AI 根据内容归纳的语义化名称)
const aiBasename = path.basename(normalized, ".vue");
const meaninglessPattern = /^(?:Node\d+|Frame\s*\d+|Group\s*\d+|FigmaPage|index|Component\d+_\d+)$/i;
if (aiBasename && !meaninglessPattern.test(aiBasename)) {
componentName = toPascalCase(aiBasename);
}
}
if (!componentName) {
// 3. 兜底:从 Figma URL 提取节点 ID
if (batchUrl) {
const nodeMatch = batchUrl.match(/node-id=([^&]+)/);
if (nodeMatch) {
const nodeId = nodeMatch[1].replaceAll(":", "").replaceAll("-", "");
componentName = `Node${nodeId}`;
}
}
componentName = componentName || `Component${args.batchIndex || 0}_${fileIndex}`;
}
const fileName = `${componentName}.vue`;
const targetPath = path.join(componentsDir, fileName);
......@@ -655,6 +822,8 @@ function run() {
}
}
// 确保所有有 components/ 的页面目录都有 index.vue,然后再注册路由
ensurePageIndexForPageDirs(projectRoot);
const routerResult = registerRoutesInRouter(projectRoot);
if (routerResult.count > 0) {
console.log(`[ai-direct-apply-output] 自动注册路由: ${routerResult.count} 个新页面`);
......
......@@ -973,7 +973,7 @@ async function resolveAiResponse({ args, bundlePath }) {
const previousSummary = lastResponse?.summary || "(无摘要)";
const correctionMessage = {
role: "user",
content: `## ⚠ 上次响应不合格,必须重新生成\n\n你上次返回的内容:\n\`\`\`json\n${JSON.stringify(lastResponse, null, 2)}\n\`\`\`\n\n**问题**:${lastResponse && !Array.isArray(lastResponse.files) ? "缺少 files 数组" : Array.isArray(lastResponse.files) && lastResponse.files.length === 0 ? "files 数组为空" : "响应格式错误"}\n\n**强制要求**:\n1. 必须生成完整的 Vue 组件代码\n2. files 数组必须非空,每个元素包含 path、language、purpose、content\n3. content 字段必须是完整可执行的 Vue SFC 代码(包含 <template>、<script>、<style>)\n4. 禁止只返回 summary\n5. 禁止返回空 files 数组\n\n**现在立即重新生成,严格按照以上要求输出完整 JSON。**`,
content: `## ⚠ 上次响应不合格,必须重新生成\n\n你上次返回的内容:\n\`\`\`json\n${JSON.stringify(lastResponse, null, 2)}\n\`\`\`\n\n**问题**:${lastResponse && !Array.isArray(lastResponse.files) ? "缺少 files 数组,只返回了 summary" : Array.isArray(lastResponse.files) && lastResponse.files.length === 0 ? "files 数组为空" : "响应格式错误"}\n\n**你必须输出包含 files 数组的完整 JSON。**\n即使 design context 非常简单(比如只有一个按钮、一个导航栏),也必须生成完整的 Vue SFC 代码。\n\n**输出格式模板(必须严格遵循):**\n\`\`\`json\n{\n "summary": "简要描述",\n "files": [\n {\n "path": "src/views/<PageName>/components/<ComponentName>.vue",\n "language": "vue",\n "purpose": "组件用途描述",\n "content": "<script setup lang=\\"ts\\">\\n// 组件逻辑\\n</script>\\n\\n<template>\\n <!-- 组件模板 -->\\n</template>\\n\\n<style scoped>\\n/* 样式 */\\n</style>"\n }\n ]\n}\n\`\`\`\n\n**现在立即按上述格式重新生成完整 JSON。files 数组不能为空,content 必须是完整的 Vue SFC 代码。**`,
};
currentMessages = [...messagesPayload.messages, correctionMessage];
_log(`[ai-direct-execute] ⚠ 第 ${attempt} 次重试:上次响应 ${previousSummary}`);
......@@ -1442,6 +1442,11 @@ async function run() {
}
if (args.existingPreviewProjectRoot) {
applyArgs.push("--append-mode");
// 检测单页面模式:bundle 没有 _batchMode 时为单 URL 生成
const isSinglePageMode = !bundle.figma?._batchMode;
if (isSinglePageMode) {
applyArgs.push("--single-page-mode");
}
if (args.pageName) {
applyArgs.push("--page-name", args.pageName);
}
......
......@@ -571,6 +571,26 @@ function validateRouterConsistency({ response }) {
return { errors, warnings };
}
// 组件文件命名校验:拦截 Node123、Frame1、Group3、FigmaPage 等无意义名称
function validateComponentFileNaming({ response }) {
const errors = [];
const warnings = [];
const meaninglessPattern = /(?:^|\/)(?:Node\d+|Frame\s*\d+|Group\s*\d+|FigmaPage)\.vue$/i;
for (const file of response.files) {
const normalizedPath = file.path.replaceAll("\\", "/");
if (!normalizedPath.endsWith(".vue")) continue;
if (meaninglessPattern.test(normalizedPath)) {
errors.push(
`组件文件名无意义: \`${normalizedPath}\`。请根据组件内容归纳语义化名称(如 ProductList.vue、UserProfileCard.vue),不要使用 Figma 节点 ID 作为文件名。`,
);
}
}
return { errors, warnings };
}
// 轻量级本地导入一致性检查:不依赖 node_modules,只检查本地文件的 named import 是否在目标文件中有对应导出
function validateLocalImportConsistency({ preview }) {
const errors = [];
......@@ -712,6 +732,7 @@ function run() {
const primaryDataResult = validatePrimaryFigmaDataAdherence({ response, bundle, bundlePath });
const visualSummaryResult = validateVisualSummaryAdherence({ response, bundle, bundlePath });
const routerConsistencyResult = validateRouterConsistency({ response });
const fileNamingResult = validateComponentFileNaming({ response });
const importConsistencyResult = validateLocalImportConsistency({ preview });
const commands = [
runCommand(`node scripts/lint-changed.mjs ${changedFiles.map((file) => `"${file}"`).join(" ")}`, repoRoot),
......@@ -732,6 +753,7 @@ function run() {
primaryDataResult.errors.length === 0 &&
visualSummaryResult.errors.length === 0 &&
routerConsistencyResult.errors.length === 0 &&
fileNamingResult.errors.length === 0 &&
importConsistencyResult.errors.length === 0 &&
failedCommands.length === 0
? "passed"
......@@ -752,6 +774,7 @@ function run() {
primaryDataValidation: primaryDataResult,
visualSummaryValidation: visualSummaryResult,
routerConsistencyValidation: routerConsistencyResult,
fileNamingValidation: fileNamingResult,
importConsistencyValidation: importConsistencyResult,
commandResults: commands,
};
......@@ -828,6 +851,17 @@ function run() {
console.warn(`[ai-direct-validate-output] warning: ${warning}`);
}
if (fileNamingResult.errors.length > 0) {
console.error("[ai-direct-validate-output] 组件文件命名校验失败:");
for (const error of fileNamingResult.errors) {
console.error(` - ${error}`);
}
}
for (const warning of fileNamingResult.warnings) {
console.warn(`[ai-direct-validate-output] warning: ${warning}`);
}
if (importConsistencyResult.errors.length > 0) {
console.error("[ai-direct-validate-output] 本地导入一致性校验失败:");
for (const error of importConsistencyResult.errors) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!