From 6e42e44fed2bc39491ac347840330cb6f0a463c6 Mon Sep 17 00:00:00 2001 From: shixiaohua Date: Mon, 3 Jun 2024 11:19:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A4=84=E7=90=86useRouter=20ReferenceErro?= =?UTF-8?q?r:=20location=20is=20not=20defined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next.config.mjs | 4 +-- src/app/@auth/(.)login/page.tsx | 0 src/app/login/page.tsx | 0 src/app/page.tsx | 21 ++++++++------ src/app/route.tsx | 12 -------- src/middleware.ts | 23 --------------- src/ui/acme-logo.tsx | 12 -------- src/ui/dashboard/nav-links.tsx | 37 ------------------------- src/ui/dashboard/sidenav.tsx | 29 ------------------- src/ui/fonts.ts | 7 ----- src/ui/task/calendar/CalShow.tsx | 2 +- src/ui/task/project/DetailModelForm.tsx | 7 +++-- src/ui/task/project/TreeTablePro.tsx | 2 +- 13 files changed, 20 insertions(+), 136 deletions(-) delete mode 100644 src/app/@auth/(.)login/page.tsx delete mode 100644 src/app/login/page.tsx delete mode 100644 src/app/route.tsx delete mode 100644 src/middleware.ts delete mode 100644 src/ui/acme-logo.tsx delete mode 100644 src/ui/dashboard/nav-links.tsx delete mode 100644 src/ui/dashboard/sidenav.tsx delete mode 100644 src/ui/fonts.ts diff --git a/next.config.mjs b/next.config.mjs index f49e64d..04725e4 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,7 +1,7 @@ /** @type {import('next').NextConfig} */ const nextConfig = { // Middleware cannot be used with "output: export". - // output: 'export', + output: 'export', // Optional: Change links `/me` -> `/me/` and emit `/me.html` -> `/me/index.html` // trailingSlash: true, @@ -9,7 +9,7 @@ const nextConfig = { // skipTrailingSlashRedirect: true, // Optional: Change the output directory `out` -> `dist` - // distDir: 'dist', + distDir: 'docker/out', }; export default nextConfig; diff --git a/src/app/@auth/(.)login/page.tsx b/src/app/@auth/(.)login/page.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/page.tsx b/src/app/page.tsx index 2303575..00b50c1 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,13 +1,16 @@ 'use client' -import {usePathname, useRouter} from "next/navigation"; +import { useRouter} from "next/navigation"; import dayjs from "dayjs"; +import {useEffect} from "react"; + export default function Home() { - console.log('app.usePathname()', usePathname()); - const { replace } = useRouter(); - replace("/task/four") - dayjs.locale('zh-cn') - return ( -
-
- ); + const {replace} = useRouter(); + useEffect(()=>{ + replace("/task/four") + },[]) + dayjs.locale('zh-cn') + return ( +
+
+ ); } diff --git a/src/app/route.tsx b/src/app/route.tsx deleted file mode 100644 index de578a3..0000000 --- a/src/app/route.tsx +++ /dev/null @@ -1,12 +0,0 @@ -export const dynamic = 'force-dynamic' // defaults to auto - -export async function GET(request: Request) { - return new Response('Hello, Next.js!', { - status: 200, - headers: { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type, Authorization', - }, - }) -} diff --git a/src/middleware.ts b/src/middleware.ts deleted file mode 100644 index 9fd3a1e..0000000 --- a/src/middleware.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { NextResponse } from 'next/server' -import type { NextRequest } from 'next/server' -// export const config = { -// matcher: ['/task/four', '/task/project','/search/task_message_tree'], -// } - -export function middleware(request: NextRequest) { - // Clone the request headers and set a new header `x-hello-from-middleware1` - // const requestHeaders = new Headers(request.headers) - // requestHeaders.set('x-hello-from-middleware1', 'hello') - console.log('middleware:',request) - // You can also set request headers in NextResponse.rewrite - const response = NextResponse.next({ - request: { - // New request headers - // headers: requestHeaders, - }, - }) - - // Set a new response header `x-hello-from-middleware2` - response.headers.set('x-hello-from-middleware2', 'hello') - return response -} diff --git a/src/ui/acme-logo.tsx b/src/ui/acme-logo.tsx deleted file mode 100644 index b968f21..0000000 --- a/src/ui/acme-logo.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { GlobeAltIcon } from '@heroicons/react/24/outline'; - -export default function AcmeLogo() { - return ( -
- {/**/} -

