@hlw-uni/mp-vue 2.1.13 → 2.1.14
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/dist/composables/ad/index.d.ts +5 -0
- package/dist/index.js +12 -2
- package/dist/index.mjs +12 -2
- package/package.json +1 -1
- package/src/app.ts +15 -0
- package/src/composables/ad/index.ts +13 -2
|
@@ -35,6 +35,11 @@ export interface AdAdapter {
|
|
|
35
35
|
isAuth?: () => boolean;
|
|
36
36
|
/** 是否 VIP;配合 config.vip_no_ad=1 时屏蔽展示型广告(reward 不受影响) */
|
|
37
37
|
isVip?: () => boolean;
|
|
38
|
+
/**
|
|
39
|
+
* 用户级强制屏蔽:返回 true 直接屏蔽展示型广告(reward 不受影响),
|
|
40
|
+
* 优先级高于 mp.vip_no_ad + isVip 的联合判断;不传 = 不强制。
|
|
41
|
+
*/
|
|
42
|
+
userNoAd?: () => boolean;
|
|
38
43
|
}
|
|
39
44
|
/** 激励视频关闭回调返回 */
|
|
40
45
|
export interface AdCloseResult {
|
package/dist/index.js
CHANGED
|
@@ -658,9 +658,11 @@ var __publicField = (obj, key, value) => {
|
|
|
658
658
|
const store = useAdStore();
|
|
659
659
|
const { loaded } = pinia.storeToRefs(store);
|
|
660
660
|
const config2 = vue.computed(() => {
|
|
661
|
-
var _a;
|
|
661
|
+
var _a, _b;
|
|
662
662
|
const raw = store.config;
|
|
663
|
-
|
|
663
|
+
const userForce = ((_a = adapter$1 == null ? void 0 : adapter$1.userNoAd) == null ? void 0 : _a.call(adapter$1)) === true;
|
|
664
|
+
const vipHide = raw.vip_no_ad === 1 && ((_b = adapter$1 == null ? void 0 : adapter$1.isVip) == null ? void 0 : _b.call(adapter$1)) === true;
|
|
665
|
+
if (userForce || vipHide) {
|
|
664
666
|
return { ...EMPTY, reward_unit_id: raw.reward_unit_id, vip_no_ad: 1 };
|
|
665
667
|
}
|
|
666
668
|
return raw;
|
|
@@ -1815,6 +1817,14 @@ var __publicField = (obj, key, value) => {
|
|
|
1815
1817
|
_interceptorCleanup.forEach((dispose) => dispose());
|
|
1816
1818
|
_interceptorCleanup = [];
|
|
1817
1819
|
const offRequest = http.onRequest((config2) => {
|
|
1820
|
+
const method = (config2.method ?? "GET").toUpperCase();
|
|
1821
|
+
if (method === "GET" && config2.data && typeof config2.data === "object") {
|
|
1822
|
+
const qs = Object.entries(config2.data).filter(([, v]) => v !== void 0 && v !== null).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&");
|
|
1823
|
+
if (qs) {
|
|
1824
|
+
config2.url = config2.url + (config2.url.includes("?") ? "&" : "?") + qs;
|
|
1825
|
+
}
|
|
1826
|
+
config2.data = void 0;
|
|
1827
|
+
}
|
|
1818
1828
|
const device = useDevice();
|
|
1819
1829
|
if (device.value) {
|
|
1820
1830
|
const d = device.value;
|
package/dist/index.mjs
CHANGED
|
@@ -657,9 +657,11 @@ function useAd() {
|
|
|
657
657
|
const store = useAdStore();
|
|
658
658
|
const { loaded } = storeToRefs(store);
|
|
659
659
|
const config2 = computed(() => {
|
|
660
|
-
var _a;
|
|
660
|
+
var _a, _b;
|
|
661
661
|
const raw = store.config;
|
|
662
|
-
|
|
662
|
+
const userForce = ((_a = adapter$1 == null ? void 0 : adapter$1.userNoAd) == null ? void 0 : _a.call(adapter$1)) === true;
|
|
663
|
+
const vipHide = raw.vip_no_ad === 1 && ((_b = adapter$1 == null ? void 0 : adapter$1.isVip) == null ? void 0 : _b.call(adapter$1)) === true;
|
|
664
|
+
if (userForce || vipHide) {
|
|
663
665
|
return { ...EMPTY, reward_unit_id: raw.reward_unit_id, vip_no_ad: 1 };
|
|
664
666
|
}
|
|
665
667
|
return raw;
|
|
@@ -1814,6 +1816,14 @@ function setupInterceptors(options = {}) {
|
|
|
1814
1816
|
_interceptorCleanup.forEach((dispose) => dispose());
|
|
1815
1817
|
_interceptorCleanup = [];
|
|
1816
1818
|
const offRequest = http.onRequest((config2) => {
|
|
1819
|
+
const method = (config2.method ?? "GET").toUpperCase();
|
|
1820
|
+
if (method === "GET" && config2.data && typeof config2.data === "object") {
|
|
1821
|
+
const qs = Object.entries(config2.data).filter(([, v]) => v !== void 0 && v !== null).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&");
|
|
1822
|
+
if (qs) {
|
|
1823
|
+
config2.url = config2.url + (config2.url.includes("?") ? "&" : "?") + qs;
|
|
1824
|
+
}
|
|
1825
|
+
config2.data = void 0;
|
|
1826
|
+
}
|
|
1817
1827
|
const device = useDevice();
|
|
1818
1828
|
if (device.value) {
|
|
1819
1829
|
const d = device.value;
|
package/package.json
CHANGED
package/src/app.ts
CHANGED
|
@@ -102,6 +102,21 @@ export function setupInterceptors(options: InterceptorOptions & { sigSecret?: st
|
|
|
102
102
|
* 请求拦截:注入设备信息、签名和 token。
|
|
103
103
|
*/
|
|
104
104
|
const offRequest = http.onRequest((config: RequestConfig) => {
|
|
105
|
+
// GET 请求:把 cfg.data 合并到 url query,并清空 cfg.data。
|
|
106
|
+
// 否则 uni.request 会在 sig 之后再把 data 自动拼到 URL,导致后端 raw query
|
|
107
|
+
// 多了未参与签名的字段(如 id/cate_id),sig 校验必然失败。
|
|
108
|
+
const method = (config.method ?? 'GET').toUpperCase();
|
|
109
|
+
if (method === 'GET' && config.data && typeof config.data === 'object') {
|
|
110
|
+
const qs = Object.entries(config.data as Record<string, unknown>)
|
|
111
|
+
.filter(([, v]) => v !== undefined && v !== null)
|
|
112
|
+
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
|
|
113
|
+
.join('&');
|
|
114
|
+
if (qs) {
|
|
115
|
+
config.url = config.url + (config.url.includes('?') ? '&' : '?') + qs;
|
|
116
|
+
}
|
|
117
|
+
config.data = undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
105
120
|
const device = useDevice();
|
|
106
121
|
if (device.value) {
|
|
107
122
|
const d = device.value;
|
|
@@ -87,6 +87,11 @@ export interface AdAdapter {
|
|
|
87
87
|
isAuth?: () => boolean;
|
|
88
88
|
/** 是否 VIP;配合 config.vip_no_ad=1 时屏蔽展示型广告(reward 不受影响) */
|
|
89
89
|
isVip?: () => boolean;
|
|
90
|
+
/**
|
|
91
|
+
* 用户级强制屏蔽:返回 true 直接屏蔽展示型广告(reward 不受影响),
|
|
92
|
+
* 优先级高于 mp.vip_no_ad + isVip 的联合判断;不传 = 不强制。
|
|
93
|
+
*/
|
|
94
|
+
userNoAd?: () => boolean;
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
/** 激励视频关闭回调返回 */
|
|
@@ -147,10 +152,16 @@ export function useAd() {
|
|
|
147
152
|
const store = useAdStore();
|
|
148
153
|
const { loaded } = storeToRefs(store);
|
|
149
154
|
|
|
150
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* 真实生效的广告配置;以下任一命中即屏蔽展示型 unit_id(reward 保留):
|
|
157
|
+
* 1. adapter.userNoAd() === true —— 用户级强制屏蔽,优先级最高
|
|
158
|
+
* 2. raw.vip_no_ad === 1 && adapter.isVip() —— 小程序级 VIP 隐藏开关
|
|
159
|
+
*/
|
|
151
160
|
const config = computed<AdConfig>(() => {
|
|
152
161
|
const raw = store.config;
|
|
153
|
-
|
|
162
|
+
const userForce = adapter?.userNoAd?.() === true;
|
|
163
|
+
const vipHide = raw.vip_no_ad === 1 && adapter?.isVip?.() === true;
|
|
164
|
+
if (userForce || vipHide) {
|
|
154
165
|
return { ...EMPTY, reward_unit_id: raw.reward_unit_id, vip_no_ad: 1 };
|
|
155
166
|
}
|
|
156
167
|
return raw;
|