Browse Source

修复编译

main
李金 6 months ago
parent
commit
d896d11fcf
  1. 94
      src/components/config-provider/index.tsx
  2. 22
      src/components/glass/index.tsx
  3. 108
      src/components/icon/picker/PickerPanel.tsx
  4. 21
      src/pages/dashboard/index.tsx
  5. 25
      tsconfig.json

94
src/components/config-provider/index.tsx

@ -1,63 +1,63 @@
import { ConfigProvider as AntdConfigProvider, ConfigProviderProps as AntdConfigProviderProps } from 'antd'
import { AntdToken, ThemeAppearance, useAntdToken, useThemeMode } from 'antd-style'
import { AntdToken, ThemeAppearance, useThemeMode } from 'antd-style'
import type { OverrideToken } from 'antd/es/theme/interface'
import type { FC, ReactNode } from 'react'
import { ThemeProvider, createProAntdTheme, getProToken } from '@/theme'
export const useProAntdTheme = (appearance: ThemeAppearance) => {
const token = useAntdToken()
const themeConfig = createProAntdTheme(appearance)
const controlToken: Partial<AntdToken> = {
// colorBgContainer: token?.colorFillQuaternary,
// colorBorder: 'transparent',
// controlOutline: 'transparent',
}
themeConfig.components = {
Input: controlToken,
InputNumber: controlToken,
Select: controlToken,
Tree: {
colorBgContainer: 'transparent',
directoryNodeSelectedBg: '#e1f0ff',
directoryNodeSelectedColor: 'rgb(22, 62, 124)',
},
TreeSelect: controlToken,
}
return themeConfig
// const token = useAntdToken()
const themeConfig = createProAntdTheme(appearance)
const controlToken: Partial<AntdToken> = {
// colorBgContainer: token?.colorFillQuaternary,
// colorBorder: 'transparent',
// controlOutline: 'transparent',
}
themeConfig.components = {
Input: controlToken,
InputNumber: controlToken,
Select: controlToken,
Tree: {
colorBgContainer: 'transparent',
directoryNodeSelectedBg: '#e1f0ff',
directoryNodeSelectedColor: 'rgb(22, 62, 124)',
},
TreeSelect: controlToken,
}
return themeConfig
}
export interface ConfigProviderProps extends AntdConfigProviderProps {
componentToken?: OverrideToken;
children: ReactNode;
componentToken?: OverrideToken;
children: ReactNode;
}
export const ConfigProvider: FC<ConfigProviderProps> = ({ children, componentToken, ...props }) => {
const { appearance, themeMode } = useThemeMode()
const proTheme = useProAntdTheme(appearance)
proTheme.components = { ...proTheme.components, ...componentToken }
return (
<AntdConfigProvider theme={proTheme} {...props}>
<ThemeProvider
appearance={appearance}
themeMode={themeMode}
// 以下都是自定义主题
theme={createProAntdTheme}
customToken={getProToken}
>
{children}
</ThemeProvider>
</AntdConfigProvider>
)
const { appearance, themeMode } = useThemeMode()
const proTheme = useProAntdTheme(appearance)
proTheme.components = { ...proTheme.components, ...componentToken }
return (
<AntdConfigProvider theme={proTheme} {...props}>
<ThemeProvider
appearance={appearance}
themeMode={themeMode}
// 以下都是自定义主题
theme={createProAntdTheme}
customToken={getProToken}
>
{children}
</ThemeProvider>
</AntdConfigProvider>
)
}
export const withProvider = (Component) => (props) => {
return (
<ConfigProvider>
<Component {...props} />
</ConfigProvider>
)
return (
<ConfigProvider>
<Component {...props} />
</ConfigProvider>
)
}

22
src/components/glass/index.tsx

