im-ui-mobile 0.0.94 → 0.0.96
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/index.js +6 -33
- package/package.json +1 -1
- package/utils/config.js +3 -4
- package/utils/emoji.js +4 -11
package/index.js
CHANGED
|
@@ -39,46 +39,19 @@ for (const key in importComponents) {
|
|
|
39
39
|
|
|
40
40
|
// 全局配置对象
|
|
41
41
|
let config = {}
|
|
42
|
-
|
|
43
|
-
// // 默认配置
|
|
44
|
-
// const defaultConfig = {
|
|
45
|
-
// emojiUrl: '',
|
|
46
|
-
// baseUrl: ''
|
|
47
|
-
// }
|
|
48
|
-
|
|
49
42
|
let emoji = null
|
|
50
43
|
|
|
51
44
|
const install = (app, upuiParams = '') => {
|
|
52
|
-
//
|
|
53
|
-
// config = { ...defaultConfig, ...options }
|
|
54
|
-
|
|
55
|
-
// // 提供全局配置
|
|
56
|
-
// app.provide('im-config', config)
|
|
57
|
-
// configManager.setConfig(config)
|
|
58
|
-
|
|
59
|
-
// if (!emoji) {
|
|
60
|
-
// emoji = new Emoji({ emojiUrl: config.emojiUrl })
|
|
61
|
-
// }
|
|
62
|
-
|
|
63
|
-
console.log('upuiParams', upuiParams)
|
|
64
|
-
|
|
65
|
-
// 初始化
|
|
45
|
+
// 初始化自定义配置
|
|
66
46
|
if (upuiParams) {
|
|
67
47
|
uni.upuiParams = upuiParams
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (temp.options) {
|
|
73
|
-
// 合并配置
|
|
74
|
-
config = temp.options
|
|
75
|
-
configManager.setConfig(temp.options)
|
|
76
|
-
console.log('install', configManager.get('emojiUrl'))
|
|
48
|
+
const params = upuiParams()
|
|
49
|
+
if (params.options) {
|
|
50
|
+
config = params.options
|
|
51
|
+
configManager.setConfig(params.options)
|
|
77
52
|
}
|
|
78
|
-
|
|
79
53
|
}
|
|
80
54
|
|
|
81
|
-
|
|
82
55
|
// 安装插件
|
|
83
56
|
app.use(UViewPlusPlugin)
|
|
84
57
|
|
|
@@ -88,8 +61,8 @@ const install = (app, upuiParams = '') => {
|
|
|
88
61
|
})
|
|
89
62
|
}
|
|
90
63
|
|
|
64
|
+
// 使用自定义配置的对象实例化
|
|
91
65
|
nextTick(() => {
|
|
92
|
-
console.log('new an emoji instance.')
|
|
93
66
|
emoji = new Emoji();
|
|
94
67
|
})
|
|
95
68
|
|
package/package.json
CHANGED
package/utils/config.js
CHANGED
|
@@ -17,9 +17,8 @@ export const configManager = {
|
|
|
17
17
|
|
|
18
18
|
// 初始化自定义配置
|
|
19
19
|
if (uni && uni.upuiParams) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
configManager.setConfig(temp.options)
|
|
20
|
+
const params = uni.upuiParams()
|
|
21
|
+
if (params.options) {
|
|
22
|
+
configManager.setConfig(params.options)
|
|
24
23
|
}
|
|
25
24
|
}
|
package/utils/emoji.js
CHANGED
|
@@ -11,7 +11,7 @@ class Emoji {
|
|
|
11
11
|
*/
|
|
12
12
|
constructor(options = {}) {
|
|
13
13
|
// 表情图片基础URL
|
|
14
|
-
|
|
14
|
+
this.emojiUrl = configManager.get('emojiUrl', 'url not found from awear.');
|
|
15
15
|
|
|
16
16
|
// 表情文本列表
|
|
17
17
|
this.emoTextList = [
|
|
@@ -25,12 +25,6 @@ class Emoji {
|
|
|
25
25
|
|
|
26
26
|
// 正则表达式匹配表情文本
|
|
27
27
|
this.regex = /\#[\u4E00-\u9FA5]{1,3}\;/gi;
|
|
28
|
-
|
|
29
|
-
console.log('new Emoji', configManager.get('emojiUrl'))
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getEmojiUrl() {
|
|
33
|
-
return configManager.get('emojiUrl', 'url not found from awear.')
|
|
34
28
|
}
|
|
35
29
|
|
|
36
30
|
/**
|
|
@@ -77,8 +71,7 @@ class Emoji {
|
|
|
77
71
|
if (idx === -1) {
|
|
78
72
|
return '';
|
|
79
73
|
}
|
|
80
|
-
|
|
81
|
-
return this.getEmojiUrl() + idx + ".gif";
|
|
74
|
+
return this.emojiUrl + idx + ".gif";
|
|
82
75
|
}
|
|
83
76
|
|
|
84
77
|
/**
|
|
@@ -87,13 +80,13 @@ class Emoji {
|
|
|
87
80
|
* @returns {string} 表情文本,格式如 "#开心;"
|
|
88
81
|
*/
|
|
89
82
|
pathToText(path) {
|
|
90
|
-
if (!path || !this.
|
|
83
|
+
if (!path || !this.emojiUrl || !path.includes(this.emojiUrl)) {
|
|
91
84
|
return '';
|
|
92
85
|
}
|
|
93
86
|
|
|
94
87
|
try {
|
|
95
88
|
// 从路径中提取表情索引
|
|
96
|
-
const filename = path.replace(this.
|
|
89
|
+
const filename = path.replace(this.emojiUrl, '').replace('.gif', '');
|
|
97
90
|
const index = parseInt(filename);
|
|
98
91
|
|
|
99
92
|
// 检查索引是否有效
|