mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-16 11:37:47 +01:00
fix: active shadow setting (#354)
* chore: active shadow setting * chore: add isTauri * chore: web build * docs: update notes
This commit is contained in:
4
.env
4
.env
@@ -1,3 +1,3 @@
|
||||
COCO_SERVER_URL=https://coco.infini.cloud #http://localhost:9000
|
||||
COCO_SERVER_URL=http://localhost:9000 https://coco.infini.cloud #http://localhost:9000
|
||||
|
||||
COCO_WEBSOCKET_URL=wss://coco.infini.cloud/ws #ws://localhost:9000/ws
|
||||
COCO_WEBSOCKET_URL=ws://localhost:9000/ws wss://coco.infini.cloud/ws #ws://localhost:9000/ws
|
||||
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@@ -11,6 +11,7 @@
|
||||
"dtolnay",
|
||||
"dyld",
|
||||
"elif",
|
||||
"errmsg",
|
||||
"fullscreen",
|
||||
"headlessui",
|
||||
"Icdbb",
|
||||
|
||||
@@ -17,10 +17,12 @@ Information about release notes of Coco Server is provided here.
|
||||
- feat: add shortcuts to most icon buttons #334
|
||||
- feat: add font icon for search list #342
|
||||
- feat: add a border to the main window in Windows 10 #343
|
||||
- feat: mobile terminal adaptation about style #348
|
||||
|
||||
### Bug fix
|
||||
|
||||
- fix: fixed the problem of not being able to search in secondary directories #338
|
||||
- fix: active shadow setting #354
|
||||
|
||||
### Improvements
|
||||
|
||||
@@ -38,7 +40,6 @@ Information about release notes of Coco Server is provided here.
|
||||
|
||||
- feat: support multi websocket connections #314
|
||||
- feat: add support for embeddable web widget #277
|
||||
- feat: mobile terminal adaptation about style #348
|
||||
|
||||
### Bug fix
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
"core:window:allow-set-focus",
|
||||
"core:window:allow-set-always-on-top",
|
||||
"core:window:deny-internal-toggle-maximize",
|
||||
"core:window:allow-set-shadow",
|
||||
"core:app:allow-set-app-theme",
|
||||
"shell:default",
|
||||
"http:default",
|
||||
|
||||
@@ -50,10 +50,9 @@ export const Get = <T>(
|
||||
// console.log("baseURL", appStore.state?.endpoint_http)
|
||||
|
||||
let baseURL = appStore.state?.endpoint_http;
|
||||
const isDev = import.meta.env.DEV;
|
||||
|
||||
axios
|
||||
.get(isDev ? url : baseURL + url, { params })
|
||||
.get(baseURL + url, { params })
|
||||
.then((result) => {
|
||||
let res: FcResponse<T>;
|
||||
if (clearFn !== undefined) {
|
||||
@@ -79,10 +78,9 @@ export const Post = <T>(
|
||||
// console.log("baseURL", appStore.state?.endpoint_http)
|
||||
|
||||
let baseURL = appStore.state?.endpoint_http;
|
||||
const isDev = import.meta.env.DEV;
|
||||
|
||||
axios
|
||||
.post(isDev ? url : baseURL + url, data, {
|
||||
.post(baseURL + url, data, {
|
||||
params,
|
||||
headers,
|
||||
} as any)
|
||||
|
||||
@@ -58,7 +58,7 @@ const ChatAI = memo(
|
||||
clearChatPage,
|
||||
isChatPage = false,
|
||||
getFileUrl,
|
||||
showChatHistory = true,
|
||||
showChatHistory,
|
||||
},
|
||||
ref
|
||||
) => {
|
||||
@@ -166,7 +166,8 @@ const ChatAI = memo(
|
||||
isDeepThinkActive,
|
||||
sourceDataIds,
|
||||
changeInput,
|
||||
websocketSessionId
|
||||
websocketSessionId,
|
||||
showChatHistory
|
||||
);
|
||||
|
||||
const { dealMsg, messageTimeoutRef } = useMessageHandler(
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { OpenURLWithBrowser } from "@/utils/index";
|
||||
import type { IChunkData } from "@/components/Assistant/types";
|
||||
import RetrieveIcon from "@/icons/Retrieve";
|
||||
import { useAppStore } from "@/stores/appStore";
|
||||
|
||||
interface FetchSourceProps {
|
||||
Detail?: any;
|
||||
@@ -34,8 +35,14 @@ interface ISourceData {
|
||||
url: string;
|
||||
}
|
||||
|
||||
export const FetchSource = ({ Detail, ChunkData, loading }: FetchSourceProps) => {
|
||||
export const FetchSource = ({
|
||||
Detail,
|
||||
ChunkData,
|
||||
loading,
|
||||
}: FetchSourceProps) => {
|
||||
const { t } = useTranslation();
|
||||
const isTauri = useAppStore((state) => state.isTauri);
|
||||
|
||||
const [isSourceExpanded, setIsSourceExpanded] = useState(false);
|
||||
|
||||
const [total, setTotal] = useState(0);
|
||||
@@ -51,7 +58,7 @@ export const FetchSource = ({ Detail, ChunkData, loading }: FetchSourceProps) =>
|
||||
useEffect(() => {
|
||||
if (!ChunkData?.message_chunk) return;
|
||||
|
||||
if (!loading) {
|
||||
if (!loading) {
|
||||
try {
|
||||
const match = ChunkData.message_chunk.match(
|
||||
// /\u003cPayload total=(\d+)\u003e/
|
||||
@@ -130,7 +137,11 @@ export const FetchSource = ({ Detail, ChunkData, loading }: FetchSourceProps) =>
|
||||
{item.title || item.category}
|
||||
</div>
|
||||
</div>
|
||||
<div className="hidden md:flex w-[25%] items-center justify-end gap-2">
|
||||
<div
|
||||
className={`${
|
||||
isTauri ? "flex" : "hidden md:flex"
|
||||
} w-[25%] items-center justify-end gap-2`}
|
||||
>
|
||||
<span className="text-xs text-[#999999] dark:text-[#999999] truncate">
|
||||
{item.source?.name}
|
||||
</span>
|
||||
|
||||
@@ -99,7 +99,9 @@ export default function Footer({
|
||||
<Copyright />
|
||||
)}
|
||||
|
||||
<div className="hidden md:flex items-center gap-3">
|
||||
<div
|
||||
className={`${isTauri ? "flex" : "hidden md:flex"} items-center gap-3`}
|
||||
>
|
||||
<div className="gap-1 flex items-center text-[#666] dark:text-[#666] text-xs">
|
||||
<span className="mr-1.5">{t("search.footer.select")}:</span>
|
||||
<kbd className="coco-modal-footer-commands-key pr-1">
|
||||
|
||||
@@ -4,10 +4,12 @@ import { useTranslation } from "react-i18next";
|
||||
import { isMac } from "@/utils/platform";
|
||||
import { useShortcutsStore } from "@/stores/shortcutsStore";
|
||||
import noDataImg from "@/assets/coconut-tree.png";
|
||||
import { useAppStore } from "@/stores/appStore";
|
||||
|
||||
export const NoResults = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const isTauri = useAppStore((state) => state.isTauri);
|
||||
const modeSwitch = useShortcutsStore((state) => state.modeSwitch);
|
||||
|
||||
return (
|
||||
@@ -19,7 +21,7 @@ export const NoResults = () => {
|
||||
<div className="mt-4 text-sm text-[#999] dark:text-[#666]">
|
||||
{t("search.main.noResults")}
|
||||
</div>
|
||||
<div className="hidden md:flex mt-10 text-sm text-[#333] dark:text-[#D8D8D8]">
|
||||
<div className={`${isTauri ? 'flex' : 'hidden md:flex'} mt-10 text-sm text-[#333] dark:text-[#D8D8D8]`}>
|
||||
{t("search.main.askCoco")}
|
||||
{isMac ? (
|
||||
<span className="ml-3 w-5 h-5 rounded-[6px] border border-[#D8D8D8] flex justify-center items-center">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import TypeIcon from "@/components/Common/Icons/TypeIcon";
|
||||
import RichIcon from "@/components/Common/Icons/RichIcon";
|
||||
import { useAppStore } from "@/stores/appStore";
|
||||
|
||||
interface ListRightProps {
|
||||
item: any;
|
||||
@@ -16,8 +17,14 @@ export default function ListRight({
|
||||
currentIndex,
|
||||
goToTwoPage,
|
||||
}: ListRightProps) {
|
||||
const isTauri = useAppStore((state) => state.isTauri);
|
||||
|
||||
return (
|
||||
<div className="hidden md:flex flex-1 text-right min-w-[160px] h-full pl-5 text-[12px] gap-2 items-center justify-end relative">
|
||||
<div
|
||||
className={`${
|
||||
isTauri ? "flex" : "hidden md:flex"
|
||||
} flex-1 text-right min-w-[160px] h-full pl-5 text-[12px] gap-2 items-center justify-end relative`}
|
||||
>
|
||||
{item?.rich_categories ? null : (
|
||||
<div
|
||||
className="w-4 h-4 cursor-pointer"
|
||||
|
||||
@@ -2,6 +2,8 @@ import React from "react";
|
||||
import { AlignLeft, Columns2 } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useAppStore } from "@/stores/appStore";
|
||||
|
||||
interface SearchHeaderProps {
|
||||
total: number;
|
||||
viewMode: "detail" | "list";
|
||||
@@ -15,6 +17,8 @@ export const SearchHeader: React.FC<SearchHeaderProps> = ({
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const isTauri = useAppStore((state) => state.isTauri);
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-between py-1">
|
||||
<div className="text-xs text-gray-600 dark:text-gray-400">
|
||||
@@ -24,7 +28,7 @@ export const SearchHeader: React.FC<SearchHeaderProps> = ({
|
||||
</span>
|
||||
{t('search.header.results')}
|
||||
</div>
|
||||
<div className="hidden md:flex gap-2">
|
||||
<div className={`${isTauri ? 'flex' : 'hidden md:flex'} gap-2`}>
|
||||
<div className="flex bg-gray-100 dark:bg-gray-800 rounded-lg p-0.5">
|
||||
<button
|
||||
onClick={() => setViewMode("list")}
|
||||
|
||||
@@ -58,7 +58,7 @@ function SearchChat({
|
||||
queryDocuments,
|
||||
searchPlaceholder,
|
||||
chatPlaceholder,
|
||||
showChatHistory,
|
||||
showChatHistory = true,
|
||||
setIsPinned,
|
||||
}: SearchChatProps) {
|
||||
const customInitialState = {
|
||||
|
||||
@@ -19,7 +19,8 @@ export function useChatActions(
|
||||
isDeepThinkActive?: boolean,
|
||||
sourceDataIds?: string[],
|
||||
changeInput?: (val: string) => void,
|
||||
websocketSessionId?: string
|
||||
websocketSessionId?: string,
|
||||
showChatHistory?: boolean,
|
||||
) {
|
||||
const isTauri = useAppStore((state) => state.isTauri);
|
||||
const [keyword, setKeyword] = useState("");
|
||||
@@ -373,8 +374,9 @@ export function useChatActions(
|
||||
}, [currentServiceId, keyword]);
|
||||
|
||||
useEffect(() => {
|
||||
getChatHistory();
|
||||
}, [keyword]);
|
||||
console.log("showChatHistory", showChatHistory);
|
||||
showChatHistory && getChatHistory();
|
||||
}, [showChatHistory]);
|
||||
|
||||
const createChatWindow = useCallback(async (createWin: any) => {
|
||||
if (isTauri) {
|
||||
|
||||
@@ -92,7 +92,7 @@ function App() {
|
||||
theme="dark"
|
||||
searchPlaceholder=""
|
||||
chatPlaceholder=""
|
||||
showChatHistory={true}
|
||||
showChatHistory={false}
|
||||
setIsPinned={(isPinned) => console.log('isPinned:', isPinned)}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -28,7 +28,7 @@ function WebApp({
|
||||
width = 680,
|
||||
height = 590,
|
||||
headers = {
|
||||
"X-API-TOKEN": "cvrmh6uhpceh4c6u2e9gnnmb1e09x2u1ttvdpt87zsv8gtdbto938t942r5mxdfmexzwynwtbyd9ov52qee9",
|
||||
"X-API-TOKEN": "cvqt6r02sdb2v3bkgip0x3ixv01f3r2lhnxoz1efbn160wm9og58wtv8t6wrv1ebvnvypuc23dx9pb33aemh",
|
||||
"APP-INTEGRATION-ID": "cvkm9hmhpcemufsg3vug",
|
||||
},
|
||||
// token = "cva1j5ehpcenic3ir7k0h8fb8qtv35iwtywze248oscrej8yoivhb5b1hyovp24xejjk27jy9ddt69ewfi3n", // https://coco.infini.cloud
|
||||
@@ -38,11 +38,11 @@ function WebApp({
|
||||
hideCoco = () => {},
|
||||
hasModules = ["search", "chat"],
|
||||
defaultModule = "search",
|
||||
hasFeature = ['think_active', 'search_active'],
|
||||
hasFeature = ['search', 'think_active', 'search_active'],
|
||||
theme="light",
|
||||
searchPlaceholder = "",
|
||||
chatPlaceholder = "",
|
||||
showChatHistory = true,
|
||||
showChatHistory = false,
|
||||
setIsPinned,
|
||||
}: WebAppProps) {
|
||||
const setIsTauri = useAppStore((state) => state.setIsTauri);
|
||||
|
||||
@@ -28,6 +28,8 @@ export default function Layout() {
|
||||
}
|
||||
|
||||
useMount(async () => {
|
||||
await platformAdapter.setShadow(true);
|
||||
|
||||
const unlistenTheme = await platformAdapter.listenThemeChanged(
|
||||
(theme: AppTheme) => {
|
||||
setTheme(theme);
|
||||
|
||||
@@ -93,11 +93,13 @@ export interface PlatformAdapter {
|
||||
openExternal: (url: string) => Promise<void>;
|
||||
commands: <T>(commandName: string, ...args: any[]) => Promise<T>;
|
||||
isWindows10: () => Promise<boolean>;
|
||||
setShadow(enable: boolean): Promise<void>;
|
||||
}
|
||||
|
||||
// const appStore = JSON.parse(localStorage.getItem("app-store") || "{}");
|
||||
// const isTauri = appStore.state?.isTauri ?? !!(window as any).__TAURI__;
|
||||
|
||||
let platformAdapter: PlatformAdapter = createTauriAdapter();
|
||||
// let platformAdapter: PlatformAdapter = createWebAdapter();
|
||||
|
||||
export default platformAdapter;
|
||||
@@ -177,6 +177,12 @@ export const createTauriAdapter = (): PlatformAdapter => {
|
||||
return open(url);
|
||||
},
|
||||
|
||||
isWindows10: isWindows10
|
||||
isWindows10: isWindows10,
|
||||
|
||||
async setShadow(enable: boolean) {
|
||||
const { getCurrentWindow } = await import("@tauri-apps/api/window");
|
||||
const window = await getCurrentWindow();
|
||||
return window.setShadow(enable);
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -164,5 +164,10 @@ export const createWebAdapter = (): PlatformAdapter => {
|
||||
},
|
||||
|
||||
isWindows10: async () => false,
|
||||
|
||||
async setShadow(enable: boolean): Promise<void> {
|
||||
console.warn('setShadow is not supported in web environment', enable);
|
||||
return Promise.resolve();
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -67,7 +67,7 @@ export default defineConfig({
|
||||
|
||||
const packageJson = {
|
||||
name: "@infinilabs/search-chat",
|
||||
version: "1.0.10",
|
||||
version: "1.1.0",
|
||||
main: "index.js",
|
||||
module: "index.js",
|
||||
type: "module",
|
||||
|
||||
Reference in New Issue
Block a user