Skip to content

Commit

Permalink
chore: remove pkg config
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohuoni committed Nov 7, 2022
1 parent 54420d1 commit 36e289f
Show file tree
Hide file tree
Showing 42 changed files with 5,107 additions and 683 deletions.
1 change: 1 addition & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"ignore": [
"@examples/aclass",
"@examples/alita2",
"@examples/boilerplate",
"@examples/helmet",
"@examples/boilerplate",
Expand Down
7 changes: 7 additions & 0 deletions .changeset/lemon-berries-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'alita': minor
'@alita/native': minor
'@alita/plugins': minor
---

feat: support alita2
23 changes: 23 additions & 0 deletions examples/alita2/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const isSSR = false;
const isCordova = false;
const outputPath = isCordova ? 'www' : 'dist';
const env = process.env.NODE_ENV;
// 这里需要对应服务器地址
const path = env === 'development' ? 'http://127.0.0.1:8000/' : outputPath;

export default {
appType: isCordova ? 'cordova' : 'h5',
mobileLayout: true,
hash: false,
// ssr: isSSR && !isCordova ? {} : false,
outputPath: outputPath,
publicPath: isSSR && !isCordova ? path : './',
keepalive: [/list/],
packageId: 'com.alita.demos',
displayName: 'alita-demos',
// mobile5: true,
aconsole: {
inspx: {},
console: {},
},
};
98 changes: 98 additions & 0 deletions examples/alita2/mock/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { Request, Response } from 'express';

export default {
'POST /api/hello': {
text: 'Alita',
},
'POST /api/list': (req: Request, res: Response) => {
const dataSource = [
{
id: 1,
title: 'Ant Design Title 1',
},
{
id: 2,
title: 'Ant Design Title 2',
},
{
id: 3,
title: 'Ant Design Title 3',
},
{
id: 4,
title: 'Ant Design Title 4',
},
{
id: 5,
title: 'Ant Design Title 5',
},
{
id: 6,
title: 'Ant Design Title 6',
},
{
id: 7,
title: 'Ant Design Title 7',
},
{
id: 8,
title: 'Ant Design Title 8',
},
{
id: 9,
title: 'Ant Design Title 9',
},
{
id: 10,
title: 'Ant Design Title 10',
},
{
id: 11,
title: 'Ant Design Title 11',
},
{
id: 12,
title: 'Ant Design Title 12',
},
{
id: 13,
title: 'Ant Design Title 13',
},
{
id: 14,
title: 'Ant Design Title 14',
},
{
id: 15,
title: 'Ant Design Title 15',
},
{
id: 16,
title: 'Ant Design Title 16',
},
{
id: 17,
title: 'Ant Design Title 17',
},
{
id: 18,
title: 'Ant Design Title 18',
},
{
id: 19,
title: 'Ant Design Title 19',
},
{
id: 20,
title: 'Ant Design Title 20',
},
];
const { body } = req;

const { pageSize, offset } = body;
return res.json({
total: dataSource.length,
data: dataSource.slice(offset, offset + pageSize),
});
},
};
24 changes: 24 additions & 0 deletions examples/alita2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@examples/alita2",
"private": true,
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "alita dev",
"build": "alita build"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@alita/react": "^0.1.0",
"@alitajs/dform": "3.0.0-alpha.1",
"@alitajs/iframe": "^0.0.3",
"@alitajs/list-view": "1.0.7",
"alita": "3.1.1",
"antd": "^4.24.1",
"antd-mobile": "2.3.4",
"antd-mobile-5": "^5.24.2"
}
}
95 changes: 95 additions & 0 deletions examples/alita2/src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import type { RequestConfig, ResponseError } from 'alita';
import {
NavBarListItem,
NavBarProps,
TabBarListItem,
TabBarProps,
TitleListItem,
} from 'alita';

import HomeGary from './assets/demoIcon/home.png';
import HomeBlue from './assets/demoIcon/home1.png';
import ListGary from './assets/demoIcon/list.png';
import ListBlue from './assets/demoIcon/list1.png';
import SetGary from './assets/demoIcon/setting.png';
import SetBlue from './assets/demoIcon/setting1.png';

export function getKeepAlive() {
return [/list/];
}

export const request: RequestConfig = {
prefix: '',
method: 'post',
errorHandler: (error: ResponseError) => {
// 集中处理错误
console.log(error);
},
};

const titleList: TitleListItem[] = [
{
pagePath: '/',
title: '首页',
},
{
pagePath: '/list',
title: '列表',
},
{
pagePath: '/settings',
title: '设置',
},
];
const navList: NavBarListItem[] = [];
const navBar: NavBarProps = {
navList,
fixed: false,
onLeftClick: () => {
// router.goBack();
},
};
const tabList: TabBarListItem[] = [
{
pagePath: '/',
text: '首页',
iconPath: HomeGary,
selectedIconPath: HomeBlue,
title: '首页',
iconSize: '',
badge: '',
},
{
pagePath: '/list',
text: '列表',
iconPath: ListGary,
selectedIconPath: ListBlue,
title: '列表',
iconSize: '',
badge: '',
},
{
pagePath: '/settings',
text: '设置',
iconPath: SetGary,
selectedIconPath: SetBlue,
title: '设置',
iconSize: '',
badge: '',
},
];

const tabBar: TabBarProps = {
color: `#999999`,
selectedColor: '#00A0FF',
borderStyle: 'white',
position: 'bottom',
list: tabList,
};

export const mobileLayout = {
documentTitle: '默认标题',
navBar,
tabBar,
titleList,
};
Binary file added examples/alita2/src/assets/demoIcon/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/alita2/src/assets/demoIcon/home1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/alita2/src/assets/demoIcon/list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/alita2/src/assets/demoIcon/list1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/alita2/src/assets/demoIcon/setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/alita2/src/assets/demoIcon/setting1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/alita2/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/alita2/src/global.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html {
--alita-safe-area-bottom: 0 !important;
}
46 changes: 46 additions & 0 deletions examples/alita2/src/models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { query } from '@/services/api';
import { Effect, Reducer } from 'alita';

export interface IndexModelState {
name: string;
}

export interface IndexModelType {
namespace: 'index';
state: IndexModelState;
effects: {
query: Effect;
};
reducers: {
save: Reducer<IndexModelState>;
};
}

const IndexModel: IndexModelType = {
namespace: 'index',

state: {
name: '',
},

effects: {
*query({ payload }, { call, put }) {
const data = yield call(query, payload);
console.log(data);
yield put({
type: 'save',
payload: { name: data.text },
});
},
},
reducers: {
save(state, action) {
return {
...state,
...action.payload,
};
},
},
};

export default IndexModel;
46 changes: 46 additions & 0 deletions examples/alita2/src/models/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { query } from '@/services/api';
import { Effect, Reducer } from 'alita';

export interface ListModelState {
name: string;
}

export interface ListModelType {
namespace: 'list';
state: ListModelState;
effects: {
query: Effect;
};
reducers: {
save: Reducer<ListModelState>;
};
}

const ListModel: ListModelType = {
namespace: 'list',

state: {
name: '',
},

effects: {
*query({ payload }, { call, put }) {
const data = yield call(query, payload);
console.log(data);
yield put({
type: 'save',
payload: { name: data.text },
});
},
},
reducers: {
save(state, action) {
return {
...state,
...action.payload,
};
},
},
};

export default ListModel;
Loading

0 comments on commit 36e289f

Please sign in to comment.