mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-23 23:09:25 +01:00
chore: web component loading font icon (#838)
* chore: web component loading font icon * docs: update notes
This commit is contained in:
@@ -22,7 +22,7 @@ Information about release notes of Coco App is provided here.
|
|||||||
### ✈️ Improvements
|
### ✈️ Improvements
|
||||||
|
|
||||||
- refactor: split query_coco_fusion() #836
|
- refactor: split query_coco_fusion() #836
|
||||||
|
- chore: web component loading font icon #838
|
||||||
|
|
||||||
## 0.7.1 (2025-07-27)
|
## 0.7.1 (2025-07-27)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import durationPlugin from "dayjs/plugin/duration";
|
import durationPlugin from "dayjs/plugin/duration";
|
||||||
|
import { nanoid } from "nanoid";
|
||||||
|
|
||||||
import { useThemeStore } from "@/stores/themeStore";
|
import { useThemeStore } from "@/stores/themeStore";
|
||||||
import loadingLight from "@/assets/images/ReadAloud/loading-light.png";
|
import loadingLight from "@/assets/images/ReadAloud/loading-light.png";
|
||||||
@@ -18,7 +19,6 @@ import closeDark from "@/assets/images/ReadAloud/close-dark.png";
|
|||||||
import { useConnectStore } from "@/stores/connectStore";
|
import { useConnectStore } from "@/stores/connectStore";
|
||||||
import platformAdapter from "@/utils/platformAdapter";
|
import platformAdapter from "@/utils/platformAdapter";
|
||||||
import { useStreamAudio } from "@/hooks/useStreamAudio";
|
import { useStreamAudio } from "@/hooks/useStreamAudio";
|
||||||
import { nanoid } from "nanoid";
|
|
||||||
import { useChatStore } from "@/stores/chatStore";
|
import { useChatStore } from "@/stores/chatStore";
|
||||||
|
|
||||||
dayjs.extend(durationPlugin);
|
dayjs.extend(durationPlugin);
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { useAppStore } from "@/stores/appStore";
|
|
||||||
import logoImg from "@/assets/icon.svg";
|
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
|
|
||||||
interface FontIconProps {
|
interface FontIconProps {
|
||||||
@@ -9,17 +7,11 @@ interface FontIconProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const FontIcon: FC<FontIconProps> = ({ name, className, style, ...rest }) => {
|
const FontIcon: FC<FontIconProps> = ({ name, className, style, ...rest }) => {
|
||||||
const isTauri = useAppStore((state) => state.isTauri);
|
return (
|
||||||
|
<svg className={`icon ${className || ""}`} style={style} {...rest}>
|
||||||
if (isTauri) {
|
<use xlinkHref={`#${name}`} />
|
||||||
return (
|
</svg>
|
||||||
<svg className={`icon ${className || ""}`} style={style} {...rest}>
|
);
|
||||||
<use xlinkHref={`#${name}`} />
|
|
||||||
</svg>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return <img src={logoImg} className={className} alt={"coco"} />;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default FontIcon;
|
export default FontIcon;
|
||||||
|
|||||||
@@ -125,7 +125,9 @@ function SearchChat({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
await initializeListeners_auth();
|
await initializeListeners_auth();
|
||||||
await platformAdapter.commands("get_app_search_source");
|
if (isTauri) {
|
||||||
|
await platformAdapter.commands("get_app_search_source");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { filesize } from "filesize";
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAsyncEffect } from "ahooks";
|
import { useAsyncEffect } from "ahooks";
|
||||||
|
|
||||||
import platformAdapter from "@/utils/platformAdapter";
|
import platformAdapter from "@/utils/platformAdapter";
|
||||||
import { ExtensionsContext } from "../../../index";
|
import { ExtensionsContext } from "../../../index";
|
||||||
|
|
||||||
|
|||||||
@@ -26,15 +26,9 @@ const useScript = (src: string, onError?: () => void) => {
|
|||||||
|
|
||||||
export default useScript;
|
export default useScript;
|
||||||
|
|
||||||
export const useIconfontScript = (type: "web" | "app", serverUrl?: string) => {
|
export const useIconfontScript = () => {
|
||||||
if (type === "web") {
|
// Coco Server Icons
|
||||||
useScript(`${serverUrl}/assets/fonts/icons/iconfont.js`);
|
useScript("https://at.alicdn.com/t/c/font_4878526_cykw3et0ezd.js");
|
||||||
useScript(`${serverUrl}/assets/fonts/icons-app/iconfont.js`);
|
// Coco App Icons
|
||||||
} else {
|
useScript("https://at.alicdn.com/t/c/font_4934333_zclkkzo4fgo.js");
|
||||||
// Coco Server Icons
|
|
||||||
useScript("https://at.alicdn.com/t/c/font_4878526_cykw3et0ezd.js");
|
|
||||||
|
|
||||||
// Coco App Icons
|
|
||||||
useScript("https://at.alicdn.com/t/c/font_4934333_zclkkzo4fgo.js");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ export function useSearch() {
|
|||||||
const [error, res]: any = await Get(
|
const [error, res]: any = await Get(
|
||||||
`/query/_search?query=${searchInput}`
|
`/query/_search?query=${searchInput}`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error("_search", error);
|
console.error("_search", error);
|
||||||
response = { failed: [], hits: [], total_hits: 0 };
|
response = { failed: [], hits: [], total_hits: 0 };
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import { useCallback } from "react";
|
|||||||
|
|
||||||
import { useAppStore } from "@/stores/appStore";
|
import { useAppStore } from "@/stores/appStore";
|
||||||
import platformAdapter from "@/utils/platformAdapter";
|
import platformAdapter from "@/utils/platformAdapter";
|
||||||
import { toggle_move_to_active_space_attribute } from "@/commands/system";
|
|
||||||
import { isMac } from "@/utils/platform";
|
|
||||||
|
|
||||||
interface UseTogglePinOptions {
|
interface UseTogglePinOptions {
|
||||||
onPinChange?: (isPinned: boolean) => void;
|
onPinChange?: (isPinned: boolean) => void;
|
||||||
@@ -21,8 +19,8 @@ export const useTogglePin = (options?: UseTogglePinOptions) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await platformAdapter.setAlwaysOnTop(newPinned);
|
await platformAdapter.setAlwaysOnTop(newPinned);
|
||||||
|
await platformAdapter.toggleMoveToActiveSpaceAttribute();
|
||||||
setIsPinned(newPinned);
|
setIsPinned(newPinned);
|
||||||
isMac && toggle_move_to_active_space_attribute();
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to toggle window pin state:", err);
|
console.error("Failed to toggle window pin state:", err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { useIsMobile } from "@/hooks/useIsMobile";
|
|||||||
import { useModifierKeyPress } from "@/hooks/useModifierKeyPress";
|
import { useModifierKeyPress } from "@/hooks/useModifierKeyPress";
|
||||||
import useEscape from "@/hooks/useEscape";
|
import useEscape from "@/hooks/useEscape";
|
||||||
import { useViewportHeight } from "@/hooks/useViewportHeight";
|
import { useViewportHeight } from "@/hooks/useViewportHeight";
|
||||||
import { useIconfontScript } from "@/hooks/useScript";
|
|
||||||
import type { StartPage } from "@/types/chat";
|
import type { StartPage } from "@/types/chat";
|
||||||
import ErrorNotification from "@/components/Common/ErrorNotification";
|
import ErrorNotification from "@/components/Common/ErrorNotification";
|
||||||
|
|
||||||
@@ -83,7 +82,6 @@ function WebApp({
|
|||||||
useEscape();
|
useEscape();
|
||||||
useModifierKeyPress();
|
useModifierKeyPress();
|
||||||
useViewportHeight();
|
useViewportHeight();
|
||||||
useIconfontScript('web', serverUrl);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export default function Layout() {
|
|||||||
platformAdapter.error(message);
|
platformAdapter.error(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
useIconfontScript("app");
|
useIconfontScript();
|
||||||
|
|
||||||
const setDisabledExtensions = useExtensionsStore((state) => {
|
const setDisabledExtensions = useExtensionsStore((state) => {
|
||||||
return state.setDisabledExtensions;
|
return state.setDisabledExtensions;
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ export interface WindowOperations {
|
|||||||
hideWindow: () => Promise<void>;
|
hideWindow: () => Promise<void>;
|
||||||
showWindow: () => Promise<void>;
|
showWindow: () => Promise<void>;
|
||||||
setAlwaysOnTop: (isPinned: boolean) => Promise<void>;
|
setAlwaysOnTop: (isPinned: boolean) => Promise<void>;
|
||||||
|
toggleMoveToActiveSpaceAttribute: () => Promise<void>;
|
||||||
setShadow(enable: boolean): Promise<void>;
|
setShadow(enable: boolean): Promise<void>;
|
||||||
getWebviewWindow: () => Promise<any>;
|
getWebviewWindow: () => Promise<any>;
|
||||||
getWindowByLabel: (label: string) => Promise<{
|
getWindowByLabel: (label: string) => Promise<{
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import { useAppearanceStore } from "@/stores/appearanceStore";
|
|||||||
import { copyToClipboard, OpenURLWithBrowser } from ".";
|
import { copyToClipboard, OpenURLWithBrowser } from ".";
|
||||||
import { useAppStore } from "@/stores/appStore";
|
import { useAppStore } from "@/stores/appStore";
|
||||||
import { unrequitable } from "@/utils";
|
import { unrequitable } from "@/utils";
|
||||||
|
import { toggle_move_to_active_space_attribute } from "@/commands/system";
|
||||||
|
import { isMac } from "@/utils/platform";
|
||||||
|
|
||||||
export interface TauriPlatformAdapter extends BasePlatformAdapter {
|
export interface TauriPlatformAdapter extends BasePlatformAdapter {
|
||||||
openFileDialog: (
|
openFileDialog: (
|
||||||
@@ -77,6 +79,13 @@ export const createTauriAdapter = (): TauriPlatformAdapter => {
|
|||||||
const { getCurrentWindow } = await import("@tauri-apps/api/window");
|
const { getCurrentWindow } = await import("@tauri-apps/api/window");
|
||||||
const window = getCurrentWindow();
|
const window = getCurrentWindow();
|
||||||
return window.setAlwaysOnTop(isPinned);
|
return window.setAlwaysOnTop(isPinned);
|
||||||
|
},
|
||||||
|
|
||||||
|
async toggleMoveToActiveSpaceAttribute() {
|
||||||
|
if (isMac) {
|
||||||
|
return toggle_move_to_active_space_attribute();
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
|
|
||||||
async requestScreenRecordingPermission() {
|
async requestScreenRecordingPermission() {
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ export const createWebAdapter = (): WebPlatformAdapter => {
|
|||||||
console.log("Web mode simulated set always on top", isPinned);
|
console.log("Web mode simulated set always on top", isPinned);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async toggleMoveToActiveSpaceAttribute() {
|
||||||
|
console.log("Web mode simulated toggle move to active space attribute");
|
||||||
|
},
|
||||||
|
|
||||||
async checkScreenRecordingPermission() {
|
async checkScreenRecordingPermission() {
|
||||||
console.log("Web mode simulated check screen recording permission");
|
console.log("Web mode simulated check screen recording permission");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user