@hlw-uni/mp-vue 2.2.5 → 2.2.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni/mp-vue",
3
- "version": "2.2.5",
3
+ "version": "2.2.7",
4
4
  "description": "hlw-uni 小程序运行时 — Vue 组件 + composables + theme + http + 工具集(合并自原 mp-core)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -124,10 +124,33 @@ async function handleClick() {
124
124
  isClicked.value = false;
125
125
  }
126
126
  }
127
+
128
+ /**
129
+ * Expose a method for parent components to open the reward ad programmatically via ref.
130
+ * Usage: const adRef = ref(null);
131
+ * <hlw-reward-ad ref="adRef" :unit-id="..." />
132
+ * adRef.value?.open();
133
+ */
134
+ defineExpose({
135
+ async open() {
136
+ if (isClicked.value) return;
137
+ if (!props.unitId) {
138
+ console.warn("[HlwRewardAd] unitId is required but empty.");
139
+ return;
140
+ }
141
+ isClicked.value = true;
142
+ try {
143
+ await playRewardAdFlow();
144
+ } finally {
145
+ isClicked.value = false;
146
+ }
147
+ }
148
+ });
127
149
  </script>
128
150
 
129
151
  <style scoped>
130
152
  .hlw-reward-ad {
131
- display: inline-block;
153
+ display: block;
154
+ width: 100%;
132
155
  }
133
156
  </style>