diff --git a/entry/entry.js b/entry/entry.js index c9a9776..4cba5ed 100644 --- a/entry/entry.js +++ b/entry/entry.js @@ -1,4 +1,3 @@ - // Copyright (C) 2025 AIDC-AI // Licensed under the MIT License. @@ -7,4 +6,8 @@ import { api } from "../../scripts/api.js"; setTimeout(() => { import(api.api_base + "/copilot_web/input.js"); + const fontsLink = document.createElement("link"); + fontsLink.rel = "stylesheet"; + fontsLink.href = api.api_base + "/copilot_web/fonts.css"; + document.head.appendChild(fontsLink); }, 500); diff --git a/ui/src/fonts.css b/ui/src/fonts.css new file mode 100644 index 0000000..3576e31 --- /dev/null +++ b/ui/src/fonts.css @@ -0,0 +1,32 @@ +/* Font declarations */ +@font-face { + font-family: "cc-font"; + src: url("./fonts/cc-icon.eot?jbqswq"); + src: + url("./fonts/cc-icon.eot?jbqswq#iefix") format("embedded-opentype"), + url("./fonts/cc-icon.ttf?jbqswq") format("truetype"), + url("./fonts/cc-icon.woff?jbqswq") format("woff"), + url("./fonts/cc-icon.svg?jbqswq#icomoon") format("svg"); + font-weight: normal; + font-style: normal; + font-display: block; +} + +/* Icon classes */ +[class^="cc-icon-"], +[class*=" cc-icon-"] { + font-family: "cc-font" !important; + speak: never; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.cc-icon-logo:before { + content: "\e900"; + color: #5a6e87; +} \ No newline at end of file diff --git a/ui/src/fonts/cc-icon.eot b/ui/src/fonts/cc-icon.eot new file mode 100644 index 0000000..6e06f12 Binary files /dev/null and b/ui/src/fonts/cc-icon.eot differ diff --git a/ui/src/fonts/cc-icon.svg b/ui/src/fonts/cc-icon.svg new file mode 100644 index 0000000..a2cea69 --- /dev/null +++ b/ui/src/fonts/cc-icon.svg @@ -0,0 +1,14 @@ + + + + Generated by IcoMoon + + + + \ No newline at end of file diff --git a/ui/src/fonts/cc-icon.ttf b/ui/src/fonts/cc-icon.ttf new file mode 100644 index 0000000..93dbb19 Binary files /dev/null and b/ui/src/fonts/cc-icon.ttf differ diff --git a/ui/src/fonts/cc-icon.woff b/ui/src/fonts/cc-icon.woff new file mode 100644 index 0000000..7ca98b2 Binary files /dev/null and b/ui/src/fonts/cc-icon.woff differ diff --git a/ui/src/main.tsx b/ui/src/main.tsx index dde8ef9..3e7b471 100644 --- a/ui/src/main.tsx +++ b/ui/src/main.tsx @@ -13,6 +13,7 @@ import React, { Suspense } from "react"; import ReactDOM from "react-dom/client"; import { waitForApp } from "./utils/comfyapp.ts"; import "./scoped-tailwind.css"; +import "./fonts.css"; const App = React.lazy(() => import("./App.tsx").then(({ default: App }) => ({ @@ -37,7 +38,7 @@ waitForDocumentBody() .then(() => { app.extensionManager.registerSidebarTab({ id: "comfyui-copilot", - icon: "mdi mdi-robot-excited-outline", + icon: "cc-icon-logo", title: "ComfyUI Copilot", tooltip: "ComfyUI Copilot", type: "custom", diff --git a/ui/vite.config.ts b/ui/vite.config.ts index 6e0679d..fd0ba9f 100644 --- a/ui/vite.config.ts +++ b/ui/vite.config.ts @@ -81,6 +81,7 @@ export default defineConfig(({ mode }) => ({ external: ["/scripts/app.js", "/scripts/api.js"], input: { input: "/src/main.tsx", + fonts: "/src/fonts.css" }, output: { // Provide global variables to use in the UMD build for externalized deps @@ -92,7 +93,12 @@ export default defineConfig(({ mode }) => ({ // assetFileNames: "[name]-[hash][extname]", entryFileNames: "copilot_web/[name].js", chunkFileNames: `copilot_web/[name]-[hash].js`, - assetFileNames: `copilot_web/assets/[name]-[hash].[ext]`, + assetFileNames: (assetInfo) => { + if (assetInfo.name === 'fonts.css') { + return 'copilot_web/[name].css'; + } + return `copilot_web/assets/[name]-[hash].[ext]`; + }, manualChunks: { // 只包含实际使用的 React 相关依赖 'vendor-react': ['react', 'react-dom'],