Skip to content

Commit

Permalink
Publish
Browse files Browse the repository at this point in the history
  • Loading branch information
mantou132 committed Jan 22, 2024
1 parent 28c5de9 commit f161fb8
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 55 deletions.
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"name": "@gemjs/config",
"version": "1.6.12",
"version": "1.6.13",
"description": "Gemjs common config"
}
27 changes: 14 additions & 13 deletions packages/duoyun-ui/docs/zh/30-blog/200-crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ import { locationStore } from 'duoyun-ui/react/DyPatConsole';
import DyPatTable from 'duoyun-ui/react/DyPatTable';

export function Item() {
const [i, update] = useState(0);
useEffect(() => connect(locationStore, () => update(i + 1)), []);
const [_, update] = useState({});
useEffect(() => connect(locationStore, () => update({})), []);
return <DyPatTable></DyPatTable>;
}
```
Expand Down Expand Up @@ -257,7 +257,7 @@ import 'duoyun-ui/patterns/table';
export class ConsolePageItemElement extends GemElement {
state = {};

#columns: FilterableColumn[] = [
#columns: FilterableColumn<any>[] = [
{
title: 'No',
dataIndex: 'id',
Expand All @@ -282,21 +282,22 @@ export class ConsolePageItemElement extends GemElement {
```

```tsx React
import { useState, useEffect } from 'react';
import { connect } from '@mantou/gem';
import { get } from '@mantou/gem/helper/request';
import { locationStore } from 'duoyun-ui/patterns/console';
import { DyPatTable, FilterableColumn } from 'duoyun-ui/patterns/table';
import DyPatTable, { FilterableColumn } from 'duoyun-ui/react/DyPatTable';

export function Item() {
const [i, update] = useState(0);
useEffect(() => connect(locationStore, () => update(i + 1)), []);
const [_, update] = useState({});
useEffect(() => connect(locationStore, () => update({})), []);

const [data, updateData] = useState();
useEffect(() => {
get(`https://jsonplaceholder.typicode.com/users`).then(updateData);
}, []);

