解决 ts报错

This commit is contained in:
Wang Kejun 2022-08-20 16:02:18 +08:00
parent b1b4740db4
commit 66211f3987
11 changed files with 89 additions and 36 deletions

View File

@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var tdesign_mobile_react_1 = require("tdesign-mobile-react");
var CustomTag = tdesign_mobile_react_1.Tag;
function render() {
var t = this.t;
var _a = this.state, nickname = _a.nickname, avatar = _a.avatar, name = _a.name, mobile = _a.mobile, userState = _a.userState, idState = _a.idState, stateColor = _a.stateColor, idStateColor = _a.idStateColor, mobileCount = _a.mobileCount;
@ -17,6 +18,6 @@ function render() {
return '未设置';
}
};
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u5934\u50CF", note: avatar ? (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Avatar, { image: avatar }) : '未设置' }), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u6635\u79F0", note: nickname || '未设置' }), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u59D3\u540D", note: name || '未设置' }), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u624B\u673A\u53F7", note: getMobile() }), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u7528\u6237\u72B6\u6001", note: (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Tag, tslib_1.__assign({ theme: stateColor[userState] }, { children: t("user:v.userState.".concat(userState)) })) }), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u5B9E\u540D\u9A8C\u8BC1", note: (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Tag, tslib_1.__assign({ theme: idStateColor[idState] }, { children: t("user:v.idState.".concat(idState)) })) })] }));
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u5934\u50CF", note: avatar ? (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Avatar, { image: avatar }) : '未设置' }), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u6635\u79F0", note: nickname || '未设置' }), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u59D3\u540D", note: name || '未设置' }), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u624B\u673A\u53F7", note: getMobile() }), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u7528\u6237\u72B6\u6001", note: (0, jsx_runtime_1.jsx)(CustomTag, tslib_1.__assign({ theme: stateColor[userState], className: "", style: {} }, { children: t("user:v.userState.".concat(userState)) })) }), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { title: "\u5B9E\u540D\u9A8C\u8BC1", note: (0, jsx_runtime_1.jsx)(CustomTag, tslib_1.__assign({ theme: idStateColor[idState], className: "", style: {} }, { children: t("user:v.idState.".concat(idState)) })) })] }));
}
exports.default = render;

View File

