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