update 1.0.10
This commit is contained in:
@@ -195,6 +195,29 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
id="context-menu"
|
||||
class="hidden fixed bg-white border border-gray-200 shadow-xl rounded-md py-1 z-[100] w-40 text-xs text-gray-700 shadow-2xl"
|
||||
>
|
||||
<div id="cm-view-info" class="px-3 py-2 text-gray-300 cursor-not-allowed flex items-center">
|
||||
<span>查看详情</span>
|
||||
</div>
|
||||
<div id="cm-view-product" class="px-3 py-2 hover:bg-blue-50 hover:text-blue-600 cursor-pointer flex items-center">
|
||||
<span>查看产品链接</span>
|
||||
</div>
|
||||
<div id="cm-view-datasheet" class="px-3 py-2 hover:bg-blue-50 hover:text-blue-600 cursor-pointer flex items-center">
|
||||
<span>查看数据手册</span>
|
||||
</div>
|
||||
<div class="border-t border-gray-100 my-1"></div>
|
||||
<div id="cm-add-lcsc-car" class="px-3 py-2 text-gray-300 cursor-not-allowed flex items-center">
|
||||
<span>立创商城加购</span>
|
||||
</div>
|
||||
<div class="border-t border-gray-100 my-1"></div>
|
||||
<div id="cm-edit" class="px-3 py-2 hover:bg-blue-50 hover:text-blue-600 cursor-pointer flex items-center">
|
||||
<span>编辑</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@@ -220,6 +243,11 @@
|
||||
const editNameInput = document.getElementById('edit-name-input');
|
||||
const editLcscInput = document.getElementById('edit-lcsc-input');
|
||||
const dialogIdDisplay = document.getElementById('dialog-id-display');
|
||||
const contextMenu = document.getElementById('context-menu');
|
||||
const cmViewProduct = document.getElementById('cm-view-product');
|
||||
const cmViewDatasheet = document.getElementById('cm-view-datasheet');
|
||||
const cmAddLcscCarDatasheet = document.getElementById('cm-add-lcsc-car');
|
||||
const cmEdit = document.getElementById('cm-edit');
|
||||
|
||||
const SERVER = eda.sys_Storage.getExtensionUserConfig('server-host') ?? 'http://localhost:21816/api';
|
||||
const AUTO_RUN = eda.sys_Storage.getExtensionUserConfig('server-auto-run') ?? true;
|
||||
@@ -554,8 +582,34 @@
|
||||
}
|
||||
};
|
||||
|
||||
tableBody.oncontextmenu = (e) => {
|
||||
const row = e.target.closest('tr');
|
||||
if (row && row.dataset.row) {
|
||||
e.preventDefault();
|
||||
|
||||
selectRow(row);
|
||||
|
||||
contextMenu.classList.remove('hidden');
|
||||
|
||||
let x = e.clientX;
|
||||
let y = e.clientY;
|
||||
const menuWidth = 160;
|
||||
const menuHeight = 110;
|
||||
|
||||
if (x + menuWidth > window.innerWidth) x -= menuWidth;
|
||||
if (y + menuHeight > window.innerHeight) y -= menuHeight;
|
||||
|
||||
contextMenu.style.left = `${x}px`;
|
||||
contextMenu.style.top = `${y}px`;
|
||||
}
|
||||
};
|
||||
|
||||
placeButton.onclick = async () => {
|
||||
if (!selectedRowData) return;
|
||||
if ((await eda.dmt_SelectControl.getCurrentDocumentInfo()).documentType !== EDMT_EditorDocumentType.SCHEMATIC_PAGE) {
|
||||
eda.sys_Message.showToastMessage('只有原理图页可放置器件', ESYS_ToastMessageType.WARNING);
|
||||
return;
|
||||
}
|
||||
await eda.sys_IFrame.closeIFrame('leye-main');
|
||||
try {
|
||||
await eda.sch_PrimitiveComponent.placeComponentWithMouse({
|
||||
@@ -674,8 +728,40 @@
|
||||
}
|
||||
};
|
||||
|
||||
cmViewProduct.onclick = () => {
|
||||
if (selectedRowData && selectedRowData.lcscId) {
|
||||
const url = `https://so.szlcsc.com/global.html?c=&k=${selectedRowData.lcscId}`;
|
||||
eda.sys_Window.open(url, ESYS_WindowOpenTarget.BLANK);
|
||||
}
|
||||
};
|
||||
|
||||
cmViewDatasheet.onclick = async () => {
|
||||
if (selectedRowData && selectedRowData.uuid) {
|
||||
const data = await eda.lib_Device.get(selectedRowData.uuid);
|
||||
if (data && data.property && data.property.otherProperty && data.property.otherProperty['Datasheet']) {
|
||||
const url = data.property.otherProperty['Datasheet'];
|
||||
eda.sys_Window.open(String(url), ESYS_WindowOpenTarget.BLANK);
|
||||
} else {
|
||||
eda.sys_Message.showToastMessage('该器件无数据手册属性', ESYS_ToastMessageType.WARNING);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cmAddLcscCarDatasheet.onclick = () => {
|
||||
// cmViewProduct.click();
|
||||
eda.sys_Message.showToastMessage('暂不支持', ESYS_ToastMessageType.INFO);
|
||||
};
|
||||
|
||||
cmEdit.onclick = () => {
|
||||
editBtn.click();
|
||||
};
|
||||
|
||||
document.getElementById('cancel-btn').onclick = () => eda.sys_IFrame.closeIFrame('leye-main');
|
||||
|
||||
document.addEventListener('click', () => {
|
||||
contextMenu.classList.add('hidden');
|
||||
});
|
||||
|
||||
initInventoryData();
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user