@ued_fpi/data-visual
Version:
<br /> <br /> <div style="text-align:center"> <b style="font-size:30px">@ued_fpi/data-visual</b> <p>基于Vite4+TypeScript的Vue3大屏组件库开发框架</p> <img style="display:inline" src="https://img.shields.io/npm/v/@ued_fpi/data-visual" />
68 lines (63 loc) • 2.12 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const vue = require('vue');
const vegetation = require('./images/vegetation.png.js');
const index = require('./api/index.js');
const _hoisted_1 = { class: "dv-wgms-vegetation-monitoring" };
const _hoisted_2 = ["src"];
const _hoisted_3 = {
key: 1,
class: "monitoring-placeholder"
};
const _hoisted_4 = /* @__PURE__ */ vue.createElementVNode("img", {
src: vegetation.default,
class: "monitoring-image"
}, null, -1);
const _hoisted_5 = [
_hoisted_4
];
const FILE_PREVIEW_BASE_URL = "/file-base-server/api/v1/sys/download";
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...{
name: "DvWgmsVegetationMonitoring",
title: "植被监测"
},
__name: "index",
props: {
imageUrl: { default: "" }
},
setup(__props) {
const props = __props;
const apiImageUrl = vue.ref("");
const formatImageUrl = (imageUrl) => {
if (!imageUrl)
return "";
if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://"))
return imageUrl;
return `${FILE_PREVIEW_BASE_URL}/${imageUrl}`;
};
const displayImageUrl = vue.computed(() => props.imageUrl || apiImageUrl.value);
const loadData = async () => {
const res = await index.getVegetationMonitoring();
const list = Array.isArray(res) ? res : Array.isArray(res?.data) ? res.data : [];
apiImageUrl.value = formatImageUrl(list[0]?.vegetationImageUrl);
};
vue.onMounted(() => {
if (!props.imageUrl) {
loadData().catch(() => {
apiImageUrl.value = "";
});
}
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
displayImageUrl.value ? (vue.openBlock(), vue.createElementBlock("img", {
key: 0,
src: displayImageUrl.value,
class: "monitoring-image"
}, null, 8, _hoisted_2)) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, _hoisted_5))
]);
};
}
});
exports.default = _sfc_main;