@lobehub/ui 1.49.1 → 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/ChatItem/index.js +6 -5
- package/es/ChatItem/style.d.ts +2 -0
- package/es/ChatItem/style.js +8 -6
- package/es/ChatList/ActionsBar.js +1 -5
- package/es/ChatList/index.d.ts +10 -1
- package/es/ChatList/index.js +70 -26
- package/es/EditableMessage/index.d.ts +1 -0
- package/es/EditableMessage/index.js +4 -1
- package/es/MessageInput/index.d.ts +1 -0
- package/es/MessageInput/index.js +5 -1
- package/es/utils/formatTime.js +3 -3
- package/package.json +1 -1
package/es/ChatItem/index.js
CHANGED
|
@@ -79,16 +79,17 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
79
79
|
className: styles.alert,
|
|
80
80
|
showIcon: true
|
|
81
81
|
}, alert)) : /*#__PURE__*/_jsxs(Flexbox, {
|
|
82
|
-
className: styles.message,
|
|
83
|
-
style: editing ? {
|
|
84
|
-
padding: 12
|
|
85
|
-
} : {},
|
|
82
|
+
className: cx(styles.message, editing && styles.editingContainer),
|
|
86
83
|
children: [/*#__PURE__*/_jsx(EditableMessage, {
|
|
84
|
+
classNames: {
|
|
85
|
+
input: styles.editingInput
|
|
86
|
+
},
|
|
87
|
+
editButtonSize: 'small',
|
|
87
88
|
editing: editing,
|
|
88
89
|
onChange: onChange,
|
|
89
90
|
onEditingChange: onEditingChange,
|
|
90
91
|
value: String(message || '...')
|
|
91
|
-
}), messageExtra ? /*#__PURE__*/_jsx("div", {
|
|
92
|
+
}), messageExtra && !editing ? /*#__PURE__*/_jsx("div", {
|
|
92
93
|
className: styles.messageExtra,
|
|
93
94
|
children: messageExtra
|
|
94
95
|
}) : null]
|
package/es/ChatItem/style.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export declare const useStyles: (props?: {
|
|
|
10
10
|
alert: import("antd-style").SerializedStyles;
|
|
11
11
|
avatarContainer: import("antd-style").SerializedStyles;
|
|
12
12
|
container: string;
|
|
13
|
+
editingContainer: import("antd-style").SerializedStyles;
|
|
14
|
+
editingInput: import("antd-style").SerializedStyles;
|
|
13
15
|
loading: import("antd-style").SerializedStyles;
|
|
14
16
|
message: string;
|
|
15
17
|
messageContainer: import("antd-style").SerializedStyles;
|
package/es/ChatItem/style.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14;
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
import { rgba } from 'polished';
|
|
5
5
|
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
@@ -22,11 +22,13 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
22
22
|
alert: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n span[role='img'] {\n align-self: flex-start;\n width: 16px;\n height: 16px;\n margin-top: 3px;\n }\n\n .ant-alert-description {\n text-align: justify;\n word-break: break-all;\n word-wrap: break-word;\n }\n\n &.ant-alert-with-description {\n padding-block: 12px;\n padding-inline: 12px;\n\n .ant-alert-message {\n font-size: 14px;\n font-weight: 600;\n text-align: justify;\n word-break: break-all;\n word-wrap: break-word;\n }\n }\n "]))),
|
|
23
23
|
avatarContainer: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n flex: none;\n width: ", "px;\n height: ", "px;\n "])), avatarSize, avatarSize),
|
|
24
24
|
container: cx(type === 'pure' && pureContainerStylish, css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: ", ";\n gap: 12px;\n align-items: flex-start;\n justify-content: revert;\n\n width: 100%;\n padding: 12px;\n\n time {\n display: inline-block;\n white-space: nowrap;\n }\n\n div[role='chat-item-actions'] {\n display: flex;\n }\n\n time,\n div[role='chat-item-actions'] {\n pointer-events: none;\n opacity: 0;\n transition: opacity 200ms ", ";\n }\n\n &:hover {\n time,\n div[role='chat-item-actions'] {\n pointer-events: unset;\n opacity: 1;\n }\n }\n "])), placement === 'left' ? 'row' : 'row-reverse', token.motionEaseOut)),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
editingContainer: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n padding-block: 8px;\n border: 1px solid ", ";\n\n &:active,\n &:hover {\n border-color: ", ";\n }\n "])), token.colorPrimaryBorder, token.colorPrimary),
|
|
26
|
+
editingInput: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n min-height: 80px;\n "]))),
|
|
27
|
+
loading: css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: absolute;\n right: ", ";\n bottom: 0;\n left: ", ";\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 16px;\n height: 16px;\n\n color: ", ";\n\n background: ", ";\n border-radius: 50%;\n "])), placement === 'left' ? '-4px' : 'unset', placement === 'right' ? '-4px' : 'unset', token.colorBgLayout, token.colorPrimary),
|
|
28
|
+
message: cx(typeStylish, css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n position: relative;\n "])))),
|
|
29
|
+
messageContainer: css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: ", ";\n "])), placement === 'left' ? 'flex-start' : 'flex-end'),
|
|
30
|
+
messageContent: css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n position: revert;\n\n display: flex;\n flex-direction: ", ";\n gap: 8px;\n align-items: ", ";\n "])), type === 'block' ? placement === 'left' ? 'row' : 'row-reverse' : 'column', placement === 'left' ? 'flex-start' : 'flex-end'),
|
|
29
31
|
messageExtra: cx('message-extra'),
|
|
30
|
-
name: css(
|
|
32
|
+
name: css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n position: ", ";\n top: ", ";\n right: ", ";\n left: ", ";\n\n display: flex;\n flex-direction: ", ";\n gap: 4px;\n\n margin-bottom: 6px;\n\n font-size: 12px;\n line-height: 1;\n color: ", ";\n text-align: ", ";\n "])), showTitle ? 'relative' : 'absolute', showTitle ? 'unset' : '-16px', placement === 'right' ? '0' : 'unset', placement === 'left' ? '0' : 'unset', placement === 'left' ? 'row' : 'row-reverse', token.colorTextDescription, placement === 'left' ? 'left' : 'right')
|
|
31
33
|
};
|
|
32
34
|
});
|
|
@@ -16,11 +16,7 @@ var ActionsBar = /*#__PURE__*/memo(function (_ref) {
|
|
|
16
16
|
dropdownMenu = _ref$dropdownMenu === void 0 ? [] : _ref$dropdownMenu,
|
|
17
17
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
18
18
|
var groupItems = useMemo(function () {
|
|
19
|
-
return [
|
|
20
|
-
icon: Edit,
|
|
21
|
-
key: 'edit',
|
|
22
|
-
label: 'Edit'
|
|
23
|
-
} : {
|
|
19
|
+
return [{
|
|
24
20
|
icon: RotateCw,
|
|
25
21
|
key: 'regenerate',
|
|
26
22
|
label: 'Regenerate'
|
package/es/ChatList/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { ChatItemProps } from "../ChatItem";
|
|
3
3
|
import type { DivProps } from "../types";
|
|
4
4
|
import { ChatMessage } from "../types/chatMessage";
|
|
5
|
+
declare type MessageExtra = (props: ChatMessage) => ReactNode;
|
|
5
6
|
export interface ChatListProps extends DivProps {
|
|
6
7
|
/**
|
|
7
8
|
* @description Data of chat messages to be displayed
|
|
@@ -13,7 +14,8 @@ export interface ChatListProps extends DivProps {
|
|
|
13
14
|
* @param {string} messageId - The id of the message
|
|
14
15
|
*/
|
|
15
16
|
onActionClick?: (actionKey: string, messageId: string) => void;
|
|
16
|
-
|
|
17
|
+
onMessageChange?: (id: string, content: string) => void;
|
|
18
|
+
renderMessageExtra?: MessageExtra;
|
|
17
19
|
/**
|
|
18
20
|
* @description Whether to show name of the chat item
|
|
19
21
|
* @default false
|
|
@@ -25,5 +27,12 @@ export interface ChatListProps extends DivProps {
|
|
|
25
27
|
*/
|
|
26
28
|
type?: 'docs' | 'chat';
|
|
27
29
|
}
|
|
30
|
+
export interface ItemProps extends ChatMessage {
|
|
31
|
+
MessageExtra?: MessageExtra;
|
|
32
|
+
onActionClick?: (actionKey: string, messageId: string) => void;
|
|
33
|
+
onMessageChange?: (id: string, content: string) => void;
|
|
34
|
+
showTitle?: boolean;
|
|
35
|
+
type: 'docs' | 'chat';
|
|
36
|
+
}
|
|
28
37
|
declare const ChatList: import("react").NamedExoticComponent<ChatListProps>;
|
|
29
38
|
export default ChatList;
|
package/es/ChatList/index.js
CHANGED
|
@@ -1,22 +1,76 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["
|
|
4
|
+
var _excluded = ["MessageExtra", "showTitle", "onActionClick", "onMessageChange", "type"],
|
|
5
|
+
_excluded2 = ["onActionClick", "renderMessageExtra", "className", "data", "type", "showTitle", "onMessageChange"];
|
|
4
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
import {
|
|
8
|
+
import { App } from 'antd';
|
|
9
|
+
import copy from 'copy-to-clipboard';
|
|
10
|
+
import { memo, useState } from 'react';
|
|
7
11
|
import ChatItem from "../ChatItem";
|
|
8
12
|
import ActionsBar from "./ActionsBar";
|
|
9
13
|
import { useStyles } from "./style";
|
|
10
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
MessageExtra = _ref.renderMessageExtra,
|
|
14
|
-
className = _ref.className,
|
|
15
|
-
data = _ref.data,
|
|
16
|
-
_ref$type = _ref.type,
|
|
17
|
-
type = _ref$type === void 0 ? 'chat' : _ref$type,
|
|
15
|
+
var Item = function Item(_ref) {
|
|
16
|
+
var MessageExtra = _ref.MessageExtra,
|
|
18
17
|
showTitle = _ref.showTitle,
|
|
19
|
-
|
|
18
|
+
_onActionClick = _ref.onActionClick,
|
|
19
|
+
onMessageChange = _ref.onMessageChange,
|
|
20
|
+
type = _ref.type,
|
|
21
|
+
item = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
+
var renderMessageExtra = MessageExtra ? /*#__PURE__*/_jsx(MessageExtra, _objectSpread({}, item)) : undefined;
|
|
23
|
+
var _useState = useState(false),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
editing = _useState2[0],
|
|
26
|
+
setEditing = _useState2[1];
|
|
27
|
+
var _App$useApp = App.useApp(),
|
|
28
|
+
message = _App$useApp.message;
|
|
29
|
+
return /*#__PURE__*/_jsx(ChatItem, {
|
|
30
|
+
actions: /*#__PURE__*/_jsx(ActionsBar, {
|
|
31
|
+
onActionClick: function onActionClick(actionKey) {
|
|
32
|
+
switch (actionKey) {
|
|
33
|
+
case 'copy':
|
|
34
|
+
{
|
|
35
|
+
copy(item.content);
|
|
36
|
+
message.success('复制成功');
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case 'edit':
|
|
40
|
+
{
|
|
41
|
+
console.log('editing');
|
|
42
|
+
setEditing(true);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
_onActionClick === null || _onActionClick === void 0 ? void 0 : _onActionClick(actionKey, item.id);
|
|
46
|
+
},
|
|
47
|
+
primary: item.role === 'user'
|
|
48
|
+
}),
|
|
49
|
+
avatar: item.meta,
|
|
50
|
+
editing: editing,
|
|
51
|
+
message: item.content,
|
|
52
|
+
messageExtra: renderMessageExtra,
|
|
53
|
+
onChange: function onChange(value) {
|
|
54
|
+
onMessageChange === null || onMessageChange === void 0 ? void 0 : onMessageChange(item.id, value);
|
|
55
|
+
},
|
|
56
|
+
onEditingChange: setEditing,
|
|
57
|
+
placement: type === 'chat' ? item.role === 'user' ? 'right' : 'left' : 'left',
|
|
58
|
+
primary: item.role === 'user',
|
|
59
|
+
showTitle: showTitle,
|
|
60
|
+
time: item.updateAt || item.createAt,
|
|
61
|
+
type: type === 'chat' ? 'block' : 'pure'
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
var ChatList = /*#__PURE__*/memo(function (_ref2) {
|
|
65
|
+
var onActionClick = _ref2.onActionClick,
|
|
66
|
+
MessageExtra = _ref2.renderMessageExtra,
|
|
67
|
+
className = _ref2.className,
|
|
68
|
+
data = _ref2.data,
|
|
69
|
+
_ref2$type = _ref2.type,
|
|
70
|
+
type = _ref2$type === void 0 ? 'chat' : _ref2$type,
|
|
71
|
+
showTitle = _ref2.showTitle,
|
|
72
|
+
onMessageChange = _ref2.onMessageChange,
|
|
73
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
20
74
|
var _useStyles = useStyles(),
|
|
21
75
|
cx = _useStyles.cx,
|
|
22
76
|
styles = _useStyles.styles;
|
|
@@ -24,23 +78,13 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
|
24
78
|
className: cx(styles.container, className)
|
|
25
79
|
}, props), {}, {
|
|
26
80
|
children: data.map(function (item) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return onActionClick === null || onActionClick === void 0 ? void 0 : onActionClick(actionKey, item.id);
|
|
32
|
-
} : undefined,
|
|
33
|
-
primary: item.role === 'user'
|
|
34
|
-
}),
|
|
35
|
-
avatar: item.meta,
|
|
36
|
-
message: item.content,
|
|
37
|
-
messageExtra: renderMessageExtra,
|
|
38
|
-
placement: type === 'chat' ? item.role === 'user' ? 'right' : 'left' : 'left',
|
|
39
|
-
primary: item.role === 'user',
|
|
81
|
+
return /*#__PURE__*/_jsx(Item, _objectSpread({
|
|
82
|
+
MessageExtra: MessageExtra,
|
|
83
|
+
onActionClick: onActionClick,
|
|
84
|
+
onMessageChange: onMessageChange,
|
|
40
85
|
showTitle: showTitle,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, item.id);
|
|
86
|
+
type: type
|
|
87
|
+
}, item), item.id);
|
|
44
88
|
})
|
|
45
89
|
}));
|
|
46
90
|
});
|
|
@@ -20,7 +20,8 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
20
20
|
placeholder = _ref$placeholder === void 0 ? 'Type something...' : _ref$placeholder,
|
|
21
21
|
_ref$showEditWhenEmpt = _ref.showEditWhenEmpty,
|
|
22
22
|
showEditWhenEmpty = _ref$showEditWhenEmpt === void 0 ? false : _ref$showEditWhenEmpt,
|
|
23
|
-
styles = _ref.styles
|
|
23
|
+
styles = _ref.styles,
|
|
24
|
+
editButtonSize = _ref.editButtonSize;
|
|
24
25
|
var _useControlledState = useControlledState(false, {
|
|
25
26
|
onChange: onEditingChange,
|
|
26
27
|
value: editing
|
|
@@ -38,6 +39,7 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
38
39
|
return !value && showEditWhenEmpty ? /*#__PURE__*/_jsx(MessageInput, {
|
|
39
40
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.input,
|
|
40
41
|
defaultValue: value,
|
|
42
|
+
editButtonSize: editButtonSize,
|
|
41
43
|
onCancel: function onCancel() {
|
|
42
44
|
return setTyping(false);
|
|
43
45
|
},
|
|
@@ -60,6 +62,7 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
60
62
|
}), !expand && isEdit ? /*#__PURE__*/_jsx(MessageInput, {
|
|
61
63
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.input,
|
|
62
64
|
defaultValue: value,
|
|
65
|
+
editButtonSize: editButtonSize,
|
|
63
66
|
onCancel: function onCancel() {
|
|
64
67
|
return setTyping(false);
|
|
65
68
|
},
|
|
@@ -11,6 +11,7 @@ export interface MessageInputProps extends DivProps {
|
|
|
11
11
|
* @description The default value of the input box.
|
|
12
12
|
*/
|
|
13
13
|
defaultValue?: string;
|
|
14
|
+
editButtonSize?: 'small' | 'middle';
|
|
14
15
|
height?: number | string;
|
|
15
16
|
/**
|
|
16
17
|
* @description Callback function triggered when user clicks on the cancel button.
|
package/es/MessageInput/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["text", "type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height"];
|
|
4
|
+
var _excluded = ["text", "type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height", "editButtonSize"];
|
|
5
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
7
|
import { Button } from 'antd';
|
|
@@ -25,6 +25,8 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
25
25
|
placeholder = _ref$placeholder === void 0 ? 'Type something...' : _ref$placeholder,
|
|
26
26
|
_ref$height = _ref.height,
|
|
27
27
|
height = _ref$height === void 0 ? 'fit-content' : _ref$height,
|
|
28
|
+
_ref$editButtonSize = _ref.editButtonSize,
|
|
29
|
+
editButtonSize = _ref$editButtonSize === void 0 ? 'middle' : _ref$editButtonSize,
|
|
28
30
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
31
|
var _useState = useState(defaultValue || ''),
|
|
30
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -65,10 +67,12 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
65
67
|
onClick: function onClick() {
|
|
66
68
|
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(temporarySystemRole);
|
|
67
69
|
},
|
|
70
|
+
size: editButtonSize,
|
|
68
71
|
type: "primary",
|
|
69
72
|
children: (text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm'
|
|
70
73
|
}), /*#__PURE__*/_jsx(Button, {
|
|
71
74
|
onClick: onCancel,
|
|
75
|
+
size: editButtonSize,
|
|
72
76
|
children: (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel'
|
|
73
77
|
})]
|
|
74
78
|
})
|
package/es/utils/formatTime.js
CHANGED
|
@@ -3,10 +3,10 @@ export var formatTime = function formatTime(time) {
|
|
|
3
3
|
var now = dayjs();
|
|
4
4
|
var target = dayjs(time);
|
|
5
5
|
if (target.isSame(now, 'day')) {
|
|
6
|
-
return target.format('HH:mm');
|
|
6
|
+
return target.format('HH:mm:ss');
|
|
7
7
|
} else if (target.isSame(now, 'year')) {
|
|
8
|
-
return target.format('MM-DD HH:mm');
|
|
8
|
+
return target.format('MM-DD HH:mm:ss');
|
|
9
9
|
} else {
|
|
10
|
-
return target.format('YYYY-MM-DD HH:mm');
|
|
10
|
+
return target.format('YYYY-MM-DD HH:mm:ss');
|
|
11
11
|
}
|
|
12
12
|
};
|