feat: AI套图分层方案 + Gemini集成 - 4种图案类型处理 + 正片叠底 + 宽高比 + 模型选择

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-07 16:59:56 +08:00
parent 12395d8eca
commit dae906aba7
277 changed files with 15009 additions and 19922 deletions

View File

@@ -0,0 +1,50 @@
// 检查是否有活动文档
if (app.documents.length > 0) {
var doc = app.activeDocument; // 获取活动文档
// 递归函数来构建所有图层的字符串表示
function buildLayersString(layerSet, indent) {
var result = "";
var currentIndent = Array(indent + 1).join(" "); // 根据缩进级别构建缩进字符串
for (var i = 0; i < layerSet.layers.length; i++) {
var layer = layerSet.layers[i];
var layerName = layer.name.replace(/"/g, '\\"'); // 转义引号
if (layer.typename === 'ArtLayer') {
// 构建图层的字符串表示
result += '\n' + currentIndent + '\"图层: ' + layerName + '\": null';
} else { // LayerSet
// 构建图层组的字符串表示,并递归处理子图层
var childResult = buildLayersString(layer, indent + 1);
if (childResult !== "") {
result += '\n' + currentIndent + '\"图层组: ' + layerName + '\": {' + childResult + '}';
}
}
if (i < layerSet.layers.length - 1) {
result += ','; // 如果不是最后一个图层或图层组,添加逗号
}
}
return result;
}
var layersString = "{" + buildLayersString(doc, 0) + "\n}";
// 删除最后一个逗号
layersString = layersString.replace(/,\s*$/, '');
// 创建文件并写入数据
var desktopPath = Folder.desktop.fsName; // 获取桌面路径
var filePath = desktopPath + "/photoshop_layers.json"; // 文件完整路径
var file = new File(filePath);
// 打开文件进行写入并使用GBK编码
file.open("w");
file.encoding = "GBK";
file.write(layersString);
file.close();
alert("文件已保存至桌面: photoshop_layers.json");
} else {
alert("没有打开的文档");
}