Files
kengee-data-screen/src/utils/inject.js

157 lines
5.3 KiB
JavaScript
Raw Normal View History

2024-06-27 22:39:41 +08:00
import {dicts} from "@/utils/dicts";
import axios from 'axios'
2024-06-29 13:13:59 +08:00
import Vue from 'vue'
2024-06-27 22:39:41 +08:00
window.axios = axios
2024-07-01 02:32:42 +08:00
const KENGEE_CDN_BASE = "http://10.0.97.209/presource/datascreen"
const libs = [
`${KENGEE_CDN_BASE}/js/pinyin.min.js`,
`${KENGEE_CDN_BASE}/js/dayjs.min.js`,
`${KENGEE_CDN_BASE}/js/Tween.js`,
2024-07-10 01:58:51 +08:00
`${KENGEE_CDN_BASE}/js/three/three.min.js`,
2024-07-01 18:22:37 +08:00
`${KENGEE_CDN_BASE}/js/d3-array.min.js`,
2024-07-01 02:32:42 +08:00
`${KENGEE_CDN_BASE}/js/d3-geo.min.js`,
2024-07-28 16:36:05 +08:00
'/presource/datascreen/js/ezuikit-flv/ezuikit.js',
// '/presource/datascreen/js/ezuikit.js',
2024-07-26 15:32:33 +08:00
'/presource/datascreen/js/clappr.min.js',
2024-07-01 02:32:42 +08:00
]
window.$loadScript = (type = 'js', url, dom = "body") => {
let flag = false;
return new Promise((resolve) => {
const head = dom == 'head' ? document.getElementsByTagName('head')[0] : document.body;
for (let i = 0; i < head.children.length; i++) {
let ele = head.children[i]
if ((ele.src || '').indexOf(url) !== -1) {
flag = true;
resolve();
}
}
if (flag) return;
let script;
if (type === 'js') {
script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
} else if (type === 'css') {
script = document.createElement('link');
script.rel = 'stylesheet';
script.type = 'text/css';
script.href = url;
}
head.appendChild(script);
script.onload = function () {
resolve();
};
});
};
window.$glob = {token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJoLXVzZXItaWQiOiIxODA4MDM2NzI3NzQzNDU1MjMyIiwiaC1yb2xlLWlkIjoiMTgwODAzNjg5NDQxMjUxMzI4MCIsImV4cCI6MTc1MTQ0NDg0MywibmJmIjoxNzE5OTA4ODQzfQ.Wi6wzArP79mFj3XEzSendOfWHJc1mNuSAlAC1W4zMzI"}
2024-06-27 22:39:41 +08:00
window.$dicts = dicts
window.$waitFor = (target, t = 500) => new Promise(resolve => {
const interval = setInterval(() => {
if (target) {
clearInterval(interval)
resolve(target)
}
}, t)
if (target) {
clearInterval(interval)
resolve(target)
}
})
2024-07-05 17:36:16 +08:00
window.evenRowBGC = (color = "#09265B") => `transparent;background-image: linear-gradient(-45deg, ${color} 0, ${color} 10%, transparent 10%, transparent 50%,${color} 50%, ${color} 60%, transparent 60%, transparent);background-size: 10px 10px;`
2024-06-29 13:13:59 +08:00
Vue.prototype.$marketBoard = Vue.observable({
2024-07-15 02:19:48 +08:00
screenId: '5b1849ac-4fc3-451a-844c-3362b47341ef',
search: {"groupCodeList": [], "currentDate": "20240701", "compareDate": "20240630", "hourNum": "18"}
2024-06-29 13:13:59 +08:00
})
Vue.prototype.$multipleStoreBoard = Vue.observable({
2024-07-07 11:27:52 +08:00
search: {"groupCodeList": [], "hourNum": "", type: "1"}
2024-06-29 13:13:59 +08:00
})
Vue.prototype.$storeBoard = Vue.observable({
2024-07-08 18:53:50 +08:00
currentDate: "20240705",
dialog: false,
aroundStock: [],
2024-07-07 22:42:40 +08:00
query: {},
2024-06-29 13:13:59 +08:00
search: {}
})
2024-07-25 18:09:46 +08:00
Vue.component("HlsPlayer", {
render: (h) => h('div', {style: {width: '100%', height: '100%'}}),
props: {
2024-07-28 16:36:05 +08:00
id: {default: ""},
2024-07-25 18:09:46 +08:00
url: {default: "https://open.ys7.com/v3/openlive/155715496_1_1.m3u8?expire=1747359002&id=712960386311127040&t=c9c6ad362940b1fb4ea7a736cec78980aa9ad1d27d6e3eddf75788c0564e9d7b&ev=100"}
},
2024-07-28 16:36:05 +08:00
data() {
return {
player: null
}
},
2024-07-25 18:09:46 +08:00
mounted() {
2024-07-28 16:36:05 +08:00
const {Clappr, EzuikitFlv, EZUIKit} = window
if (EzuikitFlv && this.url) {
const {id} = this.$props
this.$el.id = id
this.player = new EzuikitFlv({
container: id,
url: this.url,
decoder: "/presource/datascreen/js/ezuikit-flv/decoder.js"
2024-07-26 15:32:33 +08:00
})
2024-07-28 16:36:05 +08:00
this.player.play()
2024-07-25 18:09:46 +08:00
}
2024-07-28 16:36:05 +08:00
// if (EZUIKit && this.url) {
// const {id} = this.$props
// this.$el.id = id
// this.player = new EZUIKit.EZUIKitPlayer({
// id, // 视频容器ID
// width: '100%', // 播放器宽度,播放器高度会按比例缩放
// height: '100%',
// accessToken: 'at.c1lrqlq7ae1hj18tbpe9q8ip4hhrbfcw-7ax2lsg0rz-06anrcm-tcd5wjaz9',
// url: 'ezopen://open.ys7.com/BA9983755/1.live',
// })
// this.player.play()
// }
// if (Clappr && this.url) {
// this.player = new Clappr.Player({
// mute: true, //静音为true
// width: '100%',
// height: '100%',
// source: this.url,
// autoPlay: true,
// disableCanAutoPlay: true, //禁用检测浏览器是否可以自动播放视频
// hideMediaControl: true, //禁用媒体控制自动隐藏
// hideMediaControlDelay: 100, //更改默认的媒体控件自动隐藏超时值
// hideVolumeBar: true, //当嵌入的宽度小于320时音量条将被隐藏
// exitFullscreenOnEnd: false, //禁用播放器将在媒体结束时自动退出全屏显示,即播放结束后不会退出全屏
// mediacontrol: {seekbar: "#000", buttons: "#FFF"}, //定义进度条和底部暂停等图标的颜色
// })
// this.player.attachTo(this.$el)
// }
},
beforeDestroy() {
this.player?.destroy()
2024-07-25 18:09:46 +08:00
}
})
2024-06-29 13:30:06 +08:00
Vue.component("tableColumn", {
props: {
column: {default: () => ({})}
},
render(h) {
const config = this.$props.column
2024-06-30 15:04:47 +08:00
return h('el-table-column', {props: {...config, label: `${config.label}` || "-"}},
2024-06-29 13:30:06 +08:00
config.children?.map(col => h("tableColumn", {props: {column: col}})) || h('template', {
slotScope: {
default: ({row}) => {
config.custom ? h('div', {style: {color: row.preSaleNum > row.stockNum ? 'red' : '#fff'}}, '周边库存情况') :
h('span', row[config.prop] || '')
}
}
}))
},
})
2024-06-27 22:39:41 +08:00
export default Promise.all([
2024-06-21 11:51:14 +08:00
import("./fetch"),
2024-07-01 02:32:42 +08:00
...libs.map(url => $loadScript('js', url)),
2024-06-21 11:51:14 +08:00
])