Skip to content

Commit

Permalink
✨ cubic中可以更改每面的文字
Browse files Browse the repository at this point in the history
  • Loading branch information
neila-a committed Apr 25, 2024
1 parent 8e5e819 commit f00586c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/app/components/dialog/InputDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function InputDialog(props: {
<DialogContentText>
{props.context}
</DialogContentText>
<TextField autoFocus margin="dense" label={props.label} fullWidth variant="standard" onChange={event => {
<TextField autoFocus margin="dense" label={props.label} fullWidth onChange={event => {
setInput(event.target.value);
}} />
</DialogContent>
Expand Down
6 changes: 1 addition & 5 deletions packages/core/src/app/index/EditToolsListDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import useToolsList from "./getToolsList";
import {
getTools
} from "tools/info";
import {
useLiveQuery
} from "dexie-react-hooks";
import db from "db";
import convertExtensionTools from "./convertExtensionTools";
import {
extensions,
Expand Down Expand Up @@ -90,7 +86,7 @@ export default function EditToolsListDialog(props: {
setDialogListName("");
setDialogOpen(false);
}}>
<TextField value={dialogListName} autoFocus margin="dense" label={get("category.分类名称")} fullWidth variant="standard" onChange={event => {
<TextField value={dialogListName} autoFocus margin="dense" label={get("category.分类名称")} fullWidth onChange={event => {
setDialogListName(event.target.value);
}} />
<TransferList left={props.left} right={right} onLeftChange={context => {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/app/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
"主页": "主页",
"外观": "外观",
"入口": "入口",
"cubic": {
"face": "第{face}面"
},
"back": "返回",
"close": "关闭",
"drag": {
Expand Down
27 changes: 25 additions & 2 deletions packages/core/src/app/tools/cubic/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
OrbitControls
} from '@react-three/drei'
import {
useRef, useState
useRef,
useState
} from "react";
import {
BoxGeometry,
Expand All @@ -17,11 +18,19 @@ import {
MeshPhongMaterial
} from "three";
import getTextCanvas from "./getTextCanvas";
import {
FormGroup,
TextField
} from "@mui/material";
import {
get
} from "react-intl-universal";
type text = [string, string, string, string, string, string];
export default function Cubic(): JSX.Element {
const canvas = useRef<HTMLCanvasElement>(),
camera = useRef<Camera>(),
mesh = useRef<Mesh>(),
[text, setText] = useState<[string, string, string, string, string, string]>(["A", "B", "C", "D", "E", "F"]),
[text, setText] = useState<text>(["A", "B", "C", "D", "E", "F"]),
materials = [1, 2, 3, 4, 5, 6].map((item, index) => new MeshPhongMaterial({
map: new CanvasTexture(getTextCanvas(text[index])),
color: 0xffffff
Expand All @@ -37,6 +46,20 @@ export default function Cubic(): JSX.Element {
<OrbitControls />
<Stats />
</Canvas>
<FormGroup>
{text.map((a, index) => (
<TextField value={a} margin="dense" label={get("cubic.face", {
face: index + 1
})} fullWidth onChange={event => {
setText(old => old.map((value, searchingIndex) => {
if (searchingIndex === index) {
return event.target.value;
}
return value;
}) as text);
}} />
))}
</FormGroup>
</>
);
};

0 comments on commit f00586c

Please sign in to comment.