sync sample.

This commit is contained in:
lchen committed 2026-11-24 13:23:02 +08:00
1 parent f9efaec884
commit 29a327ff02
4 files changed
+236 -118

No files matched your search

+162 -68
View File
@@ -10,21 +10,20 @@ import '../lib/global.d.ts';
import { createElement } from '../lib/functions';
import { Grid } from '../lib/ui/grid/grid';
import { toDateValue } from '../lib/ui/date';
import { showConfirm } from '../lib/ui/popup';
import { Popup, showAlert, showConfirm, showInput } from '../lib/ui/popup';
import { init } from '../lib/utility';
import { appendResizer, makeMovable } from '../lib/drag';
import { appendResizer, makeMovable } from '../lib/ui/movable';
import { Dropdown } from '../lib/ui/dropdown';
// document.querySelector('#js-logo').src = javascriptLogo
window.consts = {
path: '/',
path: '',
resver: 20231218,
prefix: ''
};
const snapPool: HTMLDivElement[] = [];
window.addEventListener('DOMContentLoaded', () => {
window.addEventListener('DOMContentLoaded', async () => {
const container = document.body.querySelector<HTMLElement>('.wrapper');
if (container == null) {
return;
@@ -41,7 +40,7 @@ window.addEventListener('DOMContentLoaded', () => {
);
p.style.cssText += `
left: ${Math.round(Math.random() * 800)}px;
top: ${Math.round(Math.random() * 800)}px;
top: ${Math.round(Math.random() * 500)}px;
width: ${Math.round(Math.random() * 300) + 200}px;
height: ${Math.round(Math.random() * 300) + 200}px;
`;
@@ -52,58 +51,114 @@ window.addEventListener('DOMContentLoaded', () => {
makeMovable(container, {
movable: true,
resizable: true,
snapThreshold: 5,
onSnap(guides) {
const maxX = Math.max(container.clientWidth, container.scrollWidth) - 1;
const maxY = Math.max(container.clientHeight, container.scrollHeight) - 1;
for (let i = 0; i < guides.length; i++) {
let line = snapPool[i];
if (!line) {
line = document.createElement('div');
container.appendChild(line);
snapPool.push(line);
}
const { axis, pos, start, end } = guides[i];
const len = Math.max(0, Math.round(end - start));
if (axis === 'x') {
const left = Math.max(0, Math.min(Math.round(pos), maxX));
const top = Math.round(start);
line.className = 'snap-line line-x';
line.style.width = '1px';
line.style.height = `${len}px`;
line.style.transform = `translate(${left}px, ${top}px)`;
} else {
const top = Math.max(0, Math.min(Math.round(pos), maxY));
const left = Math.round(start);
line.className = 'snap-line line-y';
line.style.width = `${len}px`;
line.style.height = '1px';
line.style.transform = `translate(${left}px, ${top}px)`;
}
line.style.display = 'block';
}
for (let i = guides.length; i < snapPool.length; i++) {
snapPool[i].style.display = 'none';
}
}
snapThreshold: 10
});
new Popup({
title: 'title',
content: createElement('div', div => {
div.style.backgroundColor = '#ccc';
div.innerText = 'test';
}),
movable: true,
resizable: true,
buttons: [
{
key: 'ok',
text: 'Ok',
trigger(popup) {
console.log(this, popup);
},
}
]
}).show();
// const r = await showAlert('Popup', 'all prepared.');
/*/
const r = await showConfirm('Confirm', 'confirm message', [
{
key: 'TRUE',
text: 'yes',
trigger(popup, button) {
console.log('button trigger.');
return new Promise(resolve => {
setTimeout(resolve, 2000);
});
},
},
{
key: 'FALSE',
text: 'no'
}
]);//*/
// const r = await showInput('Input', true, 'Type message here.', {
// oninput(e: InputEvent) {
// console.log(e);
// }
// });
// console.log(r);
});
// const DateSelector = window['lib-ui'].DateSelector;
// const formatDate = window['lib-ui'].formatDate;
/*/
var dropdown = new Dropdown({
search: true,
multiSelect: true,
selectedList: ['beijing', 'hebei']
});
dropdown.source = [
{
value: 'beijing',
text: '北京市'
},
{
value: 'hebei',
text: '河北省',
children: [
{
value: 'shijiazhuang',
text: '石家庄市'
},
{
value: 'tangshan',
text: '唐山市'
}
]
},
{
value: 'chongqing',
text: '重庆市',
children: [
{
value: 'yuzhongqu',
text: '渝中区'
}
]
},
{
value: 'jiangsu',
text: '江苏省',
children: [
{
value: 'nanjing',
text: '南京市'
},
{
value: 'xuzhou',
text: '徐州市'
},
{
value: 'suzhou',
text: '苏州市'
}
]
}
];
// window.addEventListener('load', () => {
// DateSelector.resolve(document.querySelector('#container'), function (date) {
// console.log(`element(#${this.element.id}), date changed to: ${formatDate(date)}`);
const wrapper = dropdown.create();
wrapper.style.minWidth = '220px';
document.querySelector('#container')?.replaceChildren(wrapper);
// const value = document.querySelector('#dateFrom').value;
// console.log(`dateFrom.value = '${value}', formatted: '${formatDate(value)}'`);
// });
// });
/*/
/*/
window.addEventListener('load', () => {
@@ -217,11 +272,11 @@ window.addEventListener('load', () => {
return String(count).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
};
grid.columns = [
{ key: 'name', caption: '包名称', type: Grid.ColumnTypes.Input },
{ key: 'version', caption: '版本号' },
{ key: 'name', caption: '包名称', type: Grid.ColumnTypes.Input, enabled: item => !item.version },
{ key: 'version', caption: '版本号', type: Grid.ColumnTypes.Input, enabled: item => !item.name },
{ key: 'author', caption: '作者' },
{ key: 'count', caption: '下载量', filter: getCountFilter('count'), align: 'right' },
{ key: 'mauiName', caption: 'Maui 对应包' },
{ key: 'mauiName', caption: 'Maui 对应包', allowFilter: true },
{ key: 'mauiVersion', caption: '版本号' },
{ key: 'mauiNet', caption: '.NET' },
{ key: 'mauiCount', caption: '下载量', filter: getCountFilter('mauiCount'), align: 'right' }
@@ -235,17 +290,19 @@ window.addEventListener('load', () => {
mauiName: 'Dynatrace.OneAgent.MAUI',
mauiVersion: '1.283.1',
mauiNet: '7.0',
mauiCount: 12351
},
{
name: 'Esri.ArcGISRuntime.Xamarin.Forms',
version: '100.15.4',
author: 'Esri_Inc',
count: 249909,
mauiName: 'Esri.ArcGISRuntime.Maui',
mauiVersion: '200.3.0',
mauiNet: '8.0',
mauiCount: 40913
mauiCount: 12351,
__children: [
{
name: 'Esri.ArcGISRuntime.Xamarin.Forms',
version: '100.15.4',
author: 'Esri_Inc',
count: 249909,
mauiName: 'Esri.ArcGISRuntime.Maui',
mauiVersion: '200.3.0',
mauiNet: '8.0',
mauiCount: 40913
},
]
},
{
name: 'Scandit.DataCapture.Core.Xamarin',
@@ -312,6 +369,43 @@ window.addEventListener('load', () => {
window.grid = grid;
});//*/
// const DateSelector = window['lib-ui'].DateSelector;
// const formatDate = window['lib-ui'].formatDate;
// window.addEventListener('load', () => {
// DateSelector.resolve(document.querySelector('#container'), function (date) {
// console.log(`element(#${this.element.id}), date changed to: ${formatDate(date)}`);
// const value = document.querySelector('#dateFrom').value;
// console.log(`dateFrom.value = '${value}', formatted: '${formatDate(value)}'`);
// });
// });
/*
const createVideoList = window['lib-ui'].createVideoList;
window.addEventListener('load', () => {
document.querySelector('#container').append(
createVideoList([
'http://192.168.25.95/ironintel/Temp/9fdd0f0c03c22c10204e7efaf80eb005.mp4',
'http://192.168.25.95/ironintel/Temp/9fdd0f0c03c22c10204e7efaf80eb005.mp4'
], {
autoPlay: true
})
);
});
*/
/*
const Grid = window['lib-ui'].Grid;
const createElement = window['lib-ui'].createElement;
const toDateValue = window['lib-ui'].toDateValue;
const showConfirm = window['lib-ui'].showConfirm;
window.addEventListener('load', () => {
});
//*/
/*
window.addEventListener('load', () => {
const grid = new Grid('#container');