Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
a4052633
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a4052633
编写于
7月 29, 2021
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: build
上级
6443dd25
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
254 addition
and
116 deletion
+254
-116
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+31
-2
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+223
-114
未找到文件。
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
a4052633
...
...
@@ -8970,10 +8970,39 @@ var serviceContext = (function (vue) {
});
}
const _adDataCache = {};
function getAdData(data, onsuccess, onerror) {
const { adpid, width } = data;
const key = adpid + '-' + width;
const adDataList = _adDataCache[key];
if (adDataList && adDataList.length > 0) {
onsuccess(adDataList.splice(0, 1)[0]);
return;
}
plus.ad.getAds(data, (res) => {
const list = res.ads;
onsuccess(list.splice(0, 1)[0]);
_adDataCache[key] = adDataList ? adDataList.concat(list) : list;
}, (err) => {
onerror({
errCode: err.code,
errMsg: err.message,
});
});
}
function subscribeAd() {
// view 层通过 UniViewJSBridge.invokeServiceMethod('getAdData', args, function({data})=>{console.log(data)})
registerServiceMethod('getAdData', (args, resolve) => {
// TODO args: view 层传输的参数,处理完之后,resolve:回传给 service,如resolve({data})
getAdData(args, (res) => {
resolve({
code: 0,
data: res,
});
}, (err) => {
resolve({
code: 1,
message: err,
});
});
});
}
...
...
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
a4052633
...
...
@@ -14421,8 +14421,230 @@
super(id2, document.createElement("uni-view"), parentNodeId, refNodeId, nodeJson);
}
}
function getStatusbarHeight() {
return plus.navigator.isImmersedStatusbar() ? Math.round(plus.os.name === "iOS" ? plus.navigator.getSafeAreaInsets().top : plus.navigator.getStatusbarHeight()) : 0;
}
function getNavigationBarHeight() {
const webview2 = plus.webview.currentWebview();
const style = webview2.getStyle();
const titleNView = style && style.titleNView;
if (titleNView && titleNView.type === "default") {
return NAVBAR_HEIGHT + getStatusbarHeight();
}
return 0;
}
const onDrawKey = Symbol("onDraw");
function getFixed($el) {
let fixed;
while ($el) {
const style = getComputedStyle($el);
const transform = style.transform || style.webkitTransform;
fixed = transform && transform !== "none" ? false : fixed;
fixed = style.position === "fixed" ? true : fixed;
$el = $el.parentElement;
}
return fixed;
}
function useNativeAttrs(props2, ignore) {
return computed$1(() => {
const object = {};
Object.keys(props2).forEach((key) => {
if (ignore && ignore.includes(key)) {
return;
}
let val = props2[key];
val = key === "src" ? getRealPath(val) : val;
object[key.replace(/[A-Z]/g, (str) => "-" + str.toLowerCase())] = val;
});
return object;
});
}
function useNative(rootRef) {
const position = reactive({
top: "0px",
left: "0px",
width: "0px",
height: "0px",
position: "static"
});
const hidden = ref(false);
function updatePosition() {
const el = rootRef.value;
const rect = el.getBoundingClientRect();
hidden.value = rect.width === 0 || rect.height === 0;
if (!hidden.value) {
position.position = getFixed(el) ? "absolute" : "static";
const keys = ["top", "left", "width", "height"];
keys.forEach((key) => {
let val = rect[key];
val = key === "top" ? val + (position.position === "static" ? document.documentElement.scrollTop || document.body.scrollTop || 0 : getNavigationBarHeight()) : val;
position[key] = val + "px";
});
}
}
let request = null;
function requestPositionUpdate() {
if (request) {
cancelAnimationFrame(request);
}
request = requestAnimationFrame(() => {
request = null;
updatePosition();
});
}
window.addEventListener("updateview", requestPositionUpdate);
let onDrawCallbacks = [];
let attachedCallback;
function onParentReady(callback) {
const onDraw2 = inject(onDrawKey);
const newCallback = (parentPosition) => {
callback(parentPosition);
onDrawCallbacks.forEach((callback2) => callback2(position));
onDrawCallbacks = null;
};
if (onDraw2) {
onDraw2(newCallback);
} else {
attachedCallback = () => newCallback({
top: "0px",
left: "0px",
width: Number.MAX_SAFE_INTEGER + "px",
height: Number.MAX_SAFE_INTEGER + "px",
position: "static"
});
}
}
const onDraw = function(callback) {
if (onDrawCallbacks) {
onDrawCallbacks.push(callback);
} else {
callback(position);
}
};
provide(onDrawKey, onDraw);
onMounted(() => {
updatePosition();
if (attachedCallback) {
attachedCallback();
}
});
return {
position,
hidden,
onParentReady
};
}
var Ad = /* @__PURE__ */ defineBuiltInComponent({
name: "Ad"
name: "Ad",
props: {
adpid: {
type: [Number, String],
default: ""
},
data: {
type: Object,
default: null
},
dataCount: {
type: Number,
default: 5
},
channel: {
type: String,
default: ""
}
},
setup(props2, {
emit: emit2
}) {
const rootRef = ref(null);
const containerRef = ref(null);
const trigger2 = useCustomEvent(rootRef, emit2);
const attrs2 = useNativeAttrs(props2, ["id"]);
const {
position,
onParentReady
} = useNative(containerRef);
let adView;
onParentReady(() => {
adView = plus.ad.createAdView(Object.assign({}, attrs2.value, position));
plus.webview.currentWebview().append(adView);
adView.setDislikeListener((data) => {
containerRef.value.style.height = "0";
window.dispatchEvent(new CustomEvent("updateview"));
trigger2("close", {}, data);
});
adView.setRenderingListener((data) => {
if (data.result === 0) {
containerRef.value.style.height = data.height + "px";
window.dispatchEvent(new CustomEvent("updateview"));
} else {
trigger2("error", {}, {
errCode: data.result
});
}
});
adView.setAdClickedListener(() => {
trigger2("adclicked", {}, {});
});
watch(() => position, (position2) => adView.setStyle(position2), {
deep: true
});
watch(() => props2.adpid, (val) => {
if (val) {
loadData();
}
});
watch(() => props2.data, (val) => {
if (val) {
adView.renderingBind(val);
}
});
function loadData() {
let args = {
adpid: props2.adpid,
width: position.width,
count: props2.dataCount
};
if (props2.channel !== void 0) {
args.ext = {
channel: props2.channel
};
}
UniViewJSBridge.invokeServiceMethod("getAdData", args, ({
code,
data,
message
}) => {
if (code === 0) {
adView.renderingBind(data);
} else {
trigger2("error", {}, {
errMsg: message
});
}
});
}
if (props2.adpid) {
loadData();
}
});
onBeforeUnmount(() => {
if (adView) {
adView.close();
}
});
return () => {
return createVNode("uni-ad", {
"ref": rootRef
}, {
default: () => [createVNode("div", {
"ref": containerRef,
"class": "uni-ad-container"
}, null, 512)]
}, 512);
};
}
});
class UniComponent extends UniNode {
constructor(id2, tag, component, parentNodeId, refNodeId, nodeJson, selector) {
...
...
@@ -14595,119 +14817,6 @@
}
}
var coverImage = "uni-cover-image {\n display: block;\n line-height: 1.2;\n overflow: hidden;\n height: 100%;\n width: 100%;\n pointer-events: auto;\n}\n\nuni-cover-image[hidden] {\n display: none;\n}\n\nuni-cover-image .uni-cover-image {\n width: 100%;\n height: 100%;\n}\n";
function getStatusbarHeight() {
return plus.navigator.isImmersedStatusbar() ? Math.round(plus.os.name === "iOS" ? plus.navigator.getSafeAreaInsets().top : plus.navigator.getStatusbarHeight()) : 0;
}
function getNavigationBarHeight() {
const webview2 = plus.webview.currentWebview();
const style = webview2.getStyle();
const titleNView = style && style.titleNView;
if (titleNView && titleNView.type === "default") {
return NAVBAR_HEIGHT + getStatusbarHeight();
}
return 0;
}
const onDrawKey = Symbol("onDraw");
function getFixed($el) {
let fixed;
while ($el) {
const style = getComputedStyle($el);
const transform = style.transform || style.webkitTransform;
fixed = transform && transform !== "none" ? false : fixed;
fixed = style.position === "fixed" ? true : fixed;
$el = $el.parentElement;
}
return fixed;
}
function useNativeAttrs(props2, ignore) {
return computed$1(() => {
const object = {};
Object.keys(props2).forEach((key) => {
if (ignore && ignore.includes(key)) {
return;
}
let val = props2[key];
val = key === "src" ? getRealPath(val) : val;
object[key.replace(/[A-Z]/g, (str) => "-" + str.toLowerCase())] = val;
});
return object;
});
}
function useNative(rootRef) {
const position = reactive({
top: "0px",
left: "0px",
width: "0px",
height: "0px",
position: "static"
});
const hidden = ref(false);
function updatePosition() {
const el = rootRef.value;
const rect = el.getBoundingClientRect();
hidden.value = rect.width === 0 || rect.height === 0;
if (!hidden.value) {
position.position = getFixed(el) ? "absolute" : "static";
const keys = ["top", "left", "width", "height"];
keys.forEach((key) => {
let val = rect[key];
val = key === "top" ? val + (position.position === "static" ? document.documentElement.scrollTop || document.body.scrollTop || 0 : getNavigationBarHeight()) : val;
position[key] = val + "px";
});
}
}
let request = null;
function requestPositionUpdate() {
if (request) {
cancelAnimationFrame(request);
}
request = requestAnimationFrame(() => {
request = null;
updatePosition();
});
}
window.addEventListener("updateview", requestPositionUpdate);
let onDrawCallbacks = [];
let attachedCallback;
function onParentReady(callback) {
const onDraw2 = inject(onDrawKey);
const newCallback = (parentPosition) => {
callback(parentPosition);
onDrawCallbacks.forEach((callback2) => callback2(position));
onDrawCallbacks = null;
};
if (onDraw2) {
onDraw2(newCallback);
} else {
attachedCallback = () => newCallback({
top: "0px",
left: "0px",
width: Number.MAX_SAFE_INTEGER + "px",
height: Number.MAX_SAFE_INTEGER + "px",
position: "static"
});
}
}
const onDraw = function(callback) {
if (onDrawCallbacks) {
onDrawCallbacks.push(callback);
} else {
callback(position);
}
};
provide(onDrawKey, onDraw);
onMounted(() => {
updatePosition();
if (attachedCallback) {
attachedCallback();
}
});
return {
position,
hidden,
onParentReady
};
}
let id = 0;
function useCover(rootRef, trigger2, content) {
const { position, hidden, onParentReady } = useNative(rootRef);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录