Skip to content

Commit e2e7262

Browse files
authored
Feature/marked app plus (#142)
* feat: use marked of uni-app version * fix(image): not use click.stop * feat(chat-list): 兼容app-plus * chore: fix spell error
1 parent d5a0b75 commit e2e7262

File tree

7 files changed

+149
-5
lines changed

7 files changed

+149
-5
lines changed

packages/tdesign-app/mixins/demo-base.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1+
import { goBackOrGoHome } from 'tdesign-uniapp/common/route';
2+
3+
const SHARE_INFO = {
4+
title: 'TDesign UI',
5+
};
6+
7+
18
export default {
9+
onShareAppMessage() {
10+
return SHARE_INFO;
11+
},
12+
onShareTimeline() {
13+
return SHARE_INFO;
14+
},
215
computed: {
316
gCustomNavbarHeight() {
417
let result = 0;
@@ -29,4 +42,22 @@ export default {
2942
return result;
3043
},
3144
},
45+
mounted() {
46+
// 检查分享功能是否可用
47+
// #ifdef MP-WEIXIN
48+
if (typeof wx.showShareMenu === 'function') {
49+
wx.showShareMenu({
50+
success: () => {
51+
},
52+
fail: () => {
53+
},
54+
});
55+
}
56+
// #endif
57+
},
58+
methods: {
59+
onDemoGoBack() {
60+
goBackOrGoHome();
61+
},
62+
},
3263
};

packages/tdesign-uniapp-chat/chat-list/chat-list.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export default uniComponent({
168168
<style scoped>
169169
@import './chat-list.css';
170170
171-
/* #ifdef H5 */
171+
/* #ifdef H5 || APP-PLUS */
172172
.t-chat-list__content :deep(.uni-scroll-view-content) {
173173
display: flex;;
174174
flex-direction: column;

packages/tdesign-uniapp-chat/chat-markdown-node/chat-markdown-node.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
import chatMarkdownCode from '../chat-markdown-code/chat-markdown-code.vue';
223223
import { prefix } from 'tdesign-uniapp/common/config';
224224
import { uniComponent } from 'tdesign-uniapp/common/src/index';
225-
// #ifndef H5
225+
// #ifdef MP
226226
import { TChatMarkdownNode } from './chat-markdown-node.vue';
227227
// #endif
228228
@@ -240,7 +240,7 @@ export default uniComponent({
240240
components: {
241241
// chatMarkdownTable,
242242
chatMarkdownCode,
243-
// #ifndef H5
243+
// #ifdef MP
244244
TChatMarkdownNode,
245245
// #endif
246246
},

packages/tdesign-uniapp-chat/chat-markdown/chat-markdown.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@
77
</view>
88
</template>
99
<script>
10+
import './polyfill';
1011
import chatMarkdownNode from '../chat-markdown-node/chat-markdown-node.vue';
12+
// #ifdef APP-PLUS
13+
import { Lexer as LexerUni } from '../npm/marked/uniapp';
14+
// #endif
15+
16+
// #ifndef APP-PLUS
1117
import { Lexer } from '../npm/marked';
18+
// #endif
19+
1220
import { prefix } from 'tdesign-uniapp/common/config';
1321
import props from './props';
1422
import _ from 'tdesign-uniapp/common/utils.wxs';
@@ -55,7 +63,14 @@ export default uniComponent({
5563
// 解析markdown文本
5664
parseMarkdown(markdown) {
5765
try {
58-
const lexer = new Lexer(this.options);
66+
let lexer;
67+
// #ifdef APP-PLUS
68+
lexer = new LexerUni(this.options);
69+
// #endif
70+
// #ifndef APP-PLUS
71+
lexer = new Lexer(this.options);
72+
// #endif
73+
5974
const tokens = lexer.lex(markdown);
6075
6176
this.nodes = tokens;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// 为数组 (Array) 添加 at 方法的 polyfill
2+
if (!Array.prototype.at) {
3+
Array.prototype.at = function (index) {
4+
// 将索引转换为数字
5+
index = Math.trunc(index) || 0;
6+
// 如果索引是负数,则从数组末尾开始计算
7+
if (index < 0) index += this.length;
8+
// 如果计算后的索引超出范围,则返回 undefined
9+
if (index < 0 || index >= this.length) return undefined;
10+
// 返回指定索引的元素
11+
return this[index];
12+
};
13+
}
14+
15+
// 为字符串 (String) 添加 at 方法的 polyfill
16+
if (!String.prototype.at) {
17+
String.prototype.at = function (index) {
18+
// 将索引转换为数字
19+
index = Math.trunc(index) || 0;
20+
// 如果索引是负数,则从字符串末尾开始计算
21+
if (index < 0) index += this.length;
22+
// 如果计算后的索引超出范围,则返回空字符串
23+
if (index < 0 || index >= this.length) return '';
24+
// 返回指定索引的字符
25+
return this[index];
26+
};
27+
}

packages/tdesign-uniapp-chat/npm/marked/uniapp.js

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/tdesign/image/image.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@
7676
:show-menu-by-longpress="showMenuByLongpress"
7777
:aria-hidden="ariaHidden || isLoading || isFailed"
7878
:aria-label="ariaLabel"
79+
@click="onClick"
7980
@load="onLoaded"
8081
@error="onLoadError"
81-
@click.stop="onClick"
8282
/>
8383
</view>
8484
</template>

0 commit comments

Comments
 (0)