@truenewx/tnxvue3 3.4.4 → 3.4.5

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/src/tnxvue.ts CHANGED
@@ -27,6 +27,7 @@ export type DialogOptions = {
27
27
  click?: boolean | ((yes: boolean, close: () => void) => boolean | undefined) | ((close: () => void) => boolean | undefined);
28
28
  buttonText?: string | string[];
29
29
  buttons?: ButtonOptions[];
30
+ width?: number | string;
30
31
  }
31
32
 
32
33
  export type OpenType = 'alert' | 'confirm' | 'close' | 'none';
@@ -174,7 +175,7 @@ export default class TnxVue extends Tnx {
174
175
 
175
176
  protected getDefaultDialogButtons(
176
177
  type: OpenType,
177
- click: boolean | ((yes: boolean, close: () => void) => boolean | undefined) | ((close: () => void) => boolean | undefined),
178
+ click: boolean | string | ((yes: boolean, close: () => void) => boolean | undefined) | ((close: () => void) => boolean | undefined),
178
179
  theme?: string): ButtonOptions[] {
179
180
  if (click !== false) {
180
181
  if (type === 'none') {
@@ -184,6 +185,9 @@ export default class TnxVue extends Tnx {
184
185
  text: '确定',
185
186
  type: theme || 'primary',
186
187
  click(close: () => void) {
188
+ if (typeof click === 'string') {
189
+ click = this[click];
190
+ }
187
191
  if (typeof click === 'function') {
188
192
  return click.call(this, true, close);
189
193
  }
@@ -191,6 +195,9 @@ export default class TnxVue extends Tnx {
191
195
  }, {
192
196
  text: '取消',
193
197
  click(close: () => void) {
198
+ if (typeof click === 'string') {
199
+ click = this[click];
200
+ }
194
201
  if (typeof click === 'function') {
195
202
  return click.call(this, false, close);
196
203
  }
@@ -201,6 +208,9 @@ export default class TnxVue extends Tnx {
201
208
  text: '关闭',
202
209
  type: theme,
203
210
  click(close: () => void) {
211
+ if (typeof click === 'string') {
212
+ click = this[click];
213
+ }
204
214
  if (typeof click === 'function') {
205
215
  return click.call(this, close);
206
216
  }
@@ -211,6 +221,9 @@ export default class TnxVue extends Tnx {
211
221
  text: '确定',
212
222
  type: theme || 'primary',
213
223
  click(close: () => void) {
224
+ if (typeof click === 'string') {
225
+ click = this[click];
226
+ }
214
227
  if (typeof click === 'function') {
215
228
  return click.call(this, close);
216
229
  }
@@ -221,7 +234,7 @@ export default class TnxVue extends Tnx {
221
234
  return [];
222
235
  }
223
236
 
224
- closeDialog(all?: boolean): Promise<void> {
237
+ closeDialog(all?: boolean): void {
225
238
  // 默认不实现,由UI框架扩展层实现
226
239
  throw new Error('Unsupported function');
227
240
  }
@@ -235,7 +248,7 @@ export default class TnxVue extends Tnx {
235
248
  throw new Error('Unsupported function');
236
249
  }
237
250
 
238
- closeDrawer(all?: boolean): Promise<void> {
251
+ closeDrawer(all?: boolean): void {
239
252
  // 默认不实现,由UI框架扩展层实现
240
253
  throw new Error('Unsupported function');
241
254
  }
@@ -256,10 +269,10 @@ export default class TnxVue extends Tnx {
256
269
 
257
270
  open(component: Vue.Component, props?: Record<string, any>, options: OpenOptions = {}) {
258
271
  const c = component as any;
259
- if (typeof c.open === 'function') {
260
- options = Object.assign({}, c.open(props), options);
261
- } else if (c.methods && typeof c.methods.open === 'function') {
262
- options = Object.assign({}, c.methods.open(props), options);
272
+ if (typeof c.openOptions === 'function') {
273
+ options = Object.assign({}, c.openOptions(props), options);
274
+ } else if (c.openOptions) {
275
+ options = Object.assign({}, c.openOptions, options);
263
276
  }
264
277
 
265
278
  let mode = options.mode;
package/tsconfig.json CHANGED
@@ -28,6 +28,7 @@
28
28
  },
29
29
  "include": [
30
30
  "src/**/*.ts",
31
+ "src/**/*.vue",
31
32
  "sample/**/*.ts",
32
33
  "node_modules/tdesign-vue-next/global.d.ts"
33
34
  ]