Merge branch 'dev' into release

This commit is contained in:
Xu Chang 2024-04-30 12:32:14 +08:00
commit c9ad0bd331
28 changed files with 122 additions and 127 deletions

View File

@ -15,7 +15,7 @@ export default OakComponent({
moreItems: [],
},
lifetimes: {
// 在Tabel组件render之后 才走进这个组件,应该不会存在没有数据的问题
// 在Table组件render之后 才走进这个组件,应该不会存在没有数据的问题
async ready() {
const schema = this.features.cache.getSchema();
// 小程序这里还要跑一下
@ -27,6 +27,17 @@ export default OakComponent({
});
},
},
listeners: {
actions(prev, next) {
if ((prev.actions && !next.actions) ||
(!prev.actions && next.actions) ||
(prev.actions &&
next.actions &&
prev.actions.length !== next.actions.length)) {
this.makeItems();
}
}
},
methods: {
makeItems(isMobile) {
const { schema } = this.state;
@ -40,10 +51,10 @@ export default OakComponent({
column = 2;
}
if (extraActions?.length || actions?.length) {
const actions2 = (actions && [...actions]) || [];
const actions2 = [...(actions || [])];
if (extraActions) {
// 用户传的action默认排在前面
const extraActions2 = extraActions.filter((ele) => ele.show) || [];
const extraActions2 = extraActions.filter((ele) => ele.show);
actions2.unshift(...extraActions2);
}
// 每一项里的action 和 path 用在小程序这边, onClick用于web

View File

@ -1,9 +1,9 @@
export default OakComponent({
isList: false,
data: {
slideWidth: 0, //小程序使用
slideLeft: 0, //小程序使用
slideShow: false, //小程序使用
slideWidth: 0,
slideLeft: 0,
slideShow: false,
commonAction: [
'create',
'update',

View File

@ -61,7 +61,7 @@ export default OakComponent({
let currentUrl = event.currentTarget.dataset.src;
let urlList = event.currentTarget.dataset.list;
wx.previewImage({
current: currentUrl, // 当前显示图片的http链接
current: currentUrl,
urls: urlList, // 需要预览的图片http链接列表
});
},

View File

@ -37,7 +37,7 @@ export default OakComponent({
code: '',
title: '',
desc: '',
icon: '', //web独有
icon: '',
imagePath: '', //小程序独有
},
lifetimes: {

View File

@ -90,7 +90,7 @@ export default OakComponent({
attribute: {},
options: [],
inputType: '',
timeStartStr: '', // 小程序选择时间显示
timeStartStr: '',
timeEndStr: '',
selectedLabel: '',
minDateMp: new Date(1980, 1, 1).getTime(),

View File

@ -10,17 +10,16 @@ declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactCompo
data: RowWithActions<ED2, T2>[];
loading: boolean;
tablePagination?: false | import("antd").TablePaginationConfig | undefined;
rowSelection?: {
type: 'checkbox' | 'radio';
selectedRowKeys?: string[] | undefined;
onChange: (selectedRowKeys: string[], row: RowWithActions<ED2, T2>[], info?: {
type: 'single' | 'multiple' | 'none';
}) => void;
} | undefined;
rowSelection?: import("antd/es/table/interface").TableRowSelection<RowWithActions<ED2, T2>> | undefined;
hideHeader?: boolean | undefined;
disableSerialNumber?: boolean | undefined;
size?: "small" | "large" | "middle" | undefined;
scroll?: TableProps<RowWithActions<ED, keyof ED>[]>['scroll'];
locale?: TableProps<RowWithActions<ED, keyof ED>[]>['locale'];
scroll?: ({
x?: string | number | true | undefined;
y?: string | number | undefined;
} & {
scrollToFirstRowOnChange?: boolean | undefined;
}) | undefined;
locale?: import("antd/es/table/interface").TableLocale | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -13,7 +13,7 @@ export default OakComponent({
tablePagination: undefined,
rowSelection: undefined,
hideHeader: false,
disableSerialNumber: false, //是否禁用序号 默认启用
disableSerialNumber: false,
size: 'large',
scroll: undefined,
locale: undefined,

View File

@ -18,7 +18,7 @@ export default function Render(props: WebComponentProps<ED, keyof ED, false, {
rowSelection?: {
type: 'checkbox' | 'radio';
selectedRowKeys?: React.Key[];
onChange: (selectedRowKeys: React.Key[], row: RowWithActions<ED, keyof ED>[], info?: {
onChange: (selectedRowKeys: React.Key[], rows: RowWithActions<ED, keyof ED>[], info?: {
type: 'single' | 'multiple' | 'none';
}) => void;
};

View File

@ -2,25 +2,25 @@ import React from 'react';
import { TableProps } from 'antd';
import { StorageSchema } from 'oak-domain/lib/types/Storage';
import { OakAbsAttrDef, onActionFnDef, OakExtraActionProps, OakAbsAttrJudgeDef, ED } from '../../types/AbstractComponent';
import { WebComponentProps } from '../../types/Page';
import { WebComponentProps, RowWithActions } from '../../types/Page';
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
loading: boolean;
extraActions: OakExtraActionProps[] | ((row: any) => OakExtraActionProps[]);
extraActions: OakExtraActionProps[] | ((row: RowWithActions<ED, keyof ED>) => OakExtraActionProps[]);
entity: string;
schema: StorageSchema<ED>;
attributes: OakAbsAttrDef[];
data: any[];
data: RowWithActions<ED, keyof ED>[];
disabledOp: boolean;
tablePagination?: TableProps<any[]>['pagination'];
tablePagination?: TableProps<RowWithActions<ED, keyof ED>>['pagination'];
onAction?: onActionFnDef;
rowSelection?: TableProps<any[]>['rowSelection'];
rowSelection?: TableProps<RowWithActions<ED, keyof ED>>['rowSelection'];
i18n: any;
hideHeader?: boolean;
disableSerialNumber?: boolean;
judgeAttributes: OakAbsAttrJudgeDef[];
size?: 'large' | 'middle' | 'small';
scroll?: TableProps<any[]>['scroll'];
locale?: TableProps<any[]>['locale'];
scroll?: TableProps<RowWithActions<ED, keyof ED>>['scroll'];
locale?: TableProps<RowWithActions<ED, keyof ED>>['locale'];
}, {
getColor: (attr: string, value: any) => `#${string}` | undefined;
}>): React.JSX.Element;

View File

@ -16,18 +16,12 @@ type Props<ED2 extends ED, T extends keyof ED2> = {
attributes: OakAbsAttrDef[];
data: RowWithActions<ED2, T>[];
loading?: boolean;
tablePagination?: TableProps<RowWithActions<ED2, T>[]>['pagination'];
rowSelection?: {
type: 'checkbox' | 'radio';
selectedRowKeys?: string[];
onChange: (selectedRowKeys: string[], row: RowWithActions<ED2, T>[], info?: {
type: 'single' | 'multiple' | 'none';
}) => void;
};
tablePagination?: TableProps<RowWithActions<ED2, T>>['pagination'];
rowSelection?: TableProps<RowWithActions<ED2, T>>['rowSelection'];
disableSerialNumber?: boolean;
size?: 'large' | 'middle' | 'small';
scroll?: TableProps<RowWithActions<ED2, T>[]>['scroll'];
locale?: TableProps<RowWithActions<ED2, T>[]>['locale'];
scroll?: TableProps<RowWithActions<ED2, T>>['scroll'];
locale?: TableProps<RowWithActions<ED2, T>>['locale'];
};
export type TableAttributeType = {
attribute: OakAbsAttrJudgeDef;

View File

@ -9,7 +9,7 @@ export default OakComponent({
multiple: false,
entityId: '',
entityIds: [],
pickerRender: {}, // OakAbsRefAttrPickerRender
pickerRender: {},
onChange: (() => undefined),
},
formData() {

View File

@ -5,7 +5,7 @@ export default OakComponent({
return this.props.entity;
},
properties: {
helps: {}, // Record<string, string>;
helps: {},
entity: '',
attributes: [],
layout: 'horizontal',

View File

@ -349,7 +349,7 @@ export class Cache extends Feature {
opers.forEach((oper) => {
const { entity, operation } = oper;
this.cacheStore.operate(entity, operation, this.context, {
checkerTypes: ['logical'], // 这里不能检查data不然在数据没填完前会有大量异常
checkerTypes: ['logical'],
dontCollect: true,
});
});

View File

@ -797,7 +797,7 @@ class ListNode extends Node {
async loadMore() {
const { filters, sorters, pagination, entity } = this;
const { pageSize, more, currentPage, count } = pagination;
if (!more || this.loadingMore) {
if (!more || this.loadingMore || this.loading || !count) {
return;
}
// 要根据total来计算下一页

View File

@ -1,7 +1,7 @@
import React from 'react';
export const keys = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
export const values = {
xs: 576, //小于576
xs: 576,
sm: 576,
md: 768,
lg: 992,

View File

@ -7,14 +7,14 @@ import { pick } from 'oak-domain/lib/utils/lodash';
export async function getEnv() {
const fp = await FingerprintJS.load();
// 有浏览器没有storage
const [result /* , localStorageEnabled */] = await Promise.all([fp.get() /* , navigator.storage.persisted() */]);
const { visitorId, components } = result;
const fullEnv = Object.assign(pick(components, [
'platform',
'timezone',
'vendor',
'vendorFlavors'
]), {
const [result /* , localStorageEnabled */] = await Promise.all([
fp.get() /* , navigator.storage.persisted() */,
]);
const { components } = result;
const fields = ['platform', 'timezone', 'vendor', 'vendorFlavors'];
const extendedComponents = pick(components, fields.concat('osCpu'));
const visitorId = FingerprintJS.hashComponents(extendedComponents);
const fullEnv = Object.assign(pick(components, fields), {
type: 'web',
visitorId,
// localStorageEnabled,

View File

@ -352,7 +352,7 @@ class Cache extends Feature_1.Feature {
opers.forEach((oper) => {
const { entity, operation } = oper;
this.cacheStore.operate(entity, operation, this.context, {
checkerTypes: ['logical'], // 这里不能检查data不然在数据没填完前会有大量异常
checkerTypes: ['logical'],
dontCollect: true,
});
});

View File

@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
exports.keys = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
exports.values = {
xs: 576, //小于576
xs: 576,
sm: 576,
md: 768,
lg: 992,

View File

@ -11,14 +11,14 @@ const lodash_1 = require("oak-domain/lib/utils/lodash");
async function getEnv() {
const fp = await fingerprintjs_1.default.load();
// 有浏览器没有storage
const [result /* , localStorageEnabled */] = await Promise.all([fp.get() /* , navigator.storage.persisted() */]);
const { visitorId, components } = result;
const fullEnv = Object.assign((0, lodash_1.pick)(components, [
'platform',
'timezone',
'vendor',
'vendorFlavors'
]), {
const [result /* , localStorageEnabled */] = await Promise.all([
fp.get() /* , navigator.storage.persisted() */,
]);
const { components } = result;
const fields = ['platform', 'timezone', 'vendor', 'vendorFlavors'];
const extendedComponents = (0, lodash_1.pick)(components, fields.concat('osCpu'));
const visitorId = fingerprintjs_1.default.hashComponents(extendedComponents);
const fullEnv = Object.assign((0, lodash_1.pick)(components, fields), {
type: 'web',
visitorId,
// localStorageEnabled,

View File

@ -1,6 +1,6 @@
{
"name": "oak-frontend-base",
"version": "5.0.2",
"version": "5.0.3",
"description": "oak框架中前端与业务逻辑无关的平台部分",
"author": {
"name": "XuChang"
@ -22,7 +22,7 @@
"i18n-js": "^4.3.0",
"node-schedule": "^2.1.1",
"oak-common-aspect": "^3.0.0",
"oak-domain": "^5.0.2",
"oak-domain": "^5.0.3",
"oak-memory-tree-store": "^3.3.0",
"ol": "^7.3.0",
"react-native-device-info": "^10.12.0",

View File

@ -3,6 +3,7 @@ import { ED, OakExtraActionProps } from '../../types/AbstractComponent';
import { resolvePath } from '../../utils/usefulFn';
import { StorageSchema } from 'oak-domain/lib/types/Storage';
import { ActionDef } from '../../types/Page';
import { actions } from 'oak-domain/lib/base-app-domain/User/Action';
export default OakComponent({
isList: false,
@ -32,7 +33,7 @@ export default OakComponent({
}[],
},
lifetimes: {
// 在Tabel组件render之后 才走进这个组件,应该不会存在没有数据的问题
// 在Table组件render之后 才走进这个组件,应该不会存在没有数据的问题
async ready() {
const schema = this.features.cache.getSchema();
// 小程序这里还要跑一下
@ -44,6 +45,19 @@ export default OakComponent({
});
},
},
listeners: {
actions(prev, next) {
if (
(prev.actions && !next.actions) ||
(!prev.actions && next.actions) ||
(prev.actions &&
next.actions &&
prev.actions.length !== next.actions.length)
) {
this.makeItems();
}
}
},
methods: {
makeItems(isMobile?: boolean) {
const { schema } = this.state;
@ -58,11 +72,10 @@ export default OakComponent({
column = 2;
}
if (extraActions?.length || actions?.length) {
const actions2 = (actions && [...actions]) || [];
const actions2 = [...(actions || [])];
if (extraActions) {
// 用户传的action默认排在前面
const extraActions2 =
extraActions.filter((ele) => ele.show) || [];
const extraActions2 = extraActions.filter((ele) => ele.show);
actions2.unshift(...extraActions2);
}

View File

@ -81,8 +81,7 @@ export default function Render(
i18n,
extraActions,
} = data;
const zhCNKeys: number =
i18n?.store?.data?.zh_CN && Object.keys(i18n.store.data.zh_CN).length;
const zhCNKeys: number = i18n?.store?.data?.zh_CN && Object.keys(i18n.store.data.zh_CN).length;
useEffect(() => {
makeItems();
}, [zhCNKeys, actions, cascadeActions, extraActions]);

View File

@ -17,27 +17,19 @@ export default OakComponent({
data: [] as RowWithActions<ED, keyof ED>[],
loading: false,
tablePagination: undefined as
| TableProps<RowWithActions<ED, keyof ED>[]>['pagination']
| TableProps<RowWithActions<ED, keyof ED>>['pagination']
| undefined,
rowSelection: undefined as
| {
type: 'checkbox' | 'radio';
selectedRowKeys?: string[];
onChange: (
selectedRowKeys: string[],
selectedRows: RowWithActions<ED, keyof ED>[],
info?: { type: 'single' | 'multiple' | 'none' }
) => void;
}
| TableProps<RowWithActions<ED, keyof ED>>['rowSelection']
| undefined,
hideHeader: false,
disableSerialNumber: false, //是否禁用序号 默认启用
size: 'large',
scroll: undefined as
| TableProps<RowWithActions<ED, keyof ED>[]>['scroll']
| TableProps<RowWithActions<ED, keyof ED>>['scroll']
| undefined,
locale: undefined as
| TableProps<RowWithActions<ED, keyof ED>[]>['locale']
| TableProps<RowWithActions<ED, keyof ED>>['locale']
| undefined,
},
formData({ props }) {
@ -121,23 +113,13 @@ export default OakComponent({
attributes: OakAbsAttrDef[];
data: RowWithActions<ED2, T2>[];
loading: boolean;
tablePagination?: TableProps<
RowWithActions<ED2, T2>[]
>['pagination'];
rowSelection?: {
type: 'checkbox' | 'radio';
selectedRowKeys?: string[];
onChange: (
selectedRowKeys: string[],
row: RowWithActions<ED2, T2>[],
info?: { type: 'single' | 'multiple' | 'none' }
) => void;
};
tablePagination?: TableProps<RowWithActions<ED2, T2>>['pagination'];
rowSelection?: TableProps<RowWithActions<ED2, T2>>['rowSelection'];
hideHeader?: boolean;
disableSerialNumber?: boolean; //是否禁用序号 默认启用
size?: 'large' | 'middle' | 'small';
scroll?: TableProps<RowWithActions<ED, keyof ED>[]>['scroll'];
locale?: TableProps<RowWithActions<ED, keyof ED>[]>['locale'];
scroll?: TableProps<RowWithActions<ED2, T2>>['scroll'];
locale?: TableProps<RowWithActions<ED2, T2>>['locale'];
}
>
) => React.ReactElement;

View File

@ -7,7 +7,7 @@ import { get } from 'oak-domain/lib/utils/lodash';
import { StorageSchema } from 'oak-domain/lib/types/Storage';
import { OakAbsAttrDef, onActionFnDef, CascadeActionProps, OakAbsDerivedAttrDef, OakExtraActionProps, OakAbsAttrJudgeDef, ED } from '../../types/AbstractComponent';
import { getPath, getWidth, getValue, getLabel, resolvePath, getType, getAlign, getLinkUrl, getFixed } from '../../utils/usefulFn';
import { WebComponentProps } from '../../types/Page';
import { WebComponentProps, RowWithActions } from '../../types/Page';
import ActionBtn from '../actionBtn';
import TableCell from './renderCell';
import { TableContext } from '../listPro';
@ -23,22 +23,26 @@ export default function Render(
loading: boolean;
extraActions:
| OakExtraActionProps[]
| ((row: any) => OakExtraActionProps[]);
| ((row: RowWithActions<ED, keyof ED>) => OakExtraActionProps[]);
entity: string;
schema: StorageSchema<ED>;
attributes: OakAbsAttrDef[];
data: any[];
data: RowWithActions<ED, keyof ED>[];
disabledOp: boolean;
tablePagination?: TableProps<any[]>['pagination'];
tablePagination?: TableProps<
RowWithActions<ED, keyof ED>
>['pagination'];
onAction?: onActionFnDef;
rowSelection?: TableProps<any[]>['rowSelection'];
rowSelection?: TableProps<
RowWithActions<ED, keyof ED>
>['rowSelection'];
i18n: any;
hideHeader?: boolean;
disableSerialNumber?: boolean; //是否禁用序号 默认启用
judgeAttributes: OakAbsAttrJudgeDef[];
size?: 'large' | 'middle' | 'small';
scroll?: TableProps<any[]>['scroll'];
locale?: TableProps<any[]>['locale'];
scroll?: TableProps<RowWithActions<ED, keyof ED>>['scroll'];
locale?: TableProps<RowWithActions<ED, keyof ED>>['locale'];
},
{
getColor: (attr: string, value: any) => `#${string}` | undefined;
@ -284,7 +288,7 @@ export default function Render(
} else {
keys = [record.id];
}
const row = data.filter((ele) => keys.includes(ele.id));
const row = data.filter((ele) => keys.includes(ele.id as React.Key));
rowSelection?.onChange &&
rowSelection?.onChange(keys, row, { type: 'all' });
},

View File

@ -32,7 +32,7 @@ export default function Render(
selectedRowKeys?: React.Key[];
onChange: (
selectedRowKeys: React.Key[],
row: RowWithActions<ED, keyof ED>[],
rows: RowWithActions<ED, keyof ED>[],
info?: { type: 'single' | 'multiple' | 'none' }
) => void;
};

View File

@ -32,20 +32,12 @@ type Props<ED2 extends ED, T extends keyof ED2> = {
attributes: OakAbsAttrDef[];
data: RowWithActions<ED2, T>[];
loading?: boolean;
tablePagination?: TableProps<RowWithActions<ED2, T>[]>['pagination'];
rowSelection?: {
type: 'checkbox' | 'radio';
selectedRowKeys?: string[];
onChange: (
selectedRowKeys: string[],
row: RowWithActions<ED2, T>[],
info?: { type: 'single' | 'multiple' | 'none' }
) => void;
};
tablePagination?: TableProps<RowWithActions<ED2, T>>['pagination'];
rowSelection?: TableProps<RowWithActions<ED2, T>>['rowSelection'];
disableSerialNumber?: boolean; //是否禁用序号 默认启用
size?: 'large' | 'middle' | 'small';
scroll?: TableProps<RowWithActions<ED2, T>[]>['scroll'];
locale?: TableProps<RowWithActions<ED2, T>[]>['locale'];
scroll?: TableProps<RowWithActions<ED2, T>>['scroll'];
locale?: TableProps<RowWithActions<ED2, T>>['locale'];
};
export type TableAttributeType = {

View File

@ -980,7 +980,7 @@ class ListNode<
async loadMore() {
const { filters, sorters, pagination, entity } = this;
const { pageSize, more, currentPage, count } = pagination;
if (!more || this.loadingMore) {
if (!more || this.loadingMore || this.loading || !count) {
return;
}
// 要根据total来计算下一页

View File

@ -4,27 +4,28 @@ import { WebEnv, BriefEnv } from 'oak-domain/lib/types/Environment';
/**
* fingerprintJs当中的一些敏感项
* @returns
* @returns
*/
export async function getEnv() {
const fp = await FingerprintJS.load();
// 有浏览器没有storage
const [result/* , localStorageEnabled */] = await Promise.all([fp.get()/* , navigator.storage.persisted() */]);
const [result /* , localStorageEnabled */] = await Promise.all([
fp.get() /* , navigator.storage.persisted() */,
]);
const { visitorId, components } = result;
const fullEnv = Object.assign(
pick(components, [
'platform',
'timezone',
'vendor',
'vendorFlavors'
]), {
const { components } = result;
const fields = ['platform', 'timezone', 'vendor', 'vendorFlavors'];
const extendedComponents = pick(components, fields.concat('osCpu'));
const visitorId = FingerprintJS.hashComponents(extendedComponents);
const fullEnv = Object.assign(pick(components, fields), {
type: 'web',
visitorId,
// localStorageEnabled,
language: navigator.language,
}) as unknown as WebEnv;
const briefEnv: BriefEnv = {
system: `${fullEnv.platform.value}`,
explorer: `${fullEnv.vendor.value}/${fullEnv.vendorFlavors.value[0]}`,