const columns: FilterableColumn[] = [
const columns: FilterableColumn<any>[] = [
{
title: 'No',
dataIndex: 'id',
Expand All @@ -318,7 +319,7 @@ export function Item() {
```ts
import { ContextMenu } from 'duoyun-ui/elements/contextmenu';

const columns: FilterableColumn[] = [
const columns: FilterableColumn<any>[] = [
// ...
{
title: '',
Expand Down Expand Up @@ -352,7 +353,7 @@ const columns: FilterableColumn[] = [
```ts
import type { FormItem } from 'duoyun-ui/patterns/form';

const formItems: FormItem[] = [
const formItems: FormItem<any>[] = [
{
type: 'text',
field: 'username',
Expand Down Expand Up @@ -458,8 +459,8 @@ html`

```ts
import { Time } from 'duoyun-ui/lib/time';
import { PaginationReq, createPaginationStore } from 'duoyun-ui/helper/store';
import type { ChangeEventDetail } from 'duoyun-ui/patterns/table';
import { createPaginationStore } from 'duoyun-ui/helper/store';
import type { FetchEventDetail } from 'duoyun-ui/patterns/table';

const { store, updatePage } = createPaginationStore({
storageKey: 'users',
Expand All @@ -468,7 +469,7 @@ const { store, updatePage } = createPaginationStore({
});

// 模拟真实 API
const fetchList = (args: PaginationReq) => {
const fetchList = (args: FetchEventDetail) => {
return get(`https://jsonplaceholder.typicode.com/users`).then((list) => {
list.forEach((e, i) => {
e.updated = new Time().subtract(i + 1, 'd').getTime();
Expand All @@ -478,7 +479,7 @@ const fetchList = (args: PaginationReq) => {
});
};

const onFetch = ({ detail }: CustomEvent<ChangeEventDetail>) => {
const onFetch = ({ detail }: CustomEvent<FetchEventDetail>) => {
updatePage(fetchList, detail);
};
```
Expand Down
4 changes: 2 additions & 2 deletions packages/duoyun-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "duoyun-ui",
"version": "1.1.10",
"version": "1.1.12",
"description": "A lightweight desktop UI component library, implemented using Gem",
"keywords": [
"frontend",
Expand Down Expand Up @@ -56,7 +56,7 @@
},
"devDependencies": {
"@esm-bundle/chai": "^4.3.4-fix.0",
"@gemjs/config": "^1.6.12",
"@gemjs/config": "^1.6.13",
"@open-wc/testing": "^2.5.33",
"@types/d3-geo": "^3.0.1",
"@web/dev-server-esbuild": "^0.2.16",
Expand Down
17 changes: 10 additions & 7 deletions packages/duoyun-ui/src/helper/store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UseCacheStoreOptions, useCacheStore } from '../lib/utils';

export type PaginationReq = {
type PaginationReq = {
page: number;
size: number;
};
Expand Down Expand Up @@ -63,19 +63,22 @@ export function createPaginationStore<T extends Record<string, any>>(options: Pa
update();
};

const updatePage = async (request: (args: PaginationReq) => Promise<PaginationRes<any>>, args: PaginationReq) => {
changePage(args.page, { loading: true });
const updatePage = async <Req extends PaginationReq>(
request: (req: Req) => Promise<PaginationRes<any>>,
req: Req,
) => {
changePage(req.page, { loading: true });
try {
const result = await request(args);
changePage(args.page, { ids: result.list.map((e) => e[idKey]) });
const result = await request(req);
changePage(req.page, { ids: result.list.map((e) => e[idKey]) });

if (pageContainItem) {
result.list.forEach((e) => (store.items[e[idKey]] = e));
}

update({ total: 'total' in result ? result.total : Math.ceil(result.count / args.size) });
update({ total: 'total' in result ? result.total : Math.ceil(result.count / req.size) });
} finally {
changePage(args.page, { loading: false });
changePage(req.page, { loading: false });
}
};

Expand Down
6 changes: 3 additions & 3 deletions packages/gem-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gem-analyzer",
"version": "1.7.7",
"version": "1.7.8",
"description": "gem analyzer",
"main": "index.js",
"files": [
Expand All @@ -13,10 +13,10 @@
"prepublishOnly": "yarn build"
},
"dependencies": {
"@mantou/gem": "^1.7.10"
"@mantou/gem": "^1.7.11"
},
"devDependencies": {
"@gemjs/config": "^1.6.12",
"@gemjs/config": "^1.6.13",
"ts-morph": "^13.0.0",
"typescript": "^5.3.2"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/gem-book/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gem-book",
"version": "1.5.36",
"version": "1.5.37",
"description": "Create your document website easily and quickly",
"keywords": [
"doc",
Expand Down Expand Up @@ -39,7 +39,7 @@
"prepublishOnly": "yarn build"
},
"dependencies": {
"@mantou/gem": "^1.7.10",
"@mantou/gem": "^1.7.11",
"anymatch": "^3.1.3",
"chalk": "^2.4.2",
"cheerio": "^1.0.0-rc.12",
Expand Down Expand Up @@ -67,7 +67,7 @@
"devDependencies": {
"@codesandbox/sandpack-client": "^2.0.01",
"@esm-bundle/chai": "^4.3.4-fix.0",
"@gemjs/config": "^1.6.12",
"@gemjs/config": "^1.6.13",
"@open-wc/testing": "^2.5.33",
"@types/jsdom": "^16.2.10",
"@types/marked": "^2.0.2",
Expand All @@ -77,7 +77,7 @@
"@web/dev-server-esbuild": "^0.2.16",
"@web/test-runner": "^0.13.22",
"esbuild": "^0.14.14",
"gem-analyzer": "^1.7.7",
"gem-analyzer": "^1.7.8",
"nodemon": "^2.0.7",
"ts-morph": "^13.0.0",
"webpack-cli": "^5.1.4",
Expand Down
6 changes: 3 additions & 3 deletions packages/gem-devtools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gem-devtools",
"version": "1.7.6",
"version": "1.7.7",
"description": "Gem devtools",
"scripts": {
"update:version": "node ./scripts/update.js",
Expand All @@ -11,11 +11,11 @@
"start": "yarn build && concurrently -k npm:watch npm:browser"
},
"dependencies": {
"@mantou/gem": "^1.7.10",
"@mantou/gem": "^1.7.11",
"webextension-polyfill": "^0.10.0"
},
"devDependencies": {
"@gemjs/config": "^1.6.12",
"@gemjs/config": "^1.6.13",
"@types/webextension-polyfill": "^0.10.7",
"vite": "^4.5.2",
"web-ext": "^7.8.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/gem-examples/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"private": true,
"name": "gem-examples",
"version": "1.7.6",
"version": "1.7.7",
"description": "gem examples",
"scripts": {
"build": "vite build",
"start": "vite serve"
},
"dependencies": {
"@mantou/gem": "^1.7.10",
"duoyun-ui": "^1.1.10"
"@mantou/gem": "^1.7.11",
"duoyun-ui": "^1.1.11"
},
"devDependencies": {
"@gemjs/config": "^1.6.12",
"@gemjs/config": "^1.6.13",
"vite": "^4.5.2",
"vite-plugin-virtual-mpa": "^1.9.3"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/gem-examples/src/console/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Time } from 'duoyun-ui/lib/time';
import { ContextMenu } from 'duoyun-ui/elements/contextmenu';
import { FormItem, createForm } from 'duoyun-ui/patterns/form';
import { sleep } from 'duoyun-ui/lib/utils';
import { PaginationReq, createPaginationStore } from 'duoyun-ui/helper/store';
import { createPaginationStore } from 'duoyun-ui/helper/store';
import type { FetchEventDetail, FilterableColumn } from 'duoyun-ui/patterns/table';

import 'duoyun-ui/patterns/table';
Expand Down Expand Up @@ -204,7 +204,7 @@ export class ConsolePageItemElement extends GemElement {
});
};

#fetchList = (args: PaginationReq) => {
#fetchList = (args: FetchEventDetail) => {
return get(`https://jsonplaceholder.typicode.com/users`).then((list: Item[]) => {
list.forEach((e, i) => {
e.updated = new Time().subtract(i + 1, 'd').getTime();
Expand Down
6 changes: 3 additions & 3 deletions packages/gem-port/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gem-port",
"version": "0.0.7",
"version": "0.0.8",
"description": "Export React component",
"keywords": [
"gem",
Expand All @@ -19,9 +19,9 @@
"prepublishOnly": "yarn build"
},
"dependencies": {
"@gemjs/config": "^1.6.12",
"@gemjs/config": "^1.6.13",
"commander": "^7.2.0",
"gem-analyzer": "^1.7.7",
"gem-analyzer": "^1.7.8",
"ts-morph": "^13.0.0",
"typescript": "^4.5.0"
},
Expand Down
11 changes: 0 additions & 11 deletions packages/gem-port/src/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,6 @@ function createReactSourceFile(elementFilePath: string, outDir: string) {
};
}, []);
// React Bug
const [mounted, update] = useState(false);
useEffect(() => update(true), []);
if (!mounted) {
return <${tag}
${properties
.map(({ attribute, name }) => (attribute ? `${attribute}={props.${name}}` : ''))
.join(' ')}
></${tag}>;
}
return <${tag} ref={elementRef} {...props}></${tag}>;
})
Expand Down
4 changes: 2 additions & 2 deletions packages/gem/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mantou/gem",
"version": "1.7.10",
"version": "1.7.11",
"description": "💎 使用自定义元素的轻量级 WebApp 开发框架",
"keywords": [
"frontend",
Expand Down Expand Up @@ -44,7 +44,7 @@
},
"devDependencies": {
"@esm-bundle/chai": "^4.3.4-fix.0",
"@gemjs/config": "^1.6.12",
"@gemjs/config": "^1.6.13",
"@open-wc/testing": "^2.5.33",
"@web/dev-server-esbuild": "^0.2.16",
"@web/test-runner": "^0.13.22",
Expand Down

0 comments on commit f161fb8

Please sign in to comment.