From 242a15c5892c68db7954f377f782e8ec30f19ae2 Mon Sep 17 00:00:00 2001
From: wuxichen <17301714657@163.com>
Date: Fri, 5 Sep 2025 16:44:12 +0800
Subject: [PATCH] feat: init
---
package.json | 1 +
.../src/error-page/errorBoundary/index.tsx | 2 +-
.../shared/src/error-page/index.module.less | 2 +-
packages/shared/src/voiceIcon/index.tsx | 7 +--
pnpm-lock.yaml | 38 +++++++++++++
projects/translate-h5/src/hooks/session.ts | 47 ++++++++--------
.../src/layout/main/mainLayout.tsx | 56 ++++++++-----------
projects/translate-h5/src/route/auth.tsx | 1 -
projects/translate-h5/src/route/routes.tsx | 9 +++
projects/translate-h5/src/view/app/App.tsx | 1 -
.../home/{component => archives}/index.less | 0
.../src/view/home/archives/index.tsx | 13 +++++
.../src/view/home/component/filter/index.less | 0
.../src/view/home/component/filter/index.tsx | 0
.../translate-h5/src/view/home/index.less | 20 ++++++-
projects/translate-h5/src/view/home/index.tsx | 41 ++++++++------
.../src/view/home/mood/index.module.less | 3 +
.../translate-h5/src/view/home/mood/index.tsx | 11 ++++
.../view/home/translate/component/index.less | 0
.../component/message/index.less | 0
.../component/message/index.tsx | 40 ++-----------
.../component/search/index.less | 0
.../component/search/index.tsx | 14 ++---
.../component/voice/index.less | 0
.../{ => translate}/component/voice/index.tsx | 16 +-----
.../{translate.tsx => translate/index.tsx} | 28 ++++------
projects/translate-h5/vite.config.ts | 9 +--
27 files changed, 191 insertions(+), 168 deletions(-)
rename projects/translate-h5/src/view/home/{component => archives}/index.less (100%)
create mode 100644 projects/translate-h5/src/view/home/archives/index.tsx
create mode 100644 projects/translate-h5/src/view/home/component/filter/index.less
create mode 100644 projects/translate-h5/src/view/home/component/filter/index.tsx
create mode 100644 projects/translate-h5/src/view/home/mood/index.module.less
create mode 100644 projects/translate-h5/src/view/home/mood/index.tsx
create mode 100644 projects/translate-h5/src/view/home/translate/component/index.less
rename projects/translate-h5/src/view/home/{ => translate}/component/message/index.less (100%)
rename projects/translate-h5/src/view/home/{ => translate}/component/message/index.tsx (84%)
rename projects/translate-h5/src/view/home/{ => translate}/component/search/index.less (100%)
rename projects/translate-h5/src/view/home/{ => translate}/component/search/index.tsx (92%)
rename projects/translate-h5/src/view/home/{ => translate}/component/voice/index.less (100%)
rename projects/translate-h5/src/view/home/{ => translate}/component/voice/index.tsx (95%)
rename projects/translate-h5/src/view/home/{translate.tsx => translate/index.tsx} (88%)
diff --git a/package.json b/package.json
index 54b81e1..86ee127 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,7 @@
"antd-mobile-icons": "^0.3.0",
"axios": "^1.6.2",
"axios-hooks": "^5.0.2",
+ "framer-motion": "^12.23.12",
"js-audio-recorder": "^1.0.7",
"jsqr": "^1.4.0",
"less": "^4.2.0",
diff --git a/packages/shared/src/error-page/errorBoundary/index.tsx b/packages/shared/src/error-page/errorBoundary/index.tsx
index cb74b6f..2d43be0 100644
--- a/packages/shared/src/error-page/errorBoundary/index.tsx
+++ b/packages/shared/src/error-page/errorBoundary/index.tsx
@@ -1,5 +1,5 @@
// components/ErrorBoundary/index.tsx
-import React, { Component, ReactNode } from "react";
+import { Component, ReactNode } from "react";
import { Result, Button } from "antd-mobile";
interface Props {
diff --git a/packages/shared/src/error-page/index.module.less b/packages/shared/src/error-page/index.module.less
index f0809ae..814486d 100644
--- a/packages/shared/src/error-page/index.module.less
+++ b/packages/shared/src/error-page/index.module.less
@@ -11,7 +11,7 @@
.actions {
display: flex;
- gap: 16px;
+ gap: 12px;
margin-top: 24px;
.button {
diff --git a/packages/shared/src/voiceIcon/index.tsx b/packages/shared/src/voiceIcon/index.tsx
index 09fb7a4..43ba1f2 100644
--- a/packages/shared/src/voiceIcon/index.tsx
+++ b/packages/shared/src/voiceIcon/index.tsx
@@ -1,4 +1,4 @@
-import React, { useCallback, useState } from "react";
+import React, { useCallback } from "react";
import "./index.less";
const VoiceIcon = (props: { isPlaying: boolean; onChange?: () => void }) => {
@@ -7,10 +7,7 @@ const VoiceIcon = (props: { isPlaying: boolean; onChange?: () => void }) => {
props.onChange?.();
}, [isPlaying]);
return (
-
+
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d131c54..2e33840 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -41,6 +41,9 @@ importers:
axios-hooks:
specifier: ^5.0.2
version: 5.1.1(axios@1.11.0)(react@18.3.1)
+ framer-motion:
+ specifier: ^12.23.12
+ version: 12.23.12(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
js-audio-recorder:
specifier: ^1.0.7
version: 1.0.7
@@ -1481,6 +1484,20 @@ packages:
resolution: {integrity: sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==}
engines: {node: '>= 6'}
+ framer-motion@12.23.12:
+ resolution: {integrity: sha512-6e78rdVtnBvlEVgu6eFEAgG9v3wLnYEboM8I5O5EXvfKC8gxGQB8wXJdhkMy10iVcn05jl6CNw7/HTsTCfwcWg==}
+ peerDependencies:
+ '@emotion/is-prop-valid': '*'
+ react: ^18.0.0 || ^19.0.0
+ react-dom: ^18.0.0 || ^19.0.0
+ peerDependenciesMeta:
+ '@emotion/is-prop-valid':
+ optional: true
+ react:
+ optional: true
+ react-dom:
+ optional: true
+
fs-extra@11.3.1:
resolution: {integrity: sha512-eXvGGwZ5CL17ZSwHWd3bbgk7UUpF6IFHtP57NYYakPvHOs8GDgDe5KJI36jIJzDkJ6eJjuzRA8eBQb6SkKue0g==}
engines: {node: '>=14.14'}
@@ -1828,6 +1845,12 @@ packages:
resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==}
engines: {node: '>=16 || 14 >=14.17'}
+ motion-dom@12.23.12:
+ resolution: {integrity: sha512-RcR4fvMCTESQBD/uKQe49D5RUeDOokkGRmz4ceaJKDBgHYtZtntC/s2vLvY38gqGaytinij/yi3hMcWVcEF5Kw==}
+
+ motion-utils@12.23.6:
+ resolution: {integrity: sha512-eAWoPgr4eFEOFfg2WjIsMoqJTW6Z8MTUCgn/GZ3VRpClWBdnbjryiA3ZSNLyxCTmCQx4RmYX6jX1iWHbenUPNQ==}
+
ms@2.0.0:
resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==}
@@ -3984,6 +4007,15 @@ snapshots:
hasown: 2.0.2
mime-types: 2.1.35
+ framer-motion@12.23.12(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
+ dependencies:
+ motion-dom: 12.23.12
+ motion-utils: 12.23.6
+ tslib: 2.8.1
+ optionalDependencies:
+ react: 18.3.1
+ react-dom: 18.3.1(react@18.3.1)
+
fs-extra@11.3.1:
dependencies:
graceful-fs: 4.2.11
@@ -4302,6 +4334,12 @@ snapshots:
dependencies:
brace-expansion: 2.0.2
+ motion-dom@12.23.12:
+ dependencies:
+ motion-utils: 12.23.6
+
+ motion-utils@12.23.6: {}
+
ms@2.0.0: {}
ms@2.1.3: {}
diff --git a/projects/translate-h5/src/hooks/session.ts b/projects/translate-h5/src/hooks/session.ts
index 5595df5..78c4127 100644
--- a/projects/translate-h5/src/hooks/session.ts
+++ b/projects/translate-h5/src/hooks/session.ts
@@ -1,28 +1,27 @@
-import {useState, useEffect} from 'react';
-import isEqual from 'lodash.isequal';
+// import {useState, useEffect} from 'react';
-function useSessionStorage
(key: string, initialValue: T): [T, (value: T) => void] {
- // 初始化状态
- const [storedValue, setStoredValue] = useState(() => {
- const item = sessionStorage.getItem(key);
- if (item !== null) {
- // 如果 sessionStorage 中有数据,则使用现有数据
- return JSON.parse(item);
- } else {
- // 当 sessionStorage 中没有相应的键时,使用 initialValue 初始化,并写入 sessionStorage
- sessionStorage.setItem(key, JSON.stringify(initialValue));
- return initialValue;
- }
- });
+// function useSessionStorage(key: string, initialValue: T): [T, (value: T) => void] {
+// // 初始化状态
+// const [storedValue, setStoredValue] = useState(() => {
+// const item = sessionStorage.getItem(key);
+// if (item !== null) {
+// // 如果 sessionStorage 中有数据,则使用现有数据
+// return JSON.parse(item);
+// } else {
+// // 当 sessionStorage 中没有相应的键时,使用 initialValue 初始化,并写入 sessionStorage
+// sessionStorage.setItem(key, JSON.stringify(initialValue));
+// return initialValue;
+// }
+// });
- // 监听并保存变化到 sessionStorage
- useEffect(() => {
- if (!isEqual(JSON.parse(sessionStorage.getItem(key) || 'null'), storedValue)) {
- sessionStorage.setItem(key, JSON.stringify(storedValue));
- }
- }, [key, storedValue]);
+// // 监听并保存变化到 sessionStorage
+// useEffect(() => {
+// if (!isEqual(JSON.parse(sessionStorage.getItem(key) || 'null'), storedValue)) {
+// sessionStorage.setItem(key, JSON.stringify(storedValue));
+// }
+// }, [key, storedValue]);
- return [storedValue, setStoredValue];
-}
+// return [storedValue, setStoredValue];
+// }
-export default useSessionStorage;
+// export default useSessionStorage;
diff --git a/projects/translate-h5/src/layout/main/mainLayout.tsx b/projects/translate-h5/src/layout/main/mainLayout.tsx
index 8c042c1..8402bc3 100644
--- a/projects/translate-h5/src/layout/main/mainLayout.tsx
+++ b/projects/translate-h5/src/layout/main/mainLayout.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import { NavBar, SafeArea, TabBar, Toast } from "antd-mobile";
+import { NavBar, SafeArea, Toast } from "antd-mobile";
import { useNavigate, useLocation } from "react-router-dom";
import { User, CattleZodiac } from "@icon-park/react";
import "./index.less";
@@ -13,39 +13,31 @@ interface MainLayoutProps {
const MainLayout: React.FC = ({ isShowNavBar, children, onLink, title }) => {
const navigate = useNavigate();
- const location = useLocation();
- const { pathname } = location;
- const [activeKey, setActiveKey] = React.useState(pathname);
+ // const location = useLocation();
- const setRouteActive = (value: string) => {
- if (value !== "/") {
- Toast.show("待开发");
- }
- };
+ // const tabs = [
+ // {
+ // key: "/",
+ // title: "宠物翻译",
+ // icon: ,
+ // },
+ // {
+ // key: "/set",
+ // title: "待办",
+ // icon: ,
+ // },
+ // {
+ // key: "/message",
+ // title: "消息",
+ // icon: ,
+ // },
+ // {
+ // key: "/me",
+ // title: "我的",
- const tabs = [
- {
- key: "/",
- title: "宠物翻译",
- icon: ,
- },
- {
- key: "/set",
- title: "待办",
- icon: ,
- },
- {
- key: "/message",
- title: "消息",
- icon: ,
- },
- {
- key: "/me",
- title: "我的",
-
- icon: ,
- },
- ];
+ // icon: ,
+ // },
+ // ];
const goBack = () => {
if (onLink) {
diff --git a/projects/translate-h5/src/route/auth.tsx b/projects/translate-h5/src/route/auth.tsx
index 78fc1c9..e555e41 100644
--- a/projects/translate-h5/src/route/auth.tsx
+++ b/projects/translate-h5/src/route/auth.tsx
@@ -1,6 +1,5 @@
import React, { useEffect } from "react";
import { useNavigate } from "react-router-dom";
-import { AppRoute } from "./routes";
interface AuthRouteProps {
children: React.ReactNode;
diff --git a/projects/translate-h5/src/route/routes.tsx b/projects/translate-h5/src/route/routes.tsx
index 164e56b..5249734 100644
--- a/projects/translate-h5/src/route/routes.tsx
+++ b/projects/translate-h5/src/route/routes.tsx
@@ -13,6 +13,7 @@ export interface AppRoute {
const Home = lazy(() => import("@/view/home"));
const Page404 = lazy(() => import("@/view/error/page404"));
const TranslateDetail = lazy(() => import("@/view/home/detail"));
+const TranslateMood = lazy(() => import("@/view/home/mood"));
export const routes: AppRoute[] = [
{
path: "/",
@@ -31,5 +32,13 @@ export const routes: AppRoute[] = [
},
},
{ path: "/translate/detail", element: , auth: false },
+ {
+ path: "/translate/mood",
+ element: ,
+ auth: false,
+ meta: {
+ title: "情绪监控",
+ },
+ },
{ path: "*", element: , auth: false },
];
diff --git a/projects/translate-h5/src/view/app/App.tsx b/projects/translate-h5/src/view/app/App.tsx
index c21aabd..bfce1a9 100644
--- a/projects/translate-h5/src/view/app/App.tsx
+++ b/projects/translate-h5/src/view/app/App.tsx
@@ -1,4 +1,3 @@
-import React from "react";
import { RenderRoutes } from "@/route/render-routes.tsx";
import { axiosInstance } from "@/http/axios-instance.ts";
import { configure } from "axios-hooks";
diff --git a/projects/translate-h5/src/view/home/component/index.less b/projects/translate-h5/src/view/home/archives/index.less
similarity index 100%
rename from projects/translate-h5/src/view/home/component/index.less
rename to projects/translate-h5/src/view/home/archives/index.less
diff --git a/projects/translate-h5/src/view/home/archives/index.tsx b/projects/translate-h5/src/view/home/archives/index.tsx
new file mode 100644
index 0000000..efe1ada
--- /dev/null
+++ b/projects/translate-h5/src/view/home/archives/index.tsx
@@ -0,0 +1,13 @@
+// 档案
+import MainLayout from "@/layout/main/mainLayout";
+import "./index.less";
+
+function Index() {
+ return (
+
+
+
+ );
+}
+
+export default Index;
diff --git a/projects/translate-h5/src/view/home/component/filter/index.less b/projects/translate-h5/src/view/home/component/filter/index.less
new file mode 100644
index 0000000..e69de29
diff --git a/projects/translate-h5/src/view/home/component/filter/index.tsx b/projects/translate-h5/src/view/home/component/filter/index.tsx
new file mode 100644
index 0000000..e69de29
diff --git a/projects/translate-h5/src/view/home/index.less b/projects/translate-h5/src/view/home/index.less
index 35ac51a..5a8220e 100644
--- a/projects/translate-h5/src/view/home/index.less
+++ b/projects/translate-h5/src/view/home/index.less
@@ -1,6 +1,23 @@
.home {
height: 100%;
+ width: 100%;
overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ .home-header {
+ display: flex;
+ padding: 12px;
+ position: sticky;
+ top: 0px;
+ background: #fff;
+ justify-content: space-between;
+ align-items: center;
+ z-index: 99;
+ h3 {
+ font-size: 20px;
+ font-size: 20px;
+ }
+ }
// .adm-tabs {
// display: flex;
// flex-direction: column;
@@ -21,7 +38,7 @@
// .adm-tabs-tab {
// font-size: 20px;
- // color: rgba(0, 0, 0, 0.25);
+ // font-size: 20px;
// font-weight: 600;
// &.adm-tabs-tab-active {
// color: #000;
@@ -36,6 +53,7 @@
flex-direction: column;
height: 100%;
.header {
+ padding: 0px 16px;
}
}
}
diff --git a/projects/translate-h5/src/view/home/index.tsx b/projects/translate-h5/src/view/home/index.tsx
index cf93933..197810f 100644
--- a/projects/translate-h5/src/view/home/index.tsx
+++ b/projects/translate-h5/src/view/home/index.tsx
@@ -1,32 +1,37 @@
import MainLayout from "@/layout/main/mainLayout";
-import { Button, Tabs } from "antd-mobile";
-import Translate from "./translate";
+import { useState } from "react";
+import { Divider, Space } from "antd-mobile";
+import Translate from "./translate/index";
+import { Electrocardiogram, Filter, GithubOne } from "@icon-park/react";
+import { useNavigate } from "react-router-dom";
import "./index.less";
function Index() {
- const handleRecordComplete = (audioData: AudioData): void => {
- console.log("录音完成:", audioData);
- };
+ const [visible, setVisible] = useState(false);
+ const navigate = useNavigate();
- const handleError = (error: Error): void => {
- console.error("录音错误:", error);
+ const onLink = () => {
+ navigate("/translate/mood");
};
-
return (
-
+
- {/*
-
-
-
-
- 2
-
- */}
+
);
diff --git a/projects/translate-h5/src/view/home/mood/index.module.less b/projects/translate-h5/src/view/home/mood/index.module.less
new file mode 100644
index 0000000..4e4f5c5
--- /dev/null
+++ b/projects/translate-h5/src/view/home/mood/index.module.less
@@ -0,0 +1,3 @@
+.mood {
+ padding: 12px;
+}
diff --git a/projects/translate-h5/src/view/home/mood/index.tsx b/projects/translate-h5/src/view/home/mood/index.tsx
new file mode 100644
index 0000000..462c3cc
--- /dev/null
+++ b/projects/translate-h5/src/view/home/mood/index.tsx
@@ -0,0 +1,11 @@
+import MainLayout from "@/layout/main/mainLayout";
+import styles from "./index.module.less";
+const Moods = () => {
+ return (
+
+ 心情
+
+ );
+};
+
+export default Moods;
diff --git a/projects/translate-h5/src/view/home/translate/component/index.less b/projects/translate-h5/src/view/home/translate/component/index.less
new file mode 100644
index 0000000..e69de29
diff --git a/projects/translate-h5/src/view/home/component/message/index.less b/projects/translate-h5/src/view/home/translate/component/message/index.less
similarity index 100%
rename from projects/translate-h5/src/view/home/component/message/index.less
rename to projects/translate-h5/src/view/home/translate/component/message/index.less
diff --git a/projects/translate-h5/src/view/home/component/message/index.tsx b/projects/translate-h5/src/view/home/translate/component/message/index.tsx
similarity index 84%
rename from projects/translate-h5/src/view/home/component/message/index.tsx
rename to projects/translate-h5/src/view/home/translate/component/message/index.tsx
index 9128203..faedb4f 100644
--- a/projects/translate-h5/src/view/home/component/message/index.tsx
+++ b/projects/translate-h5/src/view/home/translate/component/message/index.tsx
@@ -4,7 +4,7 @@ import { VoiceIcon } from "@workspace/shared";
import dogSvg from "@/assets/translate/dog.svg";
import catSvg from "@/assets/translate/cat.svg";
import pigSvg from "@/assets/translate/pig.svg";
-import { Message } from "../../types";
+import { Message } from "../../../types";
import "./index.less";
interface DefinedProps {
@@ -89,44 +89,18 @@ function Index(props: DefinedProps) {
};
const renderAvatar = (type?: "pig" | "cat" | "dog") => {
if (type === "pig") {
-
;
+
;
}
if (type === "cat") {
- return (
-
- );
+ return
;
}
- return (
-
- );
+ return
;
};
return (
{data.map((item, index) => (
-
playAudio(item.id, item.audioUrl)}
- >
+
playAudio(item.id, item.audioUrl)}>
{renderAvatar(item.type)}
@@ -163,9 +137,7 @@ function Index(props: DefinedProps) {
-
- {isRecording ? "录制中..." : "轻点麦克风录制"}
-
+
{isRecording ? "录制中..." : "轻点麦克风录制"}
diff --git a/projects/translate-h5/src/view/home/component/search/index.less b/projects/translate-h5/src/view/home/translate/component/search/index.less
similarity index 100%
rename from projects/translate-h5/src/view/home/component/search/index.less
rename to projects/translate-h5/src/view/home/translate/component/search/index.less
diff --git a/projects/translate-h5/src/view/home/component/search/index.tsx b/projects/translate-h5/src/view/home/translate/component/search/index.tsx
similarity index 92%
rename from projects/translate-h5/src/view/home/component/search/index.tsx
rename to projects/translate-h5/src/view/home/translate/component/search/index.tsx
index 422c48f..2d98901 100644
--- a/projects/translate-h5/src/view/home/component/search/index.tsx
+++ b/projects/translate-h5/src/view/home/translate/component/search/index.tsx
@@ -1,21 +1,14 @@
-import { DownOne } from "@icon-park/react";
-import {
- ActionSheet,
- Dropdown,
- type DropdownRef,
- Popup,
- Radio,
- SearchBar,
- Space,
-} from "antd-mobile";
+import { Dropdown, type DropdownRef, Radio, SearchBar, Space } from "antd-mobile";
import { RadioValue } from "antd-mobile/es/components/radio";
import { useRef, useState } from "react";
interface PropsConfig {
handleAllAni: () => void;
+ value?: string;
}
const allAni = ["全部宠物", "丑丑", "胖胖", "可可"];
function SearchCom(props: PropsConfig) {
+ const { value } = props;
const [aniName, setAniName] = useState
("全部宠物");
const animenuRef = useRef(null);
const handleAniSelect = (val: RadioValue) => {
@@ -32,6 +25,7 @@ function SearchCom(props: PropsConfig) {
"--height": "32px",
"--padding-left": "12px",
}}
+ defaultValue={value}
/>
diff --git a/projects/translate-h5/src/view/home/component/voice/index.less b/projects/translate-h5/src/view/home/translate/component/voice/index.less
similarity index 100%
rename from projects/translate-h5/src/view/home/component/voice/index.less
rename to projects/translate-h5/src/view/home/translate/component/voice/index.less
diff --git a/projects/translate-h5/src/view/home/component/voice/index.tsx b/projects/translate-h5/src/view/home/translate/component/voice/index.tsx
similarity index 95%
rename from projects/translate-h5/src/view/home/component/voice/index.tsx
rename to projects/translate-h5/src/view/home/translate/component/voice/index.tsx
index 196ec00..218ed3b 100644
--- a/projects/translate-h5/src/view/home/component/voice/index.tsx
+++ b/projects/translate-h5/src/view/home/translate/component/voice/index.tsx
@@ -5,8 +5,6 @@ import microphoneSvg from "@/assets/translate/microphone.svg";
import microphoneDisabledSvg from "@/assets/translate/microphoneDisabledSvg.svg";
import { createStartRecordSound, createSendSound } from "@/utils/voice";
import "./index.less";
-import { Message } from "../../types";
-import { CloseCircleOutline } from "antd-mobile-icons";
interface DefinedProps {
onRecordingComplete: (url: string, finalDuration: number) => void;
@@ -80,10 +78,7 @@ function Index(props: DefinedProps) {
//正在录音中
return (
-
+
@@ -95,14 +90,7 @@ function Index(props: DefinedProps) {
);
} else {
//麦克风状态
- return (
-
- );
+ return ;
}
}, [hasPermission, isRecording, recordingDuration]);
const checkMicrophonePermission = useCallback(async () => {
diff --git a/projects/translate-h5/src/view/home/translate.tsx b/projects/translate-h5/src/view/home/translate/index.tsx
similarity index 88%
rename from projects/translate-h5/src/view/home/translate.tsx
rename to projects/translate-h5/src/view/home/translate/index.tsx
index 3c5d328..4d32edb 100644
--- a/projects/translate-h5/src/view/home/translate.tsx
+++ b/projects/translate-h5/src/view/home/translate/index.tsx
@@ -3,7 +3,7 @@ import { Image, Toast } from "antd-mobile";
import MessageCom from "./component/message";
import VoiceRecord from "./component/voice";
import { XPopup, FloatingMenu, type FloatMenuItemConfig } from "@workspace/shared";
-import type { Message } from "./types";
+import type { Message } from "../types";
import { mockTranslateAudio } from "@/utils/voice";
import dogSvg from "@/assets/translate/dog.svg";
@@ -11,7 +11,9 @@ import catSvg from "@/assets/translate/cat.svg";
import pigSvg from "@/assets/translate/pig.svg";
import { MoreTwo } from "@icon-park/react";
import SearchCom from "./component/search";
-interface DefinedProps {}
+interface DefinedProps {
+ searchVisible: boolean;
+}
const menuItems: FloatMenuItemConfig[] = [
{ icon: , type: "dog" },
{ icon: , type: "cat" },
@@ -22,23 +24,11 @@ const menuItems: FloatMenuItemConfig[] = [
},
];
function Index(props: DefinedProps) {
- // const data: Message[] = [
- // {
- // id: 1,
- // audioUrl: "",
- // duration: 0,
- // translatedText: "",
- // isTranslating: true,
- // isPlaying: false,
- // timestamp: 0,
- // },
- // ];
- const [currentPlayingId, setCurrentPlayingId] = useState(null); //当前播放id
+ const { searchVisible } = props;
const [messages, setMessages] = useState([]);
const [isRecording, setIsRecording] = useState(false); //是否录音中
const [currentLanguage, setCurrentLanguage] = useState();
const [visible, setVisible] = useState(false);
-
useEffect(() => {
setCurrentLanguage(menuItems[0]);
}, []);
@@ -111,9 +101,11 @@ function Index(props: DefinedProps) {
return (
-
- {}} />
-
+ {searchVisible && (
+
+ {}} />
+
+ )}
{
- if (process.env.NODE_ENV === "production") {
- return `[hash:base64:8]`;
- }
- return `[name]__[local]___[hash:base64:5]`;
- },
- },
+ modules: {},
preprocessorOptions: {
less: {
// 全局变量