Files
DP/temp_backup/Designer_redundant/test-simple.ts
zuowei1216 12395d8eca newrun
2025-12-30 14:46:22 +08:00

65 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 超级简单的测试 - 验证最基础的 evalScript
*/
import { cep } from "@/utils/cep";
/**
* 测试1最简单的计算
*/
export async function testSimpleCalc() {
try {
const result = await cep.evalScript("1 + 2 + 3");
console.log('简单计算结果:', result);
return { success: true, result };
} catch (error) {
console.error('简单计算失败:', error);
return { success: false, error: String(error) };
}
}
/**
* 测试2获取应用名称不依赖任何工具库
*/
export async function testGetAppName() {
try {
const result = await cep.evalScript("app.name");
console.log('应用名称:', result);
return { success: true, appName: result };
} catch (error) {
console.error('获取应用名称失败:', error);
return { success: false, error: String(error) };
}
}
/**
* 测试3创建图层最简单版本不依赖工具库
*/
export async function testCreateLayerDirect() {
const jsx = `
(function() {
try {
if (app.documents.length === 0) {
return "no_document";
}
var doc = app.activeDocument;
var layer = doc.artLayers.add();
layer.name = "TestLayer";
return "success:" + layer.name;
} catch (e) {
return "error:" + e.toString();
}
})()
`;
try {
const result = await cep.evalScript(jsx);
console.log('创建图层结果:', result);
return { success: true, result };
} catch (error) {
console.error('创建图层失败:', error);
return { success: false, error: String(error) };
}
}