升级package, 以及更新声明文件

This commit is contained in:
zhengw
2026-01-09 16:33:18 +08:00
parent 0c4b2a886c
commit cf461d33f9
238 changed files with 46252 additions and 5857 deletions

View File

@@ -0,0 +1,25 @@
import { SuperComponent, ComponentsOptionsType } from '../../../components/common/src/index';
import { TdChatContentProps } from './type';
export interface ChatContentProps extends TdChatContentProps {
}
export default class ChatContent extends SuperComponent {
options: ComponentsOptionsType;
properties: TdChatContentProps;
data: {
classPrefix: string;
textInfo: string;
};
observers: {
content(): void;
};
methods: {
getEscapeReplacement(ch: any): any;
escape(html: any, encode?: boolean): any;
setTextInfo(): void;
};
lifetimes: {
created(): void;
attached(): void;
detached(): void;
};
}

View File

@@ -0,0 +1 @@
import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";const{prefix:prefix}=config,name=`${prefix}-chat-content`;let ChatContent=class extends SuperComponent{constructor(){super(...arguments),this.options={multipleSlots:!0},this.properties=props,this.data={classPrefix:name,textInfo:""},this.observers={content(){this.setTextInfo()}},this.methods={getEscapeReplacement:t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[t]),escape(t,e=!1){const s=/[&<>"']/,o=new RegExp(s.source,"g"),n=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,a=new RegExp(n.source,"g");if(e){if(s.test(t))return t.replace(o,this.data.getEscapeReplacement)}else if(n.test(t))return t.replace(a,this.data.getEscapeReplacement);return t},setTextInfo(){"text"===this.properties.content.type||"error"===this.properties.status?this.setData({textInfo:this.escape(this.properties.content.data||"")}):this.setData({textInfo:this.properties.content.data})}},this.lifetimes={created(){this.data.getEscapeReplacement=this.getEscapeReplacement.bind(this),this.data.escape=this.escape.bind(this)},attached(){this.setTextInfo()},detached(){}}}};ChatContent=__decorate([wxComponent()],ChatContent);export default ChatContent;

View File

@@ -0,0 +1 @@
{"component":true,"styleIsolation":"apply-shared","usingComponents":{"t-chat-markdown":"../chat-markdown/chat-markdown"}}

View File

@@ -0,0 +1 @@
<wxs src="../common/utils.wxs" module="_"/><view class="class {{classPrefix}}" style="{{_._style([style, customStyle])}}"><block wx:if="{{status === 'error' || content.type === 'text'}}"><view class="{{classPrefix}}__{{role}} {{classPrefix}}__{{status}}"><view class="_pre"><rich-text nodes="{{textInfo}}"/></view></view></block><block wx:else><view class="{{classPrefix}}__assistant"><t-chat-markdown content="{{textInfo}}" options="{{markdownProps && markdownProps.options}}"></t-chat-markdown></view></block></view>

View File

@@ -0,0 +1,8 @@
@import '../common/style/index.wxss';.t-chat-content{font:var(--td-font-body-large,32rpx / 48rpx var(--td-font-family,PingFang SC,Microsoft YaHei,Arial Regular));word-break:break-all;word-wrap:break-word;overflow-wrap:break-word;box-sizing:border-box;width:fit-content;}
.t-chat-content__system,.t-chat-content__user{color:var(--td-chat-content-user-text-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));}
.t-chat-content__system ._pre,.t-chat-content__user ._pre{margin:0;white-space:pre-wrap;}
.t-chat-content__assistant{color:var(--td-chat-content-assistant-text-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));}
.t-chat-content__assistant ._ol{-webkit-padding-start:40rpx;padding-inline-start:40rpx;}
.t-chat-content__assistant ._ol ._li{list-style:decimal;}
.t-chat-content__assistant ._img{max-width:100%;margin:8rpx 0;border-radius:var(--td-radius-small,6rpx);}
.t-chat-content__error{color:var(--td-chat-content-error-text-color,var(--td-error-color,var(--td-error-color-6,#d54941)));}

View File

@@ -0,0 +1,3 @@
export * from './props';
export * from './type';
export * from './chat-content';

View File

@@ -0,0 +1 @@
export*from"./props";export*from"./type";export*from"./chat-content";

View File

@@ -0,0 +1,3 @@
import { TdChatContentProps } from './type';
declare const props: TdChatContentProps;
export default props;

View File

@@ -0,0 +1 @@
const props={content:{type:Object,required:!0},markdownProps:{type:Object},role:{type:String,required:!0},status:{type:String}};export default props;

View File

@@ -0,0 +1,25 @@
import { ChatMarkdownProps } from '../chat-markdown/index';
export interface TdChatContentProps {
content: {
type: ObjectConstructor;
value?: TdChatContentType;
required?: boolean;
};
markdownProps?: {
type: ObjectConstructor;
value?: ChatMarkdownProps;
};
role: {
type: StringConstructor;
value?: 'user' | 'assistant' | 'system';
required?: boolean;
};
status?: {
type: StringConstructor;
value?: 'error' | '';
};
}
export interface TdChatContentType {
type: 'text' | 'markdown';
data: string;
}

View File

@@ -0,0 +1 @@
export{};