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
+228 -110

No files matched your search

+23 -42
View File
@@ -7,53 +7,34 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>UI Lib</title>
<!-- <script src="amrnb.js"></script> -->
<link rel="stylesheet" href="./style.scss" />
<script type="module" src="main.ts"></script>
<link rel="stylesheet" href="../lib/ui/css/common.scss" />
<style type="text/css">
:root {
--red-color: red;
}
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
.drag-box {
position: absolute;
}
.box-inner {
height: 100%;
display: flex;
flex-direction: column;
border: 1px solid #ccc;
background-color: #fff;
}
.drag-hover {
background-color: #ccc;
padding: 4px;
}
.wrapper {
position: relative;
height: 100%;
overflow: auto;
}
#container>.ui-grid {
width: 1000px;
height: 400px;
}
</style>
</head>
<body>
<div class="wrapper">
<div id="container"></div>
<div id="container">
<div>
<label class="ui-switch">
<input type="checkbox" />
<span>Display Behavior/Insight Events Only</span>
</label>
</div>
<div class="ui-switch-group">
<label>
<input type="radio" name="reviewed" checked="checked" />
<span>Yes</span>
</label>
<label>
<input type="radio" name="reviewed" />
<span>No</span>
</label>
<label>
<input type="radio" name="reviewed" />
<span>Pending</span>
</label>
</div>
</div>
<!--<button id="setItem">set item</button>
<button id="addItem">add item</button>
<button id="addItems">add items</button>
+154 -60
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
});
// const DateSelector = window['lib-ui'].DateSelector;
// const formatDate = window['lib-ui'].formatDate;
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();
// window.addEventListener('load', () => {
// DateSelector.resolve(document.querySelector('#container'), function (date) {
// console.log(`element(#${this.element.id}), date changed to: ${formatDate(date)}`);
// 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 value = document.querySelector('#dateFrom').value;
// console.log(`dateFrom.value = '${value}', formatted: '${formatDate(value)}'`);
// });
// });
/*/
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: '苏州市'
}
]
}
];
const wrapper = dropdown.create();
wrapper.style.minWidth = '220px';
document.querySelector('#container')?.replaceChildren(wrapper);
/*/
/*/
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,8 +290,8 @@ window.addEventListener('load', () => {
mauiName: 'Dynatrace.OneAgent.MAUI',
mauiVersion: '1.283.1',
mauiNet: '7.0',
mauiCount: 12351
},
mauiCount: 12351,
__children: [
{
name: 'Esri.ArcGISRuntime.Xamarin.Forms',
version: '100.15.4',
@@ -247,6 +302,8 @@ window.addEventListener('load', () => {
mauiNet: '8.0',
mauiCount: 40913
},
]
},
{
name: 'Scandit.DataCapture.Core.Xamarin',
version: '6.22.0',
@@ -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');
+39 -8
View File
@@ -1,10 +1,10 @@
@import '../lib/ui/css/variables/definition.scss';
@import '../lib/ui/css/common.scss';
@import '../lib/ui/css/checkbox.scss';
@import '../lib/ui/css/dropdown.scss';
@import '../lib/ui/css/grid.scss';
@import '../lib/ui/css/popup.scss';
@import '../lib/ui/css/tooltip.scss';
@use '../lib/ui/css/variables/definition.scss';
@use '../lib/ui/css/common.scss';
@use '../lib/ui/css/checkbox.scss';
@use '../lib/ui/css/dropdown.scss';
@use '../lib/ui/css/grid.scss';
@use '../lib/ui/css/popup.scss';
@use '../lib/ui/css/tooltip.scss';
:root {
font-family: var(--serif-font-family);
@@ -115,7 +115,6 @@ button {
body {
margin: 0;
display: flex;
height: 100vh;
}
@@ -232,3 +231,35 @@ h1 {
background-color: #f9f9f9;
}
}
.ui-popup-mask {
.ui-popup-container {
.ui-popup-header {
background-color: transparent;
}
}
}
.box-inner {
height: 100%;
display: flex;
flex-direction: column;
border: 1px solid #ccc;
background-color: #fff;
}
.drag-hover {
background-color: #ccc;
padding: 4px;
}
.wrapper {
position: relative;
height: 100%;
overflow: auto;
}
#container {
width: 1000px;
height: 600px;
}
+12
View File
@@ -9,5 +9,17 @@
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<rewrite>
<rules>
<rule name="rsync" stopProcessing="true">
<match url="gui/(.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="(.+)s://" />
<add input="{CACHE_URL}" pattern="(.*)s://" />
</conditions>
<action type="Rewrite" url="{C:1}://localhost:8888/gui/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>