@ -17,21 +17,21 @@ const Glass = (props: IClassProps) => {
}
return (
<div className={styles.container}>
<Flex justify={'center'} align={'center'} className={styles.description}>
{props.description}
</Flex>
<div className={styles.glass}/>
{props.children}
</div>
<div className={styles.container}>
<Flex justify={'center'} align={'center'} className={styles.description}>
{props.description}
</Flex>
<div className={styles.glass}/>
{props.children}
</div>
)
}
export const withGlass = (Component: React.Component | React.FC | JSX.Element | React.ReactNode) => (props) => {
export const withGlass = (Component: any) => (props) => {
return (
<Glass enabled={props.enabled}>
<Component {...props} />
</Glass>
<Glass enabled={props.enabled}>
<Component {...props as any} />
</Glass>
)
}

108
src/components/icon/picker/PickerPanel.tsx

@ -11,64 +11,64 @@ import { usePickerContext } from './context.tsx'
const PickerPanel = () => {
const {
state: { icon, panelTabKey, },
actions: { resetIcon, changePanelTab, isEmptyIconAntdList, isEmptyIconParkList }
} = usePickerContext()
const {
state: { icon, panelTabKey, },
actions: { resetIcon, changePanelTab, isEmptyIconAntdList, isEmptyIconParkList }
} = usePickerContext()
const token = useToken()
const token = useToken()
return (
<Flexbox width={300} gap={12} style={{ maxHeight: 400 }}>
{icon ? (
<Flexbox distribution={'space-between'} horizontal align={'center'}>
<Flexbox horizontal align={'center'} gap={8}>
<IconItem {...icon as any} />
<div>{getIconName(icon)}</div>
</Flexbox>
<Button size={'small'} type={'link'} onClick={resetIcon}>
</Button>
</Flexbox>
) : undefined}
<Segmented
options={[
{ label: 'Ant Design', value: 'antd', icon: <AntDesignOutlined/> },
{ label: 'Icon Park', value: 'park' },
]}
value={panelTabKey}
onChange={(key) => {
changePanelTab(key as any)
}}
block
/>
return (
<Flexbox width={300} gap={12} style={{ maxHeight: 400 }}>
{icon ? (
<Flexbox distribution={'space-between'} horizontal align={'center'}>
<Flexbox horizontal align={'center'} gap={8}>
<IconItem {...icon as any} />
<div>{getIconName(icon as any)}</div>
</Flexbox>
<Button size={'small'} type={'link'} onClick={resetIcon}>
</Button>
</Flexbox>
) : undefined}
<Segmented
options={[
{ label: 'Ant Design', value: 'antd', icon: <AntDesignOutlined/> },
{ label: 'Icon Park', value: 'park' },
]}
value={panelTabKey}
onChange={(key) => {
changePanelTab(key as any)
}}
block
/>
{(isEmptyIconAntdList || isEmptyIconParkList) ? (
(
<Result
status={'info'}
style={{ padding: 0, paddingTop: 8 }}
subTitle={'暂未选择图标库,请选择图标库'}
/>
)
) : (
<>
<SearchBar/>
<Flexbox
className={cx(css`
overflow-y: scroll;
border: 1px solid ${token.colorBorderSecondary};
border-left: 0;
padding-top: -1px;
`)}
>
<IconList/>
</Flexbox>
</>
)}
</Flexbox>
)
{(isEmptyIconAntdList || isEmptyIconParkList) ? (
(
<Result
status={'info'}
style={{ padding: 0, paddingTop: 8 }}
subTitle={'暂未选择图标库,请选择图标库'}
/>
)
) : (
<>
<SearchBar/>
<Flexbox
className={cx(css`
overflow-y: scroll;
border: 1px solid ${token.colorBorderSecondary};
border-left: 0;
padding-top: -1px;
`)}
>
<IconList/>
</Flexbox>
</>
)}
</Flexbox>
)
}
export default PickerPanel

21
src/pages/dashboard/index.tsx

@ -4,21 +4,22 @@ import { createFileRoute } from '@tanstack/react-router'
const Index = () => {
return (
<>
<ProCard
style={{
height: '100vh',
minHeight: 800,
}}
>
<>
<ProCard
style={{
height: '100vh',
minHeight: 800,
}}
>
<h1>Dashboard</h1>
<h1>Dashboard</h1>
</ProCard>
</>
</ProCard>
</>
)
}
// @ts-ignore
export const Route = createFileRoute('/dashboard')({
component: Index,
})

25
tsconfig.json

@ -2,10 +2,13 @@
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
@ -13,7 +16,6 @@
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"noImplicitAny": false,
"strict": true,
@ -21,14 +23,21 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true,
/* Type checking */
"strictNullChecks": true,
"files": [ "./src/**/*.d.ts"],
// "files": [ "./src/**/*.d.ts"],
"paths": {
"@/*": ["./src/*"]
"@/*": [
"./src/*"
]
}
},
"include": ["./src"],
"references": [{ "path": "./tsconfig.node.json" }]
"include": [
"./src"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
Loading…
Cancel
Save