stellar-ui-v2 1.40.17 → 1.40.19

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/README.md CHANGED
@@ -10,9 +10,9 @@
10
10
 
11
11
  ## ✨ 特性
12
12
 
13
- - 🎯 多平台覆盖,支持 微信小程序、支付宝小程序、H5.
14
- - 🚀 40+ 个高质量组件,覆盖移动端主流场景.
15
- - 📖 提供丰富的文档和组件示例.
13
+ - 🎯 多平台覆盖,支持 微信小程序、支付宝小程序、H5.
14
+ - 🚀 40+ 个高质量组件,覆盖移动端主流场景.
15
+ - 📖 提供丰富的文档和组件示例.
16
16
  - 🎨 支持修改 CSS 变量实现主题定制.
17
17
 
18
18
  ## 📱 预览
@@ -75,11 +75,11 @@ npm i stellar-ui-v2 -S
75
75
 
76
76
  ## 周边生态
77
77
 
78
- | 项目 | 描述 |
79
- | --- | --- |
80
- |[StellarUI-Plus](https://github.com/wuhanshuzhiyun/stellar-ui-plus) | 一个基于vue3构建,打造的uni-app组件库 |
81
- |[ste-vue-inset-loader](https://github.com/wuhanshuzhiyun/ste-vue-inset-loader) |常用于小程序需要全局引入组件的场景的包 |
82
- |[ste-helper](https://github.com/wuhanshuzhiyun/stellar-ui-plus/tree/main/plugins/ste-helper) |旨在帮助开发者更加有效率的使用 StellarUI-Plus来开发项目的vscode插件 |
78
+ | 项目 | 描述 |
79
+ | --- | --- |
80
+ |[StellarUI-Plus](https://github.com/wuhanshuzhiyun/stellar-ui-plus) | 一个基于vue3构建,打造的uni-app组件库 |
81
+ |[ste-vue-inset-loader](https://github.com/wuhanshuzhiyun/ste-vue-inset-loader) |常用于小程序需要全局引入组件的场景的包 |
82
+ |[ste-helper](https://github.com/wuhanshuzhiyun/stellar-ui-plus/tree/main/plugins/ste-helper) |旨在帮助开发者更加有效率的使用 StellarUI-Plus来开发项目的vscode插件 |
83
83
  |[ste-cli](https://github.com/wuhanshuzhiyun/ste-cli) |stellar配套的脚手架 |
84
84
 
85
85
  ## 核心团队
@@ -1,3 +1,15 @@
1
+ async function getImage(src) {
2
+ const image = await uni.getImageInfo({ src: src });
3
+ if (Array.isArray(image)) {
4
+ const [e, img] = image;
5
+ if (e) throw e;
6
+ return img;
7
+ } else if (image.path) {
8
+ return image;
9
+ }
10
+ throw new Error('获取图片失败');
11
+ }
12
+
1
13
  /**
2
14
  * @param {UniApp.CanvasContext} ctx
3
15
  * @param {{background:string;title:string;message:string;qrcode:string}} poster
@@ -21,7 +33,7 @@ export function drawPoster(ctx, poster, data) {
21
33
  // 绘制宽高一致的图片
22
34
  if (data.image) {
23
35
  try {
24
- const image = await uni.getImageInfo({ src: data.image });
36
+ const image = await getImage(data.image);
25
37
  ctx.drawImage(image.path, 0, 40, width, width);
26
38
  } catch (e) {
27
39
  console.error(e);
@@ -54,12 +66,12 @@ export function drawPoster(ctx, poster, data) {
54
66
  ctx.setFontSize(12);
55
67
  ctx.setFillStyle('#666666');
56
68
  ctx.setTextAlign('left');
57
- ctx.fillText(poster.message, 10, height - 20);
69
+ ctx.fillText(poster.message, 10, width + 150);
58
70
  }
59
71
  // 绘制qrcode
60
72
  if (poster.qrcode) {
61
73
  try {
62
- const qrcode = await uni.getImageInfo({ src: poster.qrcode });
74
+ const qrcode = await getImage(poster.qrcode);
63
75
  ctx.drawImage(qrcode.path, width - 80, width + 80, 70, 70);
64
76
  } catch (e) {
65
77
  console.error(e);
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <!-- 分享弹窗 -->
3
3
  <view class="ste-share-root" :class="{ open: dataOpen }">
4
- <view class="content-box" :style="{ opacity: viewPoster ? 1 : 0 }">
4
+ <view class="content-box" :style="canvasStyle">
5
5
  <view class="loading" v-if="loading"></view>
6
6
  <canvas id="content-poster" canvas-id="content-poster" />
7
7
  </view>
@@ -25,14 +25,12 @@
25
25
  <image class="footer-icon" src="../../static/shoucang.png" mode="widthFix"></image>
26
26
  <text>微信收藏</text>
27
27
  </view>
28
+ <view class="footer-item" @click="downloadPoster" v-if="viewPoster">
29
+ <image class="footer-icon" src="../../static/haibao.png" mode="widthFix"></image>
30
+ <text>生成海报</text>
31
+ </view>
28
32
  </view>
29
33
  </scroll-view>
30
- <view class="footer-share-list">
31
- <view class="footer-item" @click="downloadPoster" v-if="viewPoster">
32
- <image class="footer-icon" src="../../static/haibao.png" mode="widthFix"></image>
33
- <text>生成海报</text>
34
- </view>
35
- </view>
36
34
  </view>
37
35
  </view>
38
36
  </template>
@@ -40,7 +38,10 @@
40
38
  <script>
41
39
  import { copyFileToPublicDir, drawPoster } from './draw';
42
40
  import { share } from './share';
43
-
41
+ import utils from '../../utils/utils';
42
+ // #ifndef APP
43
+ const notApp = '该功能仅在APP端有效';
44
+ // #endif
44
45
  export default {
45
46
  name: 'ste-app-share',
46
47
  group: '业务组件',
@@ -79,6 +80,15 @@ export default {
79
80
  canvas: null,
80
81
  };
81
82
  },
83
+ computed: {
84
+ canvasStyle() {
85
+ return {
86
+ width: utils.formatPx(660),
87
+ height: utils.formatPx(990),
88
+ opacity: this.viewPoster ? 1 : 0,
89
+ };
90
+ },
91
+ },
82
92
  watch: {
83
93
  open: {
84
94
  handler(val) {
@@ -98,7 +108,8 @@ export default {
98
108
  },
99
109
  handShare(scene) {
100
110
  // #ifndef APP
101
- uni.showToast({ title: '暂不支持', icon: 'none', duration: 2000 });
111
+ console.error(notApp);
112
+ uni.showToast({ title: notApp, icon: 'none', duration: 2000 });
102
113
  // #endif
103
114
  // #ifdef APP
104
115
  share(scene, this.miniProgram, this.data);
@@ -116,18 +127,19 @@ export default {
116
127
  this.ctx.width = canvas.width;
117
128
  this.ctx.height = canvas.height;
118
129
 
119
- drawPoster(this.ctx, this.poster, this.data).then(() => {
130
+ drawPoster(this.ctx, this.poster, this.data).finally(() => {
120
131
  this.loading = false;
121
132
  });
122
133
  })
123
134
  .exec();
124
135
  } else {
125
- drawPoster(this.ctx, this.poster, this.data).then(() => {
136
+ drawPoster(this.ctx, this.poster, this.data).finally(() => {
126
137
  this.loading = false;
127
138
  });
128
139
  }
129
140
  },
130
141
  downloadPoster() {
142
+ // #ifdef APP
131
143
  uni.canvasToTempFilePath({
132
144
  canvasId: 'content-poster',
133
145
  success: ({ tempFilePath }) => {
@@ -142,6 +154,11 @@ export default {
142
154
  });
143
155
  },
144
156
  });
157
+ // #endif
158
+ // #ifndef APP
159
+ console.error(notApp);
160
+ uni.showToast({ title: notApp, icon: 'none', duration: 2000 });
161
+ // #endif
145
162
  },
146
163
  },
147
164
  };
@@ -154,7 +171,7 @@ export default {
154
171
  left: 0;
155
172
  width: 100%;
156
173
  height: 100%;
157
- z-index: 9999;
174
+ z-index: 1001;
158
175
  background-color: rgba(0, 0, 0, 0.5);
159
176
  opacity: 0;
160
177
  pointer-events: none;
@@ -165,9 +182,7 @@ export default {
165
182
  }
166
183
  .content-box {
167
184
  position: absolute;
168
- width: 660rpx;
169
- height: 1020rpx;
170
- top: 120rpx;
185
+ top: 90rpx;
171
186
  left: 50%;
172
187
  transform: translateX(-50%);
173
188
  z-index: 9;
@@ -111,12 +111,12 @@ methods: {
111
111
 
112
112
  #### IndexList Props
113
113
 
114
- | 属性名 | 说明 |类型 |默认值 |可选值 | 支持版本 |
115
- | --- |--- | --- | --- | --- | --- |
116
- | `active` | 当前激活的索引下标,支持sync双向绑定,默认值0 | `Number` | `0` | - | - |
117
- | `height` | 高度,默认值100% | `String`/`Number` | `"100%"` | - | - |
118
- | `sticky` | `title`是否粘性布局,自定义`title`插槽时不生效 | `Boolean` | `true` | - | - |
119
- | `inactiveColor` | 右边锚点状态非激活时的颜色 | `String` | `#666666` | - | - |
114
+ | 属性名 | 说明 |类型 |默认值 |可选值 | 支持版本 |
115
+ | --- |--- | --- | --- | --- | --- |
116
+ | `active` | 当前激活的索引下标,支持sync双向绑定,默认值0 | `Number` | `0` | - | - |
117
+ | `height` | 高度,默认值100% | `String`/`Number` | `"100%"` | - | - |
118
+ | `sticky` | `title`是否粘性布局,自定义`title`插槽时不生效 | `Boolean` | `true` | - | - |
119
+ | `inactiveColor` | 右边锚点状态非激活时的颜色 | `String` | `#666666` | - | - |
120
120
  | `activeColor` | 右边锚点状态激活时的颜色 | `String` | `#0090FF` | - | - |
121
121
 
122
122
  #### IndexList Events
@@ -1,72 +1,72 @@
1
- import Vue from 'vue';
2
- import Vuex from 'vuex';
3
-
4
- Vue.use(Vuex);
5
- const DEFAULT_KEY = '$steMsgBoxKey';
6
- const DEFAULT_CONFIG = {
7
- title: '',
8
- content: '',
9
- showCancel: true,
10
- icon: '',
11
- cancelText: '取消',
12
- cancelColor: '#333333',
13
- confirmText: '确认',
14
- confirmColor: '',
15
- editable: false,
16
- placeholderText: '',
17
- success: null,
18
- fail: null,
19
- complete: null,
20
- };
21
-
22
- const store = new Vuex.Store({
23
- state: {},
24
- mutations: {
25
- initializeState(state, key) {
26
- if (!state[key]) {
27
- Vue.set(state, key, {
28
- selector: key,
29
- openBegin: false,
30
- ...DEFAULT_CONFIG,
31
- });
32
- }
33
- },
34
- setState(state, { key, params }) {
35
- Object.assign(state[key], params);
36
- },
37
- resetState(state, key) {
38
- Object.assign(state[key], {
39
- openBegin: false,
40
- });
41
- },
42
- },
43
- });
44
-
45
- function useSteMsgBox(key) {
46
- key = key ?? DEFAULT_KEY;
47
- store.commit('initializeState', key);
48
-
49
- return {
50
- showMsgBox(params) {
51
- store.commit('setState', {
52
- key,
53
- params: {
54
- ...DEFAULT_CONFIG,
55
- ...params,
56
- confirm: params.confirm ?? function () {},
57
- cancel: params.cancel ?? function () {},
58
- complete: params.complete ?? function () {},
59
- openBegin: true,
60
- },
61
- });
62
- },
63
- hideMsgBox() {
64
- store.commit('resetState', key);
65
- },
66
- $state: store.state[key],
67
- $store: store,
68
- };
69
- }
70
-
71
- export default useSteMsgBox;
72
- export { DEFAULT_KEY };
1
+ import Vue from 'vue';
2
+ import Vuex from 'vuex';
3
+
4
+ Vue.use(Vuex);
5
+ const DEFAULT_KEY = '$steMsgBoxKey';
6
+ const DEFAULT_CONFIG = {
7
+ title: '',
8
+ content: '',
9
+ showCancel: true,
10
+ icon: '',
11
+ cancelText: '取消',
12
+ cancelColor: '#333333',
13
+ confirmText: '确认',
14
+ confirmColor: '',
15
+ editable: false,
16
+ placeholderText: '',
17
+ success: null,
18
+ fail: null,
19
+ complete: null,
20
+ };
21
+
22
+ const store = new Vuex.Store({
23
+ state: {},
24
+ mutations: {
25
+ initializeState(state, key) {
26
+ if (!state[key]) {
27
+ Vue.set(state, key, {
28
+ selector: key,
29
+ openBegin: false,
30
+ ...DEFAULT_CONFIG,
31
+ });
32
+ }
33
+ },
34
+ setState(state, { key, params }) {
35
+ Object.assign(state[key], params);
36
+ },
37
+ resetState(state, key) {
38
+ Object.assign(state[key], {
39
+ openBegin: false,
40
+ });
41
+ },
42
+ },
43
+ });
44
+
45
+ function useSteMsgBox(key) {
46
+ key = key ?? DEFAULT_KEY;
47
+ store.commit('initializeState', key);
48
+
49
+ return {
50
+ showMsgBox(params) {
51
+ store.commit('setState', {
52
+ key,
53
+ params: {
54
+ ...DEFAULT_CONFIG,
55
+ ...params,
56
+ confirm: params.confirm ?? function () {},
57
+ cancel: params.cancel ?? function () {},
58
+ complete: params.complete ?? function () {},
59
+ openBegin: true,
60
+ },
61
+ });
62
+ },
63
+ hideMsgBox() {
64
+ store.commit('resetState', key);
65
+ },
66
+ $state: store.state[key],
67
+ $store: store,
68
+ };
69
+ }
70
+
71
+ export default useSteMsgBox;
72
+ export { DEFAULT_KEY };