wx-h5-fontsize-fixed
Version:
本组件库由有爱开发团队开发,解决微信页面被老人机字体调整大小特别丑的痛点
98 lines (97 loc) • 3.57 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
var stdin_exports = {};
__export(stdin_exports, {
default: () => stdin_default
});
module.exports = __toCommonJS(stdin_exports);
var import_vue = require("vue");
var import_vue2 = require("vue");
const fontsizeFixedProps = {
enable: {
type: Boolean,
default: true,
required: true
}
};
var stdin_default = (0, import_vue2.defineComponent)({
name: "fontsize-fixed",
props: fontsizeFixedProps,
setup: (props) => {
const getInitFunc = () => {
if (props == null ? void 0 : props.enable) {
var style = "body {\n -webkit-text-size-adjust: 100% !important;\n text-size-adjust: 100% !important;\n -moz-text-size-adjust: 100% !important;\n}\n";
var ele = document.createElement("style");
ele.innerHTML = style;
document.getElementsByTagName("head")[0].appendChild(ele);
(function() {
console.log(window.WeixinJSBridge, "wxh5-WeixinJSBridge");
if (typeof window.WeixinJSBridge == "object" && typeof window.WeixinJSBridge.invoke == "function") {
handleFontSize();
} else {
if (document.addEventListener) {
document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
} else if (document.attachEvent) {
document.attachEvent("WeixinJSBridgeReady", handleFontSize);
document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
}
}
function handleFontSize() {
console.log(window.WeixinJSBridge, "wxh5-WeixinJSBridge2");
window.WeixinJSBridge.invoke("setFontSizeCallback", {
fontSize: 0
});
window.WeixinJSBridge.on("menu:setfont", () => {
window.WeixinJSBridge.invoke("setFontSizeCallback", {
fontSize: 0
});
});
}
})();
}
};
(0, import_vue2.onMounted)(() => __async(void 0, null, function* () {
getInitFunc();
}));
const slots = (0, import_vue2.useSlots)();
return () => {
var _a;
return (0, import_vue.createVNode)(import_vue.Fragment, null, [(_a = slots == null ? void 0 : slots.default) == null ? void 0 : _a.call(slots)]);
};
}
});