From 1d16997af8122666ed003dfd4eadbbaee660aa66 Mon Sep 17 00:00:00 2001 From: "shuilan.cj" Date: Tue, 22 Mar 2022 10:30:14 +0800 Subject: [PATCH] fix: page config type --- examples/basic-project/src/pages/about.tsx | 21 +++++---------------- examples/basic-project/src/pages/index.tsx | 7 ++----- packages/runtime/src/DocumentContext.tsx | 6 +++--- packages/runtime/src/types.ts | 8 ++++++++ 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/examples/basic-project/src/pages/about.tsx b/examples/basic-project/src/pages/about.tsx index 5317f328b..a5373e363 100644 --- a/examples/basic-project/src/pages/about.tsx +++ b/examples/basic-project/src/pages/about.tsx @@ -1,23 +1,12 @@ import * as React from 'react'; -<<<<<<< HEAD -import { useAppContext } from 'ice'; -import './home.css'; - -export default function About() { - const appContext = useAppContext(); - - console.log('About Page: appContext', appContext); - - return <>

About Page

; -} -======= import { Link } from 'ice'; export default function About() { return <>

About Page

home; } -About.pageConfig = { - auth: ['guest'], -}; ->>>>>>> 1d93732c... feat: router (#28) +export function getPageConfig() { + return { + auth: ['guest'], + }; +} diff --git a/examples/basic-project/src/pages/index.tsx b/examples/basic-project/src/pages/index.tsx index c9fe8c67e..086f9ba95 100644 --- a/examples/basic-project/src/pages/index.tsx +++ b/examples/basic-project/src/pages/index.tsx @@ -14,9 +14,6 @@ export function getPageConfig() { scripts: [ { src: 'https://g.alicdn.com/alilog/mlog/aplus_v2.js', block: true }, ], + auth: ['admin'], }; -} - -Home.pageConfig = { - auth: ['admin'], -}; \ No newline at end of file +} \ No newline at end of file diff --git a/packages/runtime/src/DocumentContext.tsx b/packages/runtime/src/DocumentContext.tsx index f5a5efc23..6c1887787 100644 --- a/packages/runtime/src/DocumentContext.tsx +++ b/packages/runtime/src/DocumentContext.tsx @@ -1,9 +1,9 @@ import * as React from 'react'; - +import type { PageConfig, PageAssets } from './types'; interface DocumentContext { html?: string; - pageAssets?: any; - pageConfig?: any; + pageAssets?: PageAssets; + pageConfig?: PageConfig; } const Context = React.createContext(null); diff --git a/packages/runtime/src/types.ts b/packages/runtime/src/types.ts index e089a2c5f..f6506cae3 100644 --- a/packages/runtime/src/types.ts +++ b/packages/runtime/src/types.ts @@ -48,9 +48,17 @@ export interface RouteMatch { export interface PageConfig { title?: string; + meta?: any[]; + links?: any[]; + scripts?: any[]; auth?: string[]; } +export interface PageAssets { + links?: any[]; + scripts?: any[]; +} + export type PageWrapper = ((Component: ComponentType) => ComponentType); export type SetAppRouter = (AppRouter: ComponentType) => void; export type AddProvider = (Provider: ComponentType) => void;