5.2.12 升级版本(很久没升级的人使用)
SunLxy opened this issue · 0 comments
SunLxy commented
// kktrc.ts文件
import defaultConfig from "@uiw-admin/config"
- import { RematchWebpackPlugin, RoutesWebpackPlugin } from '@uiw-admin/plugins'
- import lessModules from '@kkt/less-modules'
- import rawModules from '@kkt/raw-modules'
- import scopePluginOptions from '@kkt/scope-plugin-options'
export default defaultConfig({
define: {
- VERSION: JSON.stringify(pkg.version),
// BASE_NAME: "/uiw"
},
- plugins: [new RematchWebpackPlugin(), new RoutesWebpackPlugin()],
// publicPath: process.env.NODE_ENV === "development" ? "/" : "/uiw/",
- loader: [
- rawModules,
- { loader: scopePluginOptions, options: { allowedFiles: [path.resolve(process.cwd(), 'README.md')] } },
- lessModules
- ],
})
// model 文件
+ import { RootModel } from '@uiw-admin/models'
+ import { createModel } from '@rematch/core'
- export interface GlobalState {
- test: string
- [s: string]: any
- }
const global =
+ createModel<RootModel>()(
{
name: 'global',
- state: {
- test: '测试全局State',
- } as GlobalState,
+ state: {
+ test: '测试全局State',
+ },
- reducers: {
- updateState: (state: GlobalState, payload: GlobalState) => ({
- ...state,
- ...payload,
- }),
- },
+ reducers: {
+ updateState: (state, payload) => ({
+ ...state,
+ ...payload,
+ }),
+ },
effects: (dispatch) => ({
async verify() {
const dph = dispatch
dph.global.updateState({ test: '测试2' })
},
}),
}
+)
export default global
// src/index.tsx
import React from 'react';
import ReactDOM from 'react-dom';
- import { Provider } from 'react-redux';
- import { store } from '@uiw-admin/models';
import Control from '@uiw-admin/router-control';
import { SWRConfig } from 'swr';
import { request } from '@uiw-admin/utils';
import '@uiw/reset.css';
import './index.css';
ReactDOM.render(
<SWRConfig
value={{
// revalidateOnFocus: false,
fetcher: (resource, init) => {
return request(resource, init);
},
provider: () => new Map(),
}}
>
- <Provider store={store}>
<Control
routeType="hash"
/>
- </Provider>
</SWRConfig>,
document.getElementById('root'),
);