Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .env.compose.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ SEED_ADMIN_PASSWORD=
# 国内网络可改用镜像:https://registry.npmmirror.com
NPM_REGISTRY=https://registry.npmjs.org

# Optional AI-only outbound HTTP proxy. Use ai:4112 rather than bare ai:
# some HTTP clients interpret bare ai as a suffix and bypass proxies for *.ai.
AI_USE_ENV_PROXY=0
AI_OUTBOUND_PROXY=
AI_NO_PROXY=localhost,127.0.0.1,::1,api,ai:4112,worker,minio

# ── 模型(可选)──
# 只是首启兜底,之后在编辑器「设置」页维护。全部留空也能启动。
# REASONING_MODEL_BASE_URL=
# REASONING_MODEL_API_KEY=
# REASONING_MODEL_ID=
# VISION_MODEL_BASE_URL=
# VISION_MODEL_API_KEY=
# VISION_MODEL_ID=
# EMBEDDING_MODEL_BASE_URL=
# EMBEDDING_MODEL_API_KEY=
# EMBEDDING_MODEL_ID=
Expand Down
3 changes: 2 additions & 1 deletion apps/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<link rel="icon" type="image/png" href="/logo.png" />
<link rel="apple-touch-icon" href="/logo.png" />
<meta name="referrer" content="same-origin" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/cdn/animate/3.5.1/animate.min.css" type="text/css" />
Expand Down
Binary file removed apps/app/public/img/maskLayer.93de78c5.png
Binary file not shown.
Binary file removed apps/app/public/img/maskLayer.ef2b23ee.png
Binary file not shown.
61 changes: 0 additions & 61 deletions apps/app/public/lib/sdk/hooks.bundled.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ declare const ComponentFlatSchema: z.ZodObject<{
"simple-particle": import("..").ExtendsEnum.SimpleParticle;
"sw-dataContainer": import("..").ExtendsEnum.SwDataContainer;
"sw-weather": import("..").ExtendsEnum.SwWeather;
"sw-mask-layer": import("..").ExtendsEnum.SwMaskLayer;
}>, z.ZodEnum<{
rasterProgressBar: import("..").IndicatorEnum.RasterProgressBar;
iconRatio: import("..").IndicatorEnum.IconRatio;
Expand Down Expand Up @@ -3422,35 +3421,6 @@ declare const swDigitalHumanOptionSchema: z.ZodObject<{
}, z.core.$strip>;
type ftDigitalHumanOption = z.infer<typeof swDigitalHumanOptionSchema>;

import { z } from 'zod';
declare const swMaskLayerDataSchema: z.ZodArray<z.ZodObject<{
text: z.ZodString;
}, z.core.$strip>>;
type ftMaskLayerData = z.infer<typeof swMaskLayerDataSchema>;
declare const swMaskLayerOptionSchema: z.ZodObject<{
linearGradient: z.ZodObject<{
markColor: z.ZodString;
markPosition: z.ZodNumber;
markRadius: z.ZodNumber;
markOpacity: z.ZodNumber;
}, z.core.$strip>;
radioactiveGradation: z.ZodObject<{
markColor: z.ZodString;
markOpacityRadius: z.ZodNumber;
markOpacity: z.ZodNumber;
markUnOpacityRadius: z.ZodNumber;
showLengthWidthRatio: z.ZodBoolean;
lengthWidthRatio: z.ZodNumber;
}, z.core.$strip>;
markType: z.ZodString;
pointerEvents: z.ZodBoolean;
refresh: z.ZodBoolean;
backdropFilter: z.ZodBoolean;
backdropFilterBlur: z.ZodNumber;
backdropFilterSaturate: z.ZodNumber;
}, z.core.$strip>;
type ftMaskLayerOption = z.infer<typeof swMaskLayerOptionSchema>;

import { z } from 'zod';
declare const swUnrealEngineDataSchema: z.ZodArray<z.ZodObject<{
text: z.ZodString;
Expand Down Expand Up @@ -12321,33 +12291,6 @@ declare const componentPropSchemaMap: {
showAnalysis: z.ZodBoolean;
}, z.core.$strip>;
};
readonly "sw-mask-layer": {
readonly data: z.ZodArray<z.ZodObject<{
text: z.ZodString;
}, z.core.$strip>>;
readonly option: z.ZodObject<{
linearGradient: z.ZodObject<{
markColor: z.ZodString;
markPosition: z.ZodNumber;
markRadius: z.ZodNumber;
markOpacity: z.ZodNumber;
}, z.core.$strip>;
radioactiveGradation: z.ZodObject<{
markColor: z.ZodString;
markOpacityRadius: z.ZodNumber;
markOpacity: z.ZodNumber;
markUnOpacityRadius: z.ZodNumber;
showLengthWidthRatio: z.ZodBoolean;
lengthWidthRatio: z.ZodNumber;
}, z.core.$strip>;
markType: z.ZodString;
pointerEvents: z.ZodBoolean;
refresh: z.ZodBoolean;
backdropFilter: z.ZodBoolean;
backdropFilterBlur: z.ZodNumber;
backdropFilterSaturate: z.ZodNumber;
}, z.core.$strip>;
};
readonly "sw-unreal-engine": {
readonly data: z.ZodArray<z.ZodObject<{
text: z.ZodString;
Expand Down Expand Up @@ -13536,7 +13479,6 @@ declare const extendsEnumTypeSchema: z.ZodEnum<{
"simple-particle": import("..").ExtendsEnum.SimpleParticle;
"sw-dataContainer": import("..").ExtendsEnum.SwDataContainer;
"sw-weather": import("..").ExtendsEnum.SwWeather;
"sw-mask-layer": import("..").ExtendsEnum.SwMaskLayer;
}>;
/** 面板类型枚举 Schema */
declare const PanelEnumSchema: z.ZodEnum<{
Expand Down Expand Up @@ -13609,7 +13551,6 @@ declare const allComponentTypeSchema: z.ZodUnion<readonly [z.ZodEnum<{
"simple-particle": import("..").ExtendsEnum.SimpleParticle;
"sw-dataContainer": import("..").ExtendsEnum.SwDataContainer;
"sw-weather": import("..").ExtendsEnum.SwWeather;
"sw-mask-layer": import("..").ExtendsEnum.SwMaskLayer;
}>, z.ZodEnum<{
rasterProgressBar: import("..").IndicatorEnum.RasterProgressBar;
iconRatio: import("..").IndicatorEnum.IconRatio;
Expand Down Expand Up @@ -15821,8 +15762,6 @@ declare enum ExtendsEnum {
SwDataContainer = "sw-dataContainer",
/** 天气 */
SwWeather = "sw-weather",
/** 遮罩层 */
SwMaskLayer = "sw-mask-layer"
}
/**
* 扩展子组件枚举
Expand Down
Binary file added apps/app/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const contentStyle = computed(() => {
watchEffect(() => {
const appEl = document.getElementById("app");
if (appEl) {
appEl.style.backgroundColor = isBuildRoute.value ? "#181a24" : "";
appEl.style.backgroundColor = isBuildRoute.value ? "var(--sw-editor-bg)" : "";
}
});

Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/api/aiModel.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { BaseEntity } from "@/model/BaseEntity";
import { serverRequest } from "@/utils/serverService";

/** 5 个模型角色 */
export type ModelRole = "reasoning" | "vision" | "embedding" | "image" | "video";
/** 4 个模型角色 */
export type ModelRole = "reasoning" | "embedding" | "image" | "video";

export interface AiModelVo {
role: ModelRole;
Expand Down
Binary file added apps/app/src/assets/image/models/embedding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/app/src/assets/image/models/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/app/src/assets/image/models/reasoning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/app/src/assets/image/models/video.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const useExtendsComponents = () => {
{ name: ExtendsEnum.SimpleStar, title: "闪点组件", component: materialMap[ExtendsEnum.SimpleStar]! },
{ name: ExtendsEnum.FullScreenSwitch, title: "全屏切换", component: materialMap[ExtendsEnum.FullScreenSwitch]! },
{ name: ExtendsEnum.PageReload, title: "页面刷新", component: materialMap[ExtendsEnum.PageReload]! },
{ name: ExtendsEnum.SwMaskLayer, title: "放射性/线性渐变遮罩层", component: materialMap[ExtendsEnum.SwMaskLayer]! },
{ name: ExtendsEnum.SimpleParticle, title: "上升粒子", component: materialMap[ExtendsEnum.SimpleParticle]! },
{ name: ExtendsEnum.SwDataContainer, title: "数据容器", component: materialMap[ExtendsEnum.SwDataContainer]! },
{ name: ExtendsEnum.SwWeather, title: "天气", component: materialMap[ExtendsEnum.SwWeather]! }
Expand Down
13 changes: 13 additions & 0 deletions apps/app/src/layout/Siderbar/aside.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
background: $sw-surface-2;
}

.aside-brand {
display: flex;
flex-shrink: 0;
justify-content: center;
padding: 16px 0 8px;

img {
display: block;
border-radius: 8px;
object-fit: contain;
}
}

.aside-nav {
flex: 1 1 auto;
min-height: 0;
Expand Down
3 changes: 3 additions & 0 deletions apps/app/src/layout/Siderbar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<el-aside class="layout-aside aside-container" :class="{ 'is-narrow': hideSecondary }">
<!-- 一级菜单列 -->
<div class="aside-primary">
<div class="aside-brand">
<img src="/logo.png" alt="Screenwright Logo" width="40" height="40" />
</div>
<nav class="aside-nav">
<div
v-for="ele in asyncRoute"
Expand Down
10 changes: 8 additions & 2 deletions apps/app/src/style/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ $sw-theme-color: #7c6ff0;
// 是因为 packages/ui、packages/material 里的组件不引入 apps/app 的 theme.scss,
// 只能靠 :root 上的 CSS 变量跨包共享。
--sw-panel-bg: #2a2b36;
--sw-editor-bg: #1e1f27;
--sw-editor-toolbar-height: 56px;
}

// 兼容现有 SCSS 调用;这些别名不再维护独立色值。
Expand All @@ -38,12 +40,16 @@ $sw-purple-gradient: linear-gradient(180deg, var(--sw-theme-color) 0%, var(--sw-
// 试验色:偏中性的深灰,只带一点点冷色(蓝紫)倾向,避免饱和度太高看着发红/发紫。
// 不满意可以整体改回旧值:
// $sw-bg:#181a24 $sw-surface-1:#1a1c26 $sw-surface-2:#16181f --sw-panel-bg:#232630
$sw-bg: #1e1f27; // 主内容区
$sw-bg: var(--sw-editor-bg); // 主内容区
$sw-surface-1: #23242d; // 侧边栏外层
$sw-surface-2: #1a1b22; // 一级菜单列
$sw-panel-bg: var(--sw-panel-bg); // 弹窗 / 抽屉 / 编辑器面板底
$sw-control-bg: #383844; // 面板内的按钮 / 芯片等控件底(原 #383b49 / #4b4d58)
$sw-title-bg: color-mix(in srgb, var(--sw-theme-color) 12%, $sw-surface-2); // 标题栏/工具条底:中性面里掺一点主题色,比纯灰有品牌感,又不会像整块色块那么抢
$sw-title-bg: color-mix(
in srgb,
var(--sw-theme-color) 12%,
$sw-surface-2
); // 标题栏/工具条底:中性面里掺一点主题色,比纯灰有品牌感,又不会像整块色块那么抢
$sw-border: rgba(200, 205, 230, 0.08);
$sw-divider: rgba(200, 205, 230, 0.06);

Expand Down
127 changes: 127 additions & 0 deletions apps/app/src/tests/agentBI/EmptyCanvasChat.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { computed, defineComponent, ref } from "vue";
import { shallowMount } from "@vue/test-utils";

vi.mock("@/views/build/components/agentBI/components/ChatInput.vue", () => ({
default: { name: "ChatInput", template: "<div />" }
}));
vi.mock("@/hooks/useGlobalLoading", () => ({ useGlobalLoading: () => ({ loadingScene }) }));
vi.mock("@/views/build/components/buildRender/hooks/useEditStore", () => ({
useEditStore: () => ({ componentList })
}));
vi.mock("@/views/build/useLargeScreenInfo", () => ({ useLargeScreenInfo: () => ({ navInfo }) }));
vi.mock("@/views/build/components/agentBI/useAgentBISessions", () => ({
useAgentBISessions: () => ({ activeSession, visible })
}));

import { useActiveAgentBISession } from "@/views/build/components/agentBI/agentBISessionContext";
import EmptyCanvasChat from "@/views/build/components/agentBI/components/EmptyCanvasChat.vue";

const loadingScene = ref(false);
const componentList = ref<unknown[]>([]);
const navInfo = ref({ id: 2 });
const visible = ref(false);
const session = {
sessionId: "shared-session",
inputText: ref(""),
messages: ref<unknown[]>([]),
isStreaming: ref(false),
attachments: ref<Array<{ status: string }>>([]),
sendMessage: vi.fn()
};
const activeSession = computed(() => session);
let injectedSession: unknown;
const ChatInput = defineComponent({
name: "ChatInput",
props: { modelValue: String },
emits: ["update:modelValue", "send"],
setup() {
injectedSession = useActiveAgentBISession();
return {};
},
template: '<div class="chat-input" />'
});
let wrapper: ReturnType<typeof shallowMount>;

beforeEach(() => {
vi.clearAllMocks();
loadingScene.value = false;
componentList.value = [];
navInfo.value = { id: 2 };
visible.value = false;
session.inputText.value = "";
session.messages.value = [];
session.attachments.value = [];
session.isStreaming.value = false;
wrapper = shallowMount(EmptyCanvasChat, { global: { stubs: { ChatInput, WelcomeScreen: false } } });
});

afterEach(() => wrapper.unmount());

describe("空白画布 AI 入口", () => {
it("打开 AI 侧栏立即隐藏中央输入框,保留草稿且不发送消息", async () => {
wrapper.findComponent(ChatInput).vm.$emit("update:modelValue", "我的草稿");
visible.value = true;
await wrapper.vm.$nextTick();
expect(wrapper.find(".empty-canvas-chat").exists()).toBe(false);
expect(session.inputText.value).toBe("我的草稿");
expect(session.sendMessage).not.toHaveBeenCalled();
visible.value = false;
await wrapper.vm.$nextTick();
expect(wrapper.findComponent(ChatInput).props("modelValue")).toBe("我的草稿");
});
it("显示同侧栏一致的欢迎语和灵感示例,点击示例后在同一会话发送", async () => {
expect(wrapper.text()).toContain("今天,想做点什么?");
expect(wrapper.findAll(".example-btn")).toHaveLength(3);
await wrapper.find(".example-btn").trigger("click");
expect(visible.value).toBe(true);
expect(session.sendMessage).toHaveBeenCalledOnce();
expect(session.sendMessage.mock.calls[0][0]).toMatch(/^<welcome>.*新疆.*<\/welcome>$/);
});
it("复用当前会话,输入草稿时不打开侧栏", async () => {
expect(injectedSession).toBe(session);
wrapper.findComponent(ChatInput).vm.$emit("update:modelValue", "做一个销售看板");
await wrapper.vm.$nextTick();
expect(session.inputText.value).toBe("做一个销售看板");
expect(visible.value).toBe(false);
expect(session.sendMessage).not.toHaveBeenCalled();
expect(wrapper.find(".chat-input").exists()).toBe(true);
});

it("首次发送保留文本,切换到侧栏且只发送一次", async () => {
const input = wrapper.findComponent(ChatInput);
input.vm.$emit("update:modelValue", "做一个销售看板");
input.vm.$emit("send");
input.vm.$emit("send");
input.vm.$emit("update:modelValue", "");
await wrapper.vm.$nextTick();
expect(visible.value).toBe(true);
expect(session.sendMessage).toHaveBeenCalledOnce();
expect(session.sendMessage).toHaveBeenCalledWith("做一个销售看板");
expect(wrapper.find(".empty-canvas-chat").exists()).toBe(false);
});

it("只有参考图片也能开始,空输入不能触发", async () => {
wrapper.findComponent(ChatInput).vm.$emit("send");
expect(visible.value).toBe(false);
expect(session.sendMessage).not.toHaveBeenCalled();
session.attachments.value = [{ status: "pending" }];
wrapper.findComponent(ChatInput).vm.$emit("send");
await wrapper.vm.$nextTick();
expect(visible.value).toBe(true);
expect(session.sendMessage).toHaveBeenCalledOnce();
expect(session.sendMessage).toHaveBeenCalledWith("");
});

it("加载期间、已有组件和已有对话时不显示中央入口", async () => {
for (const state of ["loading", "components", "messages", "streaming", "invalid-screen"]) {
loadingScene.value = state === "loading";
componentList.value = state === "components" ? [{ id: 1 }] : [];
session.messages.value = state === "messages" ? [{ role: "user" }] : [];
session.isStreaming.value = state === "streaming";
navInfo.value.id = state === "invalid-screen" ? -1 : 2;
await wrapper.vm.$nextTick();
expect(wrapper.find(".empty-canvas-chat").exists(), state).toBe(false);
}
});
});
Loading
Loading