Merge branch 'develop' of http://xny.yj-3d.com:3000/zh/sdk4.0 into develop

This commit is contained in:
2025-08-22 18:32:13 +08:00
59 changed files with 3735 additions and 488 deletions

View File

@ -55,6 +55,9 @@ class EventBinding {
if ((e.target.min) && value < Number(e.target.min)) {
value = Number(e.target.min)
}
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
value = Number(e.target.dataset.min)
}
that[m.value] = value
}
}

View File

@ -2,13 +2,10 @@ import BaseDialog from '../../../BaseDialog';
class Dialog extends BaseDialog {
constructor(sdk, info, options, only) {
super(sdk.viewer._container, options);
super(sdk.viewer._container, options, only);
this.sdk = sdk
this.viewer = sdk.viewer
this.info = info
if (only) {
this.closeAll()
}
this._init()
}

View File

@ -1,6 +1,13 @@
class cy_tabs {
constructor(id, clickTabCallBack, sdk) {
let elm = document.getElementById(id);
constructor(boxElm, clickTabCallBack, sdk) {
let elm
if(typeof boxElm === 'string') {
elm = document.getElementById(boxElm);
}
else {
elm = boxElm
}
// let elm = document.getElementById(id);
let pane = elm.getElementsByTagName('DIV-cy-tab-pane')
let tabTop = `<div class="DIV-cy-tab-top">`
@ -37,7 +44,9 @@
tabContent = tabContent + `</div>`
let BoxElm = document.createElement('div');
BoxElm.setAttribute('id', id)
if(typeof boxElm === 'string') {
BoxElm.setAttribute('id', boxElm)
}
BoxElm.setAttribute('class', 'DIV-cy-tabs')
BoxElm.innerHTML = tabTop + tabContent
elm.parentNode.insertBefore(BoxElm, elm);

View File

@ -56,8 +56,8 @@ class richText {
MENU_CONF: {
uploadImage: {
fieldName: 'file',
maxFileSize: 50 * 1024 * 1024,
base64LimitSize: 50 * 1024 * 1024, // 50M 以下插入 base64
// maxFileSize: 50 * 1024 * 1024,
// base64LimitSize: 50 * 1024 * 1024, // 50M 以下插入 base64
server: this.uploadImageServer,
// // 上传之前触发
// onBeforeUpload(file) { // TS 语法
@ -95,18 +95,18 @@ class richText {
// console.log(`${file.name} 上传出错`, err, res)
// },
// // 自定义上传
// async customUpload(file, insertFn) { // TS 语法
// // async customUpload(file, insertFn) { // JS 语法
// // file 即选中的文件
// // 自己实现上传,并得到图片 url alt href
// // 最后插入图片
// console.log(file, insertFn)
// insertFn(url, file.name)
// }
// 自定义上传
async customUpload(file, insertFn) { // TS 语法
// async customUpload(file, insertFn) { // JS 语法
// file 即选中的文件
// 自己实现上传,并得到图片 url alt href
// 最后插入图片
let url = await _this.upload(file)
insertFn((_this.host = _this.host || getHost()) + '/' + url)
}
},
uploadVideo: {
maxFileSize: 500 * 1024 * 1024,
// maxFileSize: 500 * 1024 * 1024,
server: this.uploadVideoServer,
allowedFileTypes: ['video/mp4', 'video/mp3', 'video/ogg', 'video/webm', 'video/avi'],
// 自定义上传

View File

@ -1,4 +1,4 @@
let list = ['icon-py', 'icon-edit', 'icon-add', 'icon-add2', 'icon-minus', 'icon-play', 'icon-pause', 'icon-updateheight', 'icon-draw', 'icon-positions', 'icon-reset', 'icon-xj', 'icon-yj', 'icon-zj', 'icon-close', 'icon-query', 'icon-route', 'icon-copy', 'icon-load', 'icon-rubric', 'icon-pen', 'icon-cross']
let list = ['icon-py', 'icon-edit', 'icon-add', 'icon-add2', 'icon-minus', 'icon-play', 'icon-pause', 'icon-updateheight', 'icon-draw', 'icon-positions', 'icon-reset', 'icon-xj', 'icon-yj', 'icon-zj', 'icon-close', 'icon-query', 'icon-route', 'icon-copy', 'icon-load', 'icon-rubric', 'icon-pen', 'icon-cross', 'icom-confirm']
function setSvg() {
let svgElm = document.createElement('svg');
svgElm.xmlns = 'http://www.w3.org/2000/svg'

View File

@ -1,7 +1,11 @@
class YJColorPicker {
constructor(options = {}) {
let _this = this
let pickAlphaInput
let RInput
let GInput
let BInput
let AInput
let config = {
el: options.el,
size: "mini",
@ -12,18 +16,22 @@ class YJColorPicker {
hasClear: true,
openPickerAni: 'opacity',
defaultColor: options.defaultColor,
pickerInputChange: pickerInputChange,
startMainCallback: (t) => {
customizeStyle()
_this.colorPicker && (_this.colorPicker.picker.style.opacity = 0)
setTimeout(() => {
customizeStyle()
}, 0);
}
}
this.el = options.el
if (options.sure) {
config.sure = (color) => {
this.colorPicker.config.defaultColor = this.colorPicker.pickerInput.value
// this.colorPicker.config.defaultColor = this.colorPicker.pickerInput.value
let c = Cesium.Color.fromCssColorString(color)
if (pickAlphaInput) {
c = c.withAlpha(pickAlphaInput.value / 100)
this.pickAlphaInputValue = pickAlphaInput.value
if (AInput) {
c = c.withAlpha(AInput.value)
this.pickAlphaInputValue = AInput.value
}
color = c.toCssHexString()
if (typeof options.sure == 'function') {
@ -34,8 +42,8 @@ class YJColorPicker {
}
if (options.clear) {
config.clear = () => {
if (pickAlphaInput) {
pickAlphaInput.value = this.pickAlphaInputValue = 100
if (AInput) {
AInput.value = this.pickAlphaInputValue = 1
}
this.colorPicker.config.defaultColor = ''
customizeStyle()
@ -53,7 +61,7 @@ class YJColorPicker {
}
}
let CesiumColor
if(config.defaultColor) {
if (config.defaultColor) {
CesiumColor = Cesium.Color.fromCssColorString(config.defaultColor)
}
// if (options.predefineColor) {
@ -66,42 +74,172 @@ class YJColorPicker {
customizeStyle()
function customizeStyle() {
if (!_this.colorPicker) {
if (!_this.colorPicker || !_this.colorPicker.picker) {
return
}
let isSubtract = false
let box = _this.colorPicker.box
let picker = _this.colorPicker.picker
let x = box.getBoundingClientRect().x
let y = box.getBoundingClientRect().y
let height = 0
// if (picker.style.display === 'none') {
// picker.style.display = 'block'
// height = picker.offsetHeight
// console.log('picker.style.display.opacity', picker.style.display.opacity)
// picker.style.display = 'none'
// }
// console.log('===========================================')
// console.log((y + box.offsetHeight + 4), height, window.innerHeight)
// if ((y + box.offsetHeight + 4) + height > window.innerHeight) {
// console.log(y, height)
// picker.style.top = y - height + 'px'
// }
// else {
// picker.style.top = (y + box.offsetHeight + 4) + 'px'
// }
picker.style.left = x + 'px'
picker.style.minWidth = '325px'
let pickerContent = picker.getElementsByClassName('ew-color-picker-content')[0]
// let pickerContent = picker.getElementsByClassName('ew-color-picker-content')[0]
let pickAlphaSliderBar = picker.getElementsByClassName('ew-alpha-slider-bar')[0]
if (pickAlphaSliderBar) {
pickAlphaSliderBar.parentNode.style.width = '16px'
pickAlphaSliderBar.parentNode.removeChild(pickAlphaSliderBar)
}
// let customDivider = document.createElement('span')
// customDivider.className = 'custom-divider'
// customDivider.style.margin = '10px 0'
// pickerContent.parentNode.insertBefore(customDivider, pickerContent.nextSibling)
let pickPen = document.createElement('div')
pickPen.className = 'icon-pen-box'
pickPen.innerHTML = '<svg class="icon-pen"><use xlink:href="#yj-icon-pen"></use></svg>'
/** 为完成、暂时隐藏 *///////
pickPen.style.display = 'none'
pickPen.style.cursor = 'unset'
let pickerInput = _this.colorPicker.pickerInput
pickerInput.parentNode.insertBefore(pickPen, pickerInput)
pickerInput.style.width = '188px'
pickerInput.style.display = 'none'
let colorInputBox = document.createElement('div')
let row1Elm = document.createElement('div')
row1Elm.className = 'row'
row1Elm.style.margin = '6px 0 0 0'
row1Elm.innerHTML = `
<div class="col">R</div>
<div class="col">G</div>
<div class="col">B</div>
<div class="col" style="flex: 0 0 92px;"></div>
`
let row2Elm = document.createElement('div')
row2Elm.className = 'row'
row2Elm.innerHTML = `
<div class="col">
<input type="number" step="1" min="0" max="255">
</div>
<div class="col">
<input type="number" step="1" min="0" max="255">
</div>
<div class="col">
<input type="number" step="1" min="0" max="255">
</div>
`
colorInputBox.appendChild(row1Elm)
colorInputBox.appendChild(row2Elm)
let Inputs = row2Elm.getElementsByTagName('input')
Inputs[0].style.width = '72px'
Inputs[1].style.width = '72px'
Inputs[2].style.width = '72px'
RInput = Inputs[0]
GInput = Inputs[1]
BInput = Inputs[2]
let dropbtns = picker.getElementsByClassName('ew-color-dropbtns')[0]
picker.insertBefore(colorInputBox, dropbtns)
RInput.addEventListener('blur', (e) => {
let value = e.target.value
if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) {
value = Number(value)
if ((e.target.max) && value > Number(e.target.max)) {
value = Number(e.target.max)
}
if ((e.target.min) && value < Number(e.target.min)) {
value = Number(e.target.min)
}
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
value = Number(e.target.dataset.min)
}
RInput.value = parseInt(value)
_this.colorPicker.hsba = colorRgbaToHsba(`rgb(${RInput.value}, ${GInput.value}, ${BInput.value})`)
_this.colorPicker.changeColor(_this.colorPicker, _this.colorPicker.pickerPanel.offsetWidth,_this.colorPicker.pickerPanel.offsetHeight)
}
})
GInput.addEventListener('blur', (e) => {
let value = e.target.value
if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) {
value = Number(value)
if ((e.target.max) && value > Number(e.target.max)) {
value = Number(e.target.max)
}
if ((e.target.min) && value < Number(e.target.min)) {
value = Number(e.target.min)
}
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
value = Number(e.target.dataset.min)
}
GInput.value = parseInt(value)
_this.colorPicker.hsba = colorRgbaToHsba(`rgb(${RInput.value}, ${GInput.value}, ${BInput.value})`)
_this.colorPicker.changeColor(_this.colorPicker, _this.colorPicker.pickerPanel.offsetWidth,_this.colorPicker.pickerPanel.offsetHeight)
}
})
BInput.addEventListener('blur', (e) => {
let value = e.target.value
if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) {
value = Number(value)
if ((e.target.max) && value > Number(e.target.max)) {
value = Number(e.target.max)
}
if ((e.target.min) && value < Number(e.target.min)) {
value = Number(e.target.min)
}
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
value = Number(e.target.dataset.min)
}
BInput.value = parseInt(value)
_this.colorPicker.hsba = colorRgbaToHsba(`rgb(${RInput.value}, ${GInput.value}, ${BInput.value})`)
_this.colorPicker.changeColor(_this.colorPicker, _this.colorPicker.pickerPanel.offsetWidth,_this.colorPicker.pickerPanel.offsetHeight)
}
})
if (options.alpha) {
Inputs[0].style.width = '52px'
Inputs[1].style.width = '52px'
Inputs[2].style.width = '52px'
let pickAlpha = document.createElement('div')
pickAlpha.className = 'input-number input-number-unit-1 color-alpha'
pickAlpha.className = 'input-number input-number-unit color-alpha'
pickAlpha.innerHTML = `
<input class="input" type="number" title="" step="0.01" min="0" max="100">
<span class="unit">%</span>
<input class="input" type="number" title="" step="0.01" min="0" max="1">
<span class="arrow"></span>`
pickerInput.parentNode.insertBefore(pickAlpha, pickerInput.nextSibling)
pickerInput.style.width = '106px'
pickAlpha.style.width = '80px'
pickAlphaInput = pickAlpha.getElementsByClassName('input')[0]
pickAlphaInput.addEventListener('blur', (e) => {
pickAlpha.style.width = '66px'
pickAlpha.style.margin = '0 6px 0 0'
AInput = pickAlpha.getElementsByClassName('input')[0]
row1Elm.innerHTML = `
<div class="col">R</div>
<div class="col">G</div>
<div class="col">B</div>
<div class="col">A</div>
<div class="col" style="flex: 0 0 106px;"></div>
`
row2Elm.appendChild(pickAlpha)
AInput.addEventListener('blur', (e) => {
let value = e.target.value
if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) {
value = Number(value)
@ -114,23 +252,26 @@ class YJColorPicker {
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
value = Number(e.target.dataset.min)
}
pickAlphaInput.value = Number(value.toFixed(2))
AInput.value = parseInt(value * 100) / 100
}
})
if (_this.pickAlphaInputValue || _this.pickAlphaInputValue === 0 || _this.pickAlphaInputValue === '0') {
pickAlphaInput.value = Number(Number(_this.pickAlphaInputValue).toFixed(2))
AInput.value = parseInt(_this.pickAlphaInputValue * 100) / 100
}
else {
pickAlphaInput.value = CesiumColor ? Number((CesiumColor.alpha * 100).toFixed(2)) : 100
AInput.value = CesiumColor ? parseInt(Number(CesiumColor.alpha.toFixed(2)) * 100) / 100 : 1
}
_this.pickAlphaInputValue = pickAlphaInput.value
box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').withAlpha(pickAlphaInput.value / 100).toCssColorString()
_this.pickAlphaInputValue = AInput.value
box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').withAlpha(AInput.value).toCssColorString()
}
else {
CesiumColor = CesiumColor ? CesiumColor.withAlpha(1) : ''
box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').toCssColorString()
}
let btngroup = picker.getElementsByClassName('ew-color-dropbtngroup')[0]
row2Elm.appendChild(btngroup)
let defineColorContainer = picker.getElementsByClassName('ew-pre-define-color-container')[0]
if (defineColorContainer) {
let colorList = localStorage.getItem('custom-color')
@ -157,8 +298,10 @@ class YJColorPicker {
addColorBtn.className = 'yj-pre-collect-color add'
let subtractColorBtn = document.createElement('div')
subtractColorBtn.innerHTML = '<svg class="icon-minus"><use xlink:href="#yj-icon-minus"></use></svg>'
subtractColorBtn.innerHTML = '<svg class="icon-minus" style="display: unset;"><use xlink:href="#yj-icon-minus"></use></svg><svg class="icon-confirm" style="display: none;"><use xlink:href="#yj-icom-confirm"></use></svg>'
subtractColorBtn.className = 'yj-pre-collect-color subtract'
let minusIcon = subtractColorBtn.getElementsByClassName('icon-minus')[0]
let confirmIcon = subtractColorBtn.getElementsByClassName('icon-confirm')[0]
collectColorContainer.appendChild(addColorBtn)
collectColorContainer.appendChild(subtractColorBtn)
@ -217,8 +360,8 @@ class YJColorPicker {
let color = colorRgbaToHex(colorHsbaToRgba(_this.colorPicker.hsba))
let c = Cesium.Color.fromCssColorString(color || '#ffffff')
if (pickAlphaInput) {
c = c.withAlpha(pickAlphaInput.value / 100)
if (AInput) {
c = c.withAlpha(AInput.value)
}
let colorString = c.toCssHexString()
colorItemElm.style.backgroundColor = colorString
@ -252,23 +395,43 @@ class YJColorPicker {
subtractColorBtn.addEventListener('click', () => {
isSubtract = !isSubtract
if (isSubtract) {
minusIcon.style.display = 'none'
confirmIcon.style.display = 'unset'
for (let i = 0; i < subtractElmList.length; i++) {
subtractElmList[i].style.display = 'block'
}
}
else {
minusIcon.style.display = 'unset'
confirmIcon.style.display = 'none'
for (let i = 0; i < subtractElmList.length; i++) {
subtractElmList[i].style.display = 'none'
}
}
})
}
height = picker.offsetHeight
if (picker.style.display === 'none') {
picker.style.display = 'block'
height = picker.offsetHeight
picker.style.display = 'none'
}
if ((y + box.offsetHeight + 4) + height > window.innerHeight) {
picker.style.top = y - height + 'px'
}
else {
picker.style.top = (y + box.offsetHeight + 4) + 'px'
}
_this.colorPicker.pancelTop = parseFloat(picker.style.top) - 2
pickerInputChange(Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').toCssHexString())
}
function clickDefineColor(color) {
if (pickAlphaInput) {
if (AInput) {
let c = Cesium.Color.fromCssColorString(color)
pickAlphaInput.value = Number((c.alpha * 100).toFixed(2))
AInput.value = parseInt(Number(c.alpha.toFixed(2)) * 100) / 100
}
}
@ -321,6 +484,84 @@ class YJColorPicker {
"#" + n
}
}
function colorHexToRgba(hex, alpha) {
let a = alpha || 1,
hColor = hex.toLowerCase(),
hLen = hex.length,
rgbaColor = [];
hColor = Cesium.Color.fromCssColorString(hColor).toCssHexString().substring(0, 7)
const colorRegExp = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
if (hex && colorRegExp.test(hColor)) {
//the hex length may be 4 or 7,contained the symbol of #
if (hLen === 4) {
let hSixColor = '#';
for (let i = 1; i < hLen; i++) {
let sColor = hColor.slice(i, i + 1);
hSixColor += sColor.concat(sColor);
}
hColor = hSixColor;
}
for (let j = 1, len = hColor.length; j < len; j += 2) {
rgbaColor.push(parseInt('0X' + hColor.slice(j, j + 2), 16));
}
// return "rgba(" + rgbaColor.join(",") + ',' + a + ")";
return rgbaColor;
} else {
return;
}
}
function colorRgbaToHsba(e) {
var t = e.slice(e.indexOf("(") + 1, e.lastIndexOf(")")).split(",")
, r = t.length < 4 ? 1 : Number(t[3])
, n = Number(t[0]) / 255
, o = Number(t[1]) / 255
, i = Number(t[2]) / 255
, a = void 0
, s = void 0
, l = void 0
, c = Math.min(n, o, i)
, d = l = Math.max(n, o, i)
, u = d - c;
if (d === c)
a = 0;
else {
switch (d) {
case n:
a = (o - i) / u + (o < i ? 6 : 0);
break;
case o:
a = 2 + (i - n) / u;
break;
case i:
a = 4 + (n - o) / u
}
a = Math.round(60 * a)
}
s = 0 === d ? 0 : 1 - c / d;
return s = Math.round(100 * s),
l = Math.round(100 * l),
{
h: a,
s: s,
b: l,
a: r
}
}
function pickerInputChange(v) {
if (_this.colorPicker && _this.colorPicker.pickerInput) {
let rgbaColor = colorHexToRgba(v || _this.colorPicker.pickerInput.value)
RInput.value = rgbaColor[0]
GInput.value = rgbaColor[1]
BInput.value = rgbaColor[2]
}
}
}
}