fix: 桌面拾取按钮判定与重复函数清理
This commit is contained in:
1 parent
0694bd45d3
commit
c2b09f39e6
1 file changed
+28
-3
@@ -443,8 +443,10 @@ function FieldControl({
|
|||||||
}) {
|
}) {
|
||||||
const raw = node.values[field.key] ?? field.defaultValue;
|
const raw = node.values[field.key] ?? field.defaultValue;
|
||||||
const [picking, setPicking] = useState(false);
|
const [picking, setPicking] = useState(false);
|
||||||
const isVisionTarget = /^(OcrOffline_|CV_)/.test(node.componentId);
|
const isGroundTarget = node.componentId.endsWith("Ground");
|
||||||
|
const isVisionSource = /^(OcrOffline_|CV_|Image_)/.test(node.componentId);
|
||||||
const isWindowTarget = /^(Window_|System_ConnectRemoteDesktop)/.test(node.componentId);
|
const isWindowTarget = /^(Window_|System_ConnectRemoteDesktop)/.test(node.componentId);
|
||||||
|
const isVisionTarget = /^(OcrOffline_|CV_)/.test(node.componentId);
|
||||||
|
|
||||||
const insertVariable = (expression: string) => {
|
const insertVariable = (expression: string) => {
|
||||||
const current = textOf(raw).trim();
|
const current = textOf(raw).trim();
|
||||||
@@ -452,6 +454,23 @@ function FieldControl({
|
|||||||
onChange(field.key, current === "" || known ? expression : `${textOf(raw)}${expression}`);
|
onChange(field.key, current === "" || known ? expression : `${textOf(raw)}${expression}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const pickDesktop = async () => {
|
||||||
|
setPicking(true);
|
||||||
|
try {
|
||||||
|
const picked = await window.rpa.desktop.pickElement();
|
||||||
|
if (picked.cancelled) {
|
||||||
|
onToast("已取消拾取");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onChange(field.key, picked.selector);
|
||||||
|
onToast("已拾取:" + (picked.name || picked.controlType || "元素"));
|
||||||
|
} catch (error) {
|
||||||
|
onToast(error instanceof Error ? error.message : String(error), "error");
|
||||||
|
} finally {
|
||||||
|
setPicking(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const pickPath = async (directories: boolean) => {
|
const pickPath = async (directories: boolean) => {
|
||||||
try {
|
try {
|
||||||
const selected = await window.rpa.dialog.open({
|
const selected = await window.rpa.dialog.open({
|
||||||
@@ -616,9 +635,15 @@ function FieldControl({
|
|||||||
placeholder="css:#submit / aria:button"
|
placeholder="css:#submit / aria:button"
|
||||||
onChange={(event) => onChange(field.key, event.target.value)}
|
onChange={(event) => onChange(field.key, event.target.value)}
|
||||||
/>
|
/>
|
||||||
<button type="button" className="mini-btn" disabled={picking} onClick={() => void pickElement()} title="从运行浏览器拾取元素">
|
{isGroundTarget ? (
|
||||||
|
<button type="button" className="mini-btn" disabled={picking} onClick={() => void pickDesktop()} title="从桌面拾取元素(移到目标按空格)">
|
||||||
|
{picking ? "桌面拾取中" : "桌面拾取"}
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<button type="button" className="mini-btn" disabled={picking} onClick={() => void pickElement()} title="从运行浏览器拾取元素">
|
||||||
{picking ? "拾取中" : "拾取"}
|
{picking ? "拾取中" : "拾取"}
|
||||||
</button>
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : field.widget === "secret" ? (
|
) : field.widget === "secret" ? (
|
||||||
<div className="field-row">
|
<div className="field-row">
|
||||||
|
|||||||
Reference in new issue
Block a user