@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var tdesign_react_1 = require("tdesign-react");
var luxon_1 = require("luxon");
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
var FormItem = tdesign_react_1.Form.FormItem;
function render() {
var _this = this;
@ -18,9 +18,9 @@ function render() {
}, value: this.state.nickname }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "\u59D3\u540D", requiredMark: true }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { onChange: function (value) {
_this.setUpdateData('name', value);
}, value: this.state.name }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "\u51FA\u751F\u65E5\u671F", requiredMark: true }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.DatePicker, { allowInput: false, clearable: false, enableTimePicker: false, mode: "date", presetsPlacement: "bottom", value: this.state.birth
? luxon_1.DateTime.fromMillis(this.state.birth).toFormat('yyyy-LL-dd')
? (0, dayjs_1.default)(this.state.birth).format('YYYY-MM-DD')
: '', onChange: function (value) {
var val = luxon_1.DateTime.fromISO(value).toMillis();
var val = (0, dayjs_1.default)(value).valueOf();
_this.setUpdateData('birth', val);
}, valueType: "YYYY-MM-DD" }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "\u6027\u522B", requiredMark: true }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Radio.Group, { options: GenderOptions, onChange: function (value) {
_this.setUpdateData('gender', value);

View File

@ -4,13 +4,14 @@ var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var tdesign_mobile_react_1 = require("tdesign-mobile-react");
var tdesign_icons_react_1 = require("tdesign-icons-react");
var CustomTag = tdesign_mobile_react_1.Tag;
function render() {
var _this = this;
var t = this.t;
var event = this.props.event;
var _a = this.state, stateColor = _a.stateColor, userArr = _a.userArr;
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ style: { height: '100vh' } }, { children: [userArr === null || userArr === void 0 ? void 0 : userArr.map(function (ele, index) {
return ((0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { onClick: function () { return _this.onCellClicked(ele.id, event); }, image: (0, jsx_runtime_1.jsx)("img", { className: "avatar", src: ele.avatar }), title: ele.name || '未设置', description: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "mobile" }, { children: ["\u624B\u673A\u53F7\uFF1A", ele.mobile || '未设置'] })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { display: 'flex' } }, { children: (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Tag, tslib_1.__assign({ theme: stateColor[ele.userState] }, { children: t("user:v.userState.".concat(ele.userState)) })) }))] }) }, index));
return ((0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { onClick: function () { return _this.onCellClicked(ele.id, event); }, image: (0, jsx_runtime_1.jsx)("img", { className: "avatar", src: ele.avatar }), title: ele.name || '未设置', description: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "mobile" }, { children: ["\u624B\u673A\u53F7\uFF1A", ele.mobile || '未设置'] })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { display: 'flex' } }, { children: (0, jsx_runtime_1.jsx)(CustomTag, tslib_1.__assign({ theme: stateColor[ele.userState], className: "", style: {} }, { children: t("user:v.userState.".concat(ele.userState)) })) }))] }) }, index));
}), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Fab, { style: {
bottom: 50,
right: 16,

View File

@ -4,6 +4,7 @@ var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var tdesign_mobile_react_1 = require("tdesign-mobile-react");
var tdesign_icons_react_1 = require("tdesign-icons-react");
var CustomTag = tdesign_mobile_react_1.Tag;
function render() {
var _this = this;
var t = this.t;
@ -13,7 +14,7 @@ function render() {
height: '100vh',
} }, { children: [users === null || users === void 0 ? void 0 : users.map(function (ele, index) {
var _a;
return ((0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { onClick: function (e) { return _this.goDetail(ele.id); }, title: ele.nickname || '未设置', image: (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Image, { src: ele.avatar, alt: "\u5934\u50CF", style: { width: 80, height: 80 } }), description: (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "description" }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "name" }, { children: ["\u59D3\u540D: ", ele.name || '未设置'] })), (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "mobile" }, { children: ["\u624B\u673A: ", ele.mobile || '未设置'] })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "relation" }, { children: (_a = ele.relations) === null || _a === void 0 ? void 0 : _a.map(function (relation, index) { return ((0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Tag, tslib_1.__assign({ variant: "outline", theme: "primary" }, { children: t("".concat(entity, ":r.").concat(relation)) }), index)); }) }))] })) }, index));
return ((0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Cell, { onClick: function (e) { return _this.goDetail(ele.id); }, title: ele.nickname || '未设置', image: (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Image, { src: ele.avatar, alt: "\u5934\u50CF", style: { width: 80, height: 80 } }), description: (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "description" }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "name" }, { children: ["\u59D3\u540D: ", ele.name || '未设置'] })), (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "mobile" }, { children: ["\u624B\u673A: ", ele.mobile || '未设置'] })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "relation" }, { children: (_a = ele.relations) === null || _a === void 0 ? void 0 : _a.map(function (relation, index) { return ((0, jsx_runtime_1.jsx)(CustomTag, tslib_1.__assign({ variant: "outline", theme: "primary", className: "", style: {} }, { children: t("".concat(entity, ":r.").concat(relation)) }), index)); }) }))] })) }, index));
}), (0, jsx_runtime_1.jsx)(tdesign_mobile_react_1.Fab, { buttonProps: {
theme: 'primary',
shape: 'circle',

View File

@ -12,7 +12,7 @@
"dependencies": {
"@fingerprintjs/fingerprintjs": "^3.3.3",
"classnames": "^2.3.1",
"moment": "^2.29.4",
"dayjs": "^1.11.5",
"oak-common-aspect": "file:../oak-common-aspect",
"oak-domain": "file:../oak-domain",
"oak-external-sdk": "file:../oak-external-sdk",
@ -70,4 +70,3 @@
},
"main": "lib/index"
}

View File

@ -1,5 +1,15 @@
import React, { Component } from 'react';
import { Cell, Tag, Avatar } from 'tdesign-mobile-react';
import { Cell, Tag, Avatar, TagProps } from 'tdesign-mobile-react';
type CustomTagProps = {
children?: any;
};
const CustomTag: React.MemoExoticComponent<
React.ForwardRefExoticComponent<
CustomTagProps & TagProps & React.RefAttributes<HTMLDivElement>
>
> = Tag;
export default function render(this: any) {
const { t } = this;
@ -36,24 +46,29 @@ export default function render(this: any) {
/>
<Cell title="昵称" note={nickname || '未设置'} />
<Cell title="姓名" note={name || '未设置'} />
<Cell
title="手机号"
note={getMobile()}
/>
<Cell title="手机号" note={getMobile()} />
<Cell
title="用户状态"
note={
<Tag theme={stateColor[userState]}>
<CustomTag
theme={stateColor[userState]}
className=""
style={{}}
>
{t(`user:v.userState.${userState}`)}
</Tag>
</CustomTag>
}
/>
<Cell
title="实名验证"
note={
<Tag theme={idStateColor[idState]}>
<CustomTag
theme={idStateColor[idState]}
className=""
style={{}}
>
{t(`user:v.idState.${idState}`)}
</Tag>
</CustomTag>
}
/>
</div>

View File

@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { Button, Checkbox, Input, Form, Radio, DatePicker, Row, Col } from 'tdesign-react';
import { DateTime } from 'luxon';
import dayjs from 'dayjs';
const { FormItem } = Form;
export default function render(this: any) {
@ -47,14 +47,13 @@ export default function render(this: any) {
presetsPlacement="bottom"
value={
this.state.birth
? DateTime.fromMillis(
this.state.birth
).toFormat('yyyy-LL-dd')
? dayjs(this.state.birth).format(
'YYYY-MM-DD'
)
: ''
}
onChange={(value) => {
const val =
DateTime.fromISO(value).toMillis();
const val = dayjs(value).valueOf();
this.setUpdateData('birth', val);
}}
valueType="YYYY-MM-DD"

View File

@ -1,7 +1,17 @@
import * as React from 'react';
import { Fab, Cell, Tag } from 'tdesign-mobile-react';
import { Fab, Cell, Tag, TagProps } from 'tdesign-mobile-react';
import { Icon } from 'tdesign-icons-react';
type CustomTagProps = {
children?: any;
};
const CustomTag: React.MemoExoticComponent<
React.ForwardRefExoticComponent<
CustomTagProps & TagProps & React.RefAttributes<HTMLDivElement>
>
> = Tag;
export default function render(this: any) {
const { t } = this;
const {
@ -24,9 +34,13 @@ export default function render(this: any) {
{ele.mobile || '未设置'}
</div>
<div style={{ display: 'flex' }}>
<Tag theme={stateColor[ele.userState]}>
<CustomTag
theme={stateColor[ele.userState]}
className=""
style={{}}
>
{t(`user:v.userState.${ele.userState}`)}
</Tag>
</CustomTag>
</div>
</div>
}

View File

@ -1,7 +1,17 @@
import * as React from 'react';
import { Cell, Image, Tag, Fab } from 'tdesign-mobile-react';
import { Cell, Image, Tag, Fab, TagProps } from 'tdesign-mobile-react';
import { Icon } from 'tdesign-icons-react';
type CustomTagProps = {
children?: any;
};
const CustomTag: React.MemoExoticComponent<
React.ForwardRefExoticComponent<
CustomTagProps & TagProps & React.RefAttributes<HTMLDivElement>
>
> = Tag;
export default function render(this: any) {
const { t } = this;
const { entity } = this.props;
@ -34,15 +44,19 @@ export default function render(this: any) {
: {ele.mobile || '未设置'}
</div>
<div className="relation">
{ele.relations?.map((relation: string, index: number) => (
<Tag
key={index}
variant="outline"
theme="primary"
>
{t(`${entity}:r.${relation}`)}
</Tag>
))}
{ele.relations?.map(
(relation: string, index: number) => (
<CustomTag
key={index}
variant="outline"
theme="primary"
className=""
style={{}}
>
{t(`${entity}:r.${relation}`)}
</CustomTag>
)
)}
</div>
</div>
}

8
src/typings/react.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
declare module '*.module.less' {
const classes: {
readonly [key: string]: string;
};
export default classes;
}

1
src/typings/wechat.d.ts vendored Normal file
View File

@ -0,0 +1 @@
declare let WeixinJSBridge: any;