Skip to content

Commit d40ead7

Browse files
committed
fix: 菜单问题, 样式修复
1 parent 61e2d44 commit d40ead7

File tree

7 files changed

+81
-54
lines changed

7 files changed

+81
-54
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
},
1313
"dependencies": {
1414
"@ant-design/icons": "^5.4.0",
15-
"@ant-design/nextjs-registry": "^1.0.0",
15+
"@ant-design/nextjs-registry": "^1.0.1",
1616
"@monaco-editor/react": "^4.6.0",
1717
"antd": "^5.19.3",
1818
"classnames": "^2.5.1",
1919
"lodash": "^4.17.21",
20-
"next": "14.2.8",
20+
"next": "14.2.11",
2121
"react": "^18",
2222
"react-dom": "^18"
2323
},

pnpm-lock.yaml

+39-39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/code/format/page.tsx

+19-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
import React, { useRef, useState } from 'react';
44

5+
import prettier from 'prettier/standalone';
6+
import parserBabel from 'prettier/parser-babel';
7+
import prettierPluginEstree from 'prettier/plugins/estree';
8+
import prettierPluginHtml from 'prettier/plugins/html';
9+
510
import { Editor, EditorType } from '../../../components/editor';
611
import Toolbar from '../../../components/toolbar';
712

8-
import s from './index.module.scss';
913
import { Button, Space } from 'antd';
1014
import { useMonacoEditor } from '../../../utils/config/editor';
1115
import { useAppConfig } from '../../../utils/config/app';
1216

17+
import s from './index.module.scss';
18+
1319
export default function Page() {
1420
const { editor } = useMonacoEditor();
1521
const appConfig = useAppConfig();
@@ -29,7 +35,18 @@ export default function Page() {
2935
<Button
3036
size="middle"
3137
type="primary"
32-
onClick={() => {
38+
onClick={async () => {
39+
console.log('editor', editor.getValue(), appConfig);
40+
if (editor?.getValue?.()) {
41+
await prettier.format(editor.getValue(), {
42+
parser: 'html',
43+
plugins: [
44+
// parserBabel,
45+
// prettierPluginEstree,
46+
prettierPluginHtml,
47+
],
48+
});
49+
}
3350
editor.handleFormatDocument();
3451
}}
3552
>

src/app/layout.tsx

-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ export const metadata: Metadata = {
1212
icons: {
1313
icon: '/favicon.ico',
1414
},
15-
viewport: {
16-
width: 'device-width',
17-
initialScale: 1,
18-
maximumScale: 1,
19-
},
2015
};
2116

2217
const RootLayout = ({ children }: Readonly<React.PropsWithChildren>) => (

src/app/template.tsx

+16-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
66
import { ConfigProvider, Button, Layout, Menu, theme, Space } from 'antd';
77

88
import Link from 'next/link';
9+
import { usePathname, useSearchParams } from 'next/navigation';
10+
911
import Image from 'next/image';
1012

1113
import FooterContent from '../components/footer';
@@ -20,12 +22,15 @@ import { MonacoEditor } from '../utils/config/editor';
2022

2123
import { menu } from '../utils/menu';
2224

25+
// console.log('menu', menu);
26+
2327
const { Header, Sider, Content, Footer } = Layout;
2428

2529
export default function Template({
2630
// @ts-ignore
2731
children,
2832
}) {
33+
const pathname = usePathname();
2934
const [collapsed, setCollapsed] = useState(false);
3035
const [appConfig, setAppConfig] = useState<
3136
Partial<AppConfigParams> | undefined
@@ -65,14 +70,20 @@ export default function Template({
6570
}}
6671
>
6772
<div className={s.logoContainer}>
68-
<Link href="/">
73+
<Link
74+
href="/"
75+
style={{
76+
display: 'flex',
77+
alignItems: 'center',
78+
}}
79+
>
6980
<Image
7081
width={44}
7182
height={44}
7283
src="https://rain120.github.io/study-notes/img/chao.png"
7384
alt=""
74-
loader={() =>
75-
'https://rain120.github.io/study-notes/img/chao.png'
85+
loader={({ src, width, quality }) =>
86+
`https://rain120.github.io/study-notes/img/chao.png?w=${width}&q=${quality || 75}`
7687
}
7788
className={s.logo}
7889
/>
@@ -100,7 +111,8 @@ export default function Template({
100111
mode="inline"
101112
theme="dark"
102113
defaultOpenKeys={menu.map((m) => m.key)}
103-
inlineCollapsed={false}
114+
// inlineCollapsed={false}
115+
selectedKeys={[pathname]}
104116
items={menu}
105117
/>
106118
<div className={s.menuOp}>

src/app/themeConfig.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
'use client';
2+
13
import type { ThemeConfig } from 'antd';
24

35
const theme: ThemeConfig = {
4-
token: {
5-
},
6+
token: {},
67
};
78

89
export default theme;

src/utils/menu/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ export const menu = MENU_PATH_DATA.map((m) => {
4141
return {
4242
...c,
4343
...omit(m, 'path'),
44+
key: c.path || m.key,
4445
label: c.path ? <Link href={c.path}>{c.label}</Link> : c.label,
4546
children: m.children?.map((mc) => {
4647
const _mc = MENU_INFO[mc.label] ?? {};
4748

4849
return {
4950
..._mc,
5051
...mc,
52+
key: mc.path,
5153
label: <Link href={mc.path}>{_mc.label}</Link>,
5254
};
5355
}),

0 commit comments

Comments
 (0)