Acme

-
- ); -} diff --git a/src/ui/dashboard/nav-links.tsx b/src/ui/dashboard/nav-links.tsx deleted file mode 100644 index b709459..0000000 --- a/src/ui/dashboard/nav-links.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { - UserGroupIcon, - HomeIcon, - DocumentDuplicateIcon, -} from '@heroicons/react/24/outline'; - -// Map of links to display in the side navigation. -// Depending on the size of the application, this would be stored in a database. -const links = [ - { name: 'Home', href: '/dashboard', icon: HomeIcon }, - { - name: 'Invoices', - href: '/dashboard/invoices', - icon: DocumentDuplicateIcon, - }, - { name: 'Customers', href: '/dashboard/customers', icon: UserGroupIcon }, -]; - -export default function NavLinks() { - return ( - <> - {links.map((link) => { - const LinkIcon = link.icon; - return ( - - {/**/} -

{link.name}

-
- ); - })} - - ); -} \ No newline at end of file diff --git a/src/ui/dashboard/sidenav.tsx b/src/ui/dashboard/sidenav.tsx deleted file mode 100644 index c0a9d8a..0000000 --- a/src/ui/dashboard/sidenav.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import Link from 'next/link'; -import NavLinks from '@/ui/dashboard/nav-links'; -import AcmeLogo from '@/ui/acme-logo'; -import { PowerIcon } from '@heroicons/react/24/outline'; - -export default function SideNav() { - return ( -
- -
- -
- -
- -
-
- -
-
-
- ); -} diff --git a/src/ui/fonts.ts b/src/ui/fonts.ts deleted file mode 100644 index a02fef8..0000000 --- a/src/ui/fonts.ts +++ /dev/null @@ -1,7 +0,0 @@ -// import { Inter,Lusitana } from 'next/font/google'; -// -// export const inter = Inter({ subsets: ['latin'] }); -// export const lusitana = Lusitana({ -// weight: ['400', '700'], -// subsets: ['latin'], -// }); \ No newline at end of file diff --git a/src/ui/task/calendar/CalShow.tsx b/src/ui/task/calendar/CalShow.tsx index e903bac..c20d3d7 100644 --- a/src/ui/task/calendar/CalShow.tsx +++ b/src/ui/task/calendar/CalShow.tsx @@ -86,7 +86,7 @@ const CalShow: React.FC = () => { return () => { clearClickTimeout() } - }, [useContext(LocalContext)]); + }, [useContext(LocalContext),range]); const message = { week: '周', work_week: '工作周', diff --git a/src/ui/task/project/DetailModelForm.tsx b/src/ui/task/project/DetailModelForm.tsx index e6bd19b..1e1eaef 100644 --- a/src/ui/task/project/DetailModelForm.tsx +++ b/src/ui/task/project/DetailModelForm.tsx @@ -100,10 +100,10 @@ export const DetailModelForm: React.FC = (props) => { props.reloadData?.(); }, }} - submitter={props.itemId!==undefined?{ + submitter={props.itemId!==undefined&&props.itemId!=-1?{ render: (prop, defaultDoms) => { return [ - , + :undefined, } diff --git a/src/ui/task/project/TreeTablePro.tsx b/src/ui/task/project/TreeTablePro.tsx index d37b1a1..0c8b2ed 100644 --- a/src/ui/task/project/TreeTablePro.tsx +++ b/src/ui/task/project/TreeTablePro.tsx @@ -132,7 +132,7 @@ const TreeTablePro: React.FC = () => { } ]; let toolBarRenderList = [ - { + { actionRef.current?.reload( false); }}/>,