wps-multitool-mcp 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/index.js +4 -2
- package/dist/bridge/index.js.map +1 -1
- package/dist/cli/install.d.ts +58 -0
- package/dist/cli/install.d.ts.map +1 -0
- package/dist/cli/install.js +301 -0
- package/dist/cli/install.js.map +1 -0
- package/dist/client/action-routes.generated.d.ts +1 -1
- package/dist/client/action-routes.generated.d.ts.map +1 -1
- package/dist/client/action-routes.generated.js +6 -1
- package/dist/client/action-routes.generated.js.map +1 -1
- package/dist/client/wps-client.d.ts +0 -3
- package/dist/client/wps-client.d.ts.map +1 -1
- package/dist/client/wps-client.js +61 -27
- package/dist/client/wps-client.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -4
- package/dist/index.js.map +1 -1
- package/dist/server/auto-snapshot.d.ts +58 -0
- package/dist/server/auto-snapshot.d.ts.map +1 -0
- package/dist/server/auto-snapshot.js +150 -0
- package/dist/server/auto-snapshot.js.map +1 -0
- package/dist/server/mcp-server.d.ts.map +1 -1
- package/dist/server/mcp-server.js +8 -141
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/tool-aliases.generated.d.ts +41 -0
- package/dist/server/tool-aliases.generated.d.ts.map +1 -0
- package/dist/server/tool-aliases.generated.js +88 -0
- package/dist/server/tool-aliases.generated.js.map +1 -0
- package/dist/server/tool-annotations.d.ts +3 -0
- package/dist/server/tool-annotations.d.ts.map +1 -1
- package/dist/server/tool-annotations.generated.d.ts.map +1 -1
- package/dist/server/tool-annotations.generated.js +25 -47
- package/dist/server/tool-annotations.generated.js.map +1 -1
- package/dist/server/tool-annotations.js +83 -7
- package/dist/server/tool-annotations.js.map +1 -1
- package/dist/server/tool-metadata.d.ts +25 -0
- package/dist/server/tool-metadata.d.ts.map +1 -1
- package/dist/server/tool-metadata.js +217 -40
- package/dist/server/tool-metadata.js.map +1 -1
- package/dist/server/tool-registry.d.ts +25 -3
- package/dist/server/tool-registry.d.ts.map +1 -1
- package/dist/server/tool-registry.js +204 -42
- package/dist/server/tool-registry.js.map +1 -1
- package/dist/server/tool-tiers.d.ts +27 -8
- package/dist/server/tool-tiers.d.ts.map +1 -1
- package/dist/server/tool-tiers.js +34 -8
- package/dist/server/tool-tiers.js.map +1 -1
- package/dist/server/tool-verification.d.ts +35 -0
- package/dist/server/tool-verification.d.ts.map +1 -0
- package/dist/server/tool-verification.generated.d.ts +17 -0
- package/dist/server/tool-verification.generated.d.ts.map +1 -0
- package/dist/server/tool-verification.generated.js +293 -0
- package/dist/server/tool-verification.generated.js.map +1 -0
- package/dist/server/tool-verification.js +43 -0
- package/dist/server/tool-verification.js.map +1 -0
- package/dist/tools/common/batch.d.ts.map +1 -1
- package/dist/tools/common/batch.js +92 -14
- package/dist/tools/common/batch.js.map +1 -1
- package/dist/tools/common/general.d.ts +0 -3
- package/dist/tools/common/general.d.ts.map +1 -1
- package/dist/tools/common/general.js +16 -58
- package/dist/tools/common/general.js.map +1 -1
- package/dist/tools/common/index.d.ts +4 -2
- package/dist/tools/common/index.d.ts.map +1 -1
- package/dist/tools/common/index.js +18 -4
- package/dist/tools/common/index.js.map +1 -1
- package/dist/tools/common/repair.js +18 -18
- package/dist/tools/common/snapshot.d.ts +77 -0
- package/dist/tools/common/snapshot.d.ts.map +1 -0
- package/dist/tools/common/snapshot.js +497 -0
- package/dist/tools/common/snapshot.js.map +1 -0
- package/dist/tools/common/status.js +27 -27
- package/dist/tools/common/toolgroups.d.ts.map +1 -1
- package/dist/tools/common/toolgroups.js +21 -5
- package/dist/tools/common/toolgroups.js.map +1 -1
- package/dist/tools/excel/data.d.ts +0 -5
- package/dist/tools/excel/data.d.ts.map +1 -1
- package/dist/tools/excel/data.js +19 -39
- package/dist/tools/excel/data.js.map +1 -1
- package/dist/tools/excel/format.d.ts.map +1 -1
- package/dist/tools/excel/format.js +3 -1
- package/dist/tools/excel/format.js.map +1 -1
- package/dist/tools/excel/formula.d.ts +0 -9
- package/dist/tools/excel/formula.d.ts.map +1 -1
- package/dist/tools/excel/formula.js +1 -18
- package/dist/tools/excel/formula.js.map +1 -1
- package/dist/tools/excel/index.d.ts +3 -3
- package/dist/tools/excel/index.d.ts.map +1 -1
- package/dist/tools/excel/index.js +4 -12
- package/dist/tools/excel/index.js.map +1 -1
- package/dist/tools/excel/sheet-gaps.d.ts +2 -2
- package/dist/tools/excel/sheet-gaps.js +2 -2
- package/dist/tools/excel/sheet.d.ts +0 -10
- package/dist/tools/excel/sheet.d.ts.map +1 -1
- package/dist/tools/excel/sheet.js +7 -117
- package/dist/tools/excel/sheet.js.map +1 -1
- package/dist/tools/excel/workbook.d.ts.map +1 -1
- package/dist/tools/excel/workbook.js +8 -3
- package/dist/tools/excel/workbook.js.map +1 -1
- package/dist/tools/ppt/animation.d.ts +15 -58
- package/dist/tools/ppt/animation.d.ts.map +1 -1
- package/dist/tools/ppt/animation.js +39 -568
- package/dist/tools/ppt/animation.js.map +1 -1
- package/dist/tools/ppt/background.d.ts +0 -18
- package/dist/tools/ppt/background.d.ts.map +1 -1
- package/dist/tools/ppt/background.js +43 -249
- package/dist/tools/ppt/background.js.map +1 -1
- package/dist/tools/ppt/beautify-advanced.d.ts +0 -6
- package/dist/tools/ppt/beautify-advanced.d.ts.map +1 -1
- package/dist/tools/ppt/beautify-advanced.js +13 -76
- package/dist/tools/ppt/beautify-advanced.js.map +1 -1
- package/dist/tools/ppt/data-viz.d.ts.map +1 -1
- package/dist/tools/ppt/data-viz.js +1 -1
- package/dist/tools/ppt/data-viz.js.map +1 -1
- package/dist/tools/ppt/image.d.ts.map +1 -1
- package/dist/tools/ppt/image.js +4 -9
- package/dist/tools/ppt/image.js.map +1 -1
- package/dist/tools/ppt/index.d.ts +5 -5
- package/dist/tools/ppt/index.d.ts.map +1 -1
- package/dist/tools/ppt/index.js +5 -35
- package/dist/tools/ppt/index.js.map +1 -1
- package/dist/tools/ppt/misc.d.ts +0 -6
- package/dist/tools/ppt/misc.d.ts.map +1 -1
- package/dist/tools/ppt/misc.js +14 -65
- package/dist/tools/ppt/misc.js.map +1 -1
- package/dist/tools/ppt/presentation.d.ts.map +1 -1
- package/dist/tools/ppt/presentation.js +25 -11
- package/dist/tools/ppt/presentation.js.map +1 -1
- package/dist/tools/ppt/slide-ops.d.ts +0 -6
- package/dist/tools/ppt/slide-ops.d.ts.map +1 -1
- package/dist/tools/ppt/slide-ops.js +418 -324
- package/dist/tools/ppt/slide-ops.js.map +1 -1
- package/dist/tools/ppt/slide.d.ts.map +1 -1
- package/dist/tools/ppt/slide.js +49 -35
- package/dist/tools/ppt/slide.js.map +1 -1
- package/dist/tools/ppt/table.d.ts.map +1 -1
- package/dist/tools/ppt/table.js +4 -2
- package/dist/tools/ppt/table.js.map +1 -1
- package/dist/tools/ppt/textbox.d.ts.map +1 -1
- package/dist/tools/ppt/textbox.js +4 -1
- package/dist/tools/ppt/textbox.js.map +1 -1
- package/dist/tools/word/academic.js +79 -79
- package/dist/tools/word/content.d.ts.map +1 -1
- package/dist/tools/word/content.js +9 -4
- package/dist/tools/word/content.js.map +1 -1
- package/dist/tools/word/document.d.ts +0 -5
- package/dist/tools/word/document.d.ts.map +1 -1
- package/dist/tools/word/document.js +1 -58
- package/dist/tools/word/document.js.map +1 -1
- package/dist/tools/word/gaps.d.ts +2 -2
- package/dist/tools/word/gaps.js +2 -2
- package/dist/tools/word/index.d.ts +1 -1
- package/dist/tools/word/index.d.ts.map +1 -1
- package/dist/tools/word/index.js +1 -3
- package/dist/tools/word/index.js.map +1 -1
- package/dist/types/tools.d.ts +12 -1
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/types/tools.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +17 -0
- package/dist/utils/logger.js.map +1 -1
- package/package.json +66 -59
- package/scripts/wps-com.ps1 +8255 -7260
- package/scripts/wps-comd.ps1 +123 -123
- package/skills/wps-multitool/SKILL.md +128 -110
- package/skills/wps-multitool/references/errors.md +61 -61
- package/skills/wps-multitool/references/recipes.md +82 -81
- package/skills/wps-multitool/references/routing.md +87 -87
- package/dist/client/mac-poll-server.d.ts +0 -77
- package/dist/client/mac-poll-server.d.ts.map +0 -1
- package/dist/client/mac-poll-server.js +0 -516
- package/dist/client/mac-poll-server.js.map +0 -1
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* - wps_ppt_add_speaker_notes: 添加演讲者备注
|
|
32
32
|
*/
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.slideOpsTools = exports.addSpeakerNotesHandler = exports.addSpeakerNotesDefinition = exports.setShapeFillHandler = exports.setShapeFillDefinition = exports.
|
|
34
|
+
exports.slideOpsTools = exports.addSpeakerNotesHandler = exports.addSpeakerNotesDefinition = exports.setShapeFillHandler = exports.setShapeFillDefinition = exports.setTransitionHandler = exports.setTransitionDefinition = exports.setSlideSizeHandler = exports.setSlideSizeDefinition = exports.setBackgroundHandler = exports.setBackgroundDefinition = exports.setAnimationHandler = exports.setAnimationDefinition = exports.setShapeTextHandler = exports.setShapeTextDefinition = exports.insertImageHandler = exports.insertImageDefinition = exports.setSlideTitleHandler = exports.setSlideTitleDefinition = exports.addTextboxHandler = exports.addTextboxDefinition = exports.setShapeStyleHandler = exports.setShapeStyleDefinition = exports.addShapeHandler = exports.addShapeDefinition = exports.getSlideNotesHandler = exports.getSlideNotesDefinition = exports.setSlideLayoutHandler = exports.setSlideLayoutDefinition = exports.switchSlideHandler = exports.switchSlideDefinition = exports.getSlideInfoHandler = exports.getSlideInfoDefinition = exports.getSlideCountHandler = exports.getSlideCountDefinition = exports.moveSlideHandler = exports.moveSlideDefinition = exports.deleteSlideHandler = exports.deleteSlideDefinition = void 0;
|
|
35
35
|
const uuid_1 = require("uuid");
|
|
36
36
|
const tools_1 = require("../../types/tools");
|
|
37
37
|
const wps_client_1 = require("../../client/wps-client");
|
|
@@ -96,65 +96,6 @@ const deleteSlideHandler = async (args) => {
|
|
|
96
96
|
};
|
|
97
97
|
exports.deleteSlideHandler = deleteSlideHandler;
|
|
98
98
|
// ============================================================
|
|
99
|
-
// 2. wps_ppt_duplicate_slide - 复制幻灯片
|
|
100
|
-
// ============================================================
|
|
101
|
-
exports.duplicateSlideDefinition = {
|
|
102
|
-
name: 'wps_ppt_duplicate_slide',
|
|
103
|
-
description: `复制指定的幻灯片,在其后插入副本。
|
|
104
|
-
|
|
105
|
-
使用场景:
|
|
106
|
-
- "复制第2页幻灯片"
|
|
107
|
-
- "把这页再复制一份"
|
|
108
|
-
- "克隆当前幻灯片"`,
|
|
109
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
110
|
-
inputSchema: {
|
|
111
|
-
type: 'object',
|
|
112
|
-
properties: {
|
|
113
|
-
slideIndex: {
|
|
114
|
-
type: 'number',
|
|
115
|
-
description: '要复制的幻灯片索引(从1开始)',
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
required: ['slideIndex'],
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
const duplicateSlideHandler = async (args) => {
|
|
122
|
-
const { slideIndex } = args;
|
|
123
|
-
try {
|
|
124
|
-
const response = await wps_client_1.wpsClient.executeMethod('duplicateSlide', { slideIndex }, wps_1.WpsAppType.PRESENTATION);
|
|
125
|
-
if (response.success && response.data) {
|
|
126
|
-
return {
|
|
127
|
-
id: (0, uuid_1.v4)(),
|
|
128
|
-
success: true,
|
|
129
|
-
content: [
|
|
130
|
-
{
|
|
131
|
-
type: 'text',
|
|
132
|
-
text: `幻灯片复制成功!\n源幻灯片: 第 ${slideIndex} 页\n副本位置: 第 ${response.data.newSlideIndex} 页`,
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
return {
|
|
139
|
-
id: (0, uuid_1.v4)(),
|
|
140
|
-
success: false,
|
|
141
|
-
content: [{ type: 'text', text: `复制幻灯片失败: ${response.error}` }],
|
|
142
|
-
error: response.error,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
148
|
-
return {
|
|
149
|
-
id: (0, uuid_1.v4)(),
|
|
150
|
-
success: false,
|
|
151
|
-
content: [{ type: 'text', text: `复制幻灯片出错: ${errMsg}` }],
|
|
152
|
-
error: errMsg,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
exports.duplicateSlideHandler = duplicateSlideHandler;
|
|
157
|
-
// ============================================================
|
|
158
99
|
// 3. wps_ppt_move_slide - 移动幻灯片到指定位置
|
|
159
100
|
// ============================================================
|
|
160
101
|
exports.moveSlideDefinition = {
|
|
@@ -541,69 +482,6 @@ const getSlideNotesHandler = async (args) => {
|
|
|
541
482
|
};
|
|
542
483
|
exports.getSlideNotesHandler = getSlideNotesHandler;
|
|
543
484
|
// ============================================================
|
|
544
|
-
// 9. wps_ppt_set_slide_notes - 设置幻灯片备注
|
|
545
|
-
// ============================================================
|
|
546
|
-
exports.setSlideNotesDefinition = {
|
|
547
|
-
name: 'wps_ppt_set_slide_notes',
|
|
548
|
-
description: `设置幻灯片的备注内容,用于演讲提示。
|
|
549
|
-
|
|
550
|
-
使用场景:
|
|
551
|
-
- "给第1页添加备注"
|
|
552
|
-
- "写一些演讲提示"
|
|
553
|
-
- "修改备注内容"`,
|
|
554
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
555
|
-
inputSchema: {
|
|
556
|
-
type: 'object',
|
|
557
|
-
properties: {
|
|
558
|
-
slideIndex: {
|
|
559
|
-
type: 'number',
|
|
560
|
-
description: '幻灯片索引(从1开始)',
|
|
561
|
-
},
|
|
562
|
-
notes: {
|
|
563
|
-
type: 'string',
|
|
564
|
-
description: '备注内容',
|
|
565
|
-
},
|
|
566
|
-
},
|
|
567
|
-
required: ['slideIndex', 'notes'],
|
|
568
|
-
},
|
|
569
|
-
};
|
|
570
|
-
const setSlideNotesHandler = async (args) => {
|
|
571
|
-
const { slideIndex, notes } = args;
|
|
572
|
-
try {
|
|
573
|
-
const response = await wps_client_1.wpsClient.executeMethod('setSlideNotes', { slideIndex, notes }, wps_1.WpsAppType.PRESENTATION);
|
|
574
|
-
if (response.success) {
|
|
575
|
-
return {
|
|
576
|
-
id: (0, uuid_1.v4)(),
|
|
577
|
-
success: true,
|
|
578
|
-
content: [
|
|
579
|
-
{
|
|
580
|
-
type: 'text',
|
|
581
|
-
text: `幻灯片备注设置成功!\n幻灯片: 第 ${slideIndex} 页\n备注内容: "${notes.substring(0, 80)}${notes.length > 80 ? '...' : ''}"`,
|
|
582
|
-
},
|
|
583
|
-
],
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
else {
|
|
587
|
-
return {
|
|
588
|
-
id: (0, uuid_1.v4)(),
|
|
589
|
-
success: false,
|
|
590
|
-
content: [{ type: 'text', text: `设置幻灯片备注失败: ${response.error}` }],
|
|
591
|
-
error: response.error,
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
catch (error) {
|
|
596
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
597
|
-
return {
|
|
598
|
-
id: (0, uuid_1.v4)(),
|
|
599
|
-
success: false,
|
|
600
|
-
content: [{ type: 'text', text: `设置幻灯片备注出错: ${errMsg}` }],
|
|
601
|
-
error: errMsg,
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
exports.setSlideNotesHandler = setSlideNotesHandler;
|
|
606
|
-
// ============================================================
|
|
607
485
|
// 10. wps_ppt_add_shape - 添加形状
|
|
608
486
|
// ============================================================
|
|
609
487
|
exports.addShapeDefinition = {
|
|
@@ -1111,70 +989,201 @@ exports.setShapeTextHandler = setShapeTextHandler;
|
|
|
1111
989
|
// ============================================================
|
|
1112
990
|
exports.setAnimationDefinition = {
|
|
1113
991
|
name: 'wps_ppt_set_animation',
|
|
1114
|
-
description:
|
|
992
|
+
description: `给形状加动画,或调整已有动画的播放顺序(第 8 轮合并了动画族 5 个工具)。
|
|
1115
993
|
|
|
1116
|
-
|
|
1117
|
-
-
|
|
1118
|
-
-
|
|
1119
|
-
- wipeIn: 擦除
|
|
1120
|
-
- zoomIn: 缩放进入
|
|
1121
|
-
- bounceIn: 弹跳进入
|
|
1122
|
-
- spinIn: 旋转进入
|
|
1123
|
-
- fadeOut: 淡出
|
|
1124
|
-
- flyOut: 飞出
|
|
994
|
+
**两个分支用 \`op\` 选**:
|
|
995
|
+
- \`op:'add'\`(默认):给形状加动画,要 \`shapeIndex\` + \`category\` + \`effect\`
|
|
996
|
+
- \`op:'reorder'\`:把已有动画挪位置,要 \`animationIndex\` + \`order\`
|
|
1125
997
|
|
|
1126
|
-
|
|
1127
|
-
-
|
|
1128
|
-
-
|
|
1129
|
-
-
|
|
998
|
+
\`category\` 决定动作落在哪个动画窗格:
|
|
999
|
+
- entrance 入场(appear / fadeIn / flyIn / wipeIn / zoomIn / bounceIn / spinIn)
|
|
1000
|
+
- emphasis 强调(pulse / grow / teeter / colorPulse)
|
|
1001
|
+
- exit 退场(fadeOut / flyOut / wipeOut / zoomOut / disappear)
|
|
1002
|
+
|
|
1003
|
+
什么时候用:
|
|
1004
|
+
- "给第1页第2个形状加个淡入" → { op:'add', slideIndex:1, shapeIndex:2, category:'entrance', effect:'fadeIn' }
|
|
1005
|
+
- "让这个元素闪一下强调" → { op:'add', slideIndex:1, shapeIndex:2, category:'emphasis', effect:'pulse' }
|
|
1006
|
+
- "把第3个动画移到最前面" → { op:'reorder', slideIndex:1, animationIndex:3, order:1 }
|
|
1007
|
+
|
|
1008
|
+
限制:\`.add\` 是【累加】的 —— 同一形状重复加会叠出多条动画,不会替换。
|
|
1009
|
+
想看现在有哪些动画用 wps_ppt_get_animations,删掉某一条用 wps_ppt_remove_animation。`,
|
|
1130
1010
|
category: tools_1.ToolCategory.PRESENTATION,
|
|
1131
1011
|
inputSchema: {
|
|
1132
1012
|
type: 'object',
|
|
1133
1013
|
properties: {
|
|
1014
|
+
op: {
|
|
1015
|
+
type: 'string',
|
|
1016
|
+
enum: ['add', 'reorder'],
|
|
1017
|
+
description: '操作:add 加动画(默认)/ reorder 调顺序',
|
|
1018
|
+
},
|
|
1134
1019
|
slideIndex: {
|
|
1135
1020
|
type: 'number',
|
|
1136
1021
|
description: '幻灯片索引(从1开始)',
|
|
1137
1022
|
},
|
|
1138
1023
|
shapeIndex: {
|
|
1139
1024
|
type: 'number',
|
|
1140
|
-
description: '形状索引(从1
|
|
1025
|
+
description: '形状索引(从1开始);op=add 时必填',
|
|
1141
1026
|
},
|
|
1142
|
-
|
|
1027
|
+
category: {
|
|
1143
1028
|
type: 'string',
|
|
1144
|
-
|
|
1029
|
+
enum: ['entrance', 'emphasis', 'exit'],
|
|
1030
|
+
description: '动画类别;op=add 时必填',
|
|
1031
|
+
},
|
|
1032
|
+
effect: {
|
|
1033
|
+
type: 'string',
|
|
1034
|
+
description: '具体效果名。entrance: fadeIn/flyIn/wipeIn/zoomIn/bounceIn/spinIn;emphasis: pulse/spin/grow/teeter/colorPulse;exit: fadeOut/flyOut/wipeOut/zoomOut/disappear',
|
|
1035
|
+
},
|
|
1036
|
+
trigger: {
|
|
1037
|
+
type: 'string',
|
|
1038
|
+
enum: ['onClick', 'withPrevious', 'afterPrevious'],
|
|
1039
|
+
description: '触发方式,默认 onClick(单击时)',
|
|
1040
|
+
},
|
|
1041
|
+
animationIndex: {
|
|
1042
|
+
type: 'number',
|
|
1043
|
+
description: '已有动画的序号(从1开始);op=reorder 时必填',
|
|
1044
|
+
},
|
|
1045
|
+
order: {
|
|
1046
|
+
type: 'number',
|
|
1047
|
+
description: '新的播放位置(从1开始);op=reorder 时必填',
|
|
1145
1048
|
},
|
|
1146
1049
|
},
|
|
1147
|
-
required: ['slideIndex'
|
|
1050
|
+
required: ['slideIndex'],
|
|
1148
1051
|
},
|
|
1149
1052
|
};
|
|
1053
|
+
/** 旧 animationType → { category, effect }。旧名 wps_ppt_set_animation 只收一个字符串,
|
|
1054
|
+
* 收尾先按 Out/Exit 结尾判退场,其余按入场;未知名默认入场(宁可多加一个也别不加)。 */
|
|
1055
|
+
function splitLegacyAnimationType(animationType) {
|
|
1056
|
+
return {
|
|
1057
|
+
category: /(out|exit)$/i.test(animationType) ? 'exit' : 'entrance',
|
|
1058
|
+
effect: animationType,
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
const ANIM_NAME_MAP = {
|
|
1062
|
+
fadeIn: '淡入', flyIn: '飞入', wipeIn: '擦除', zoomIn: '缩放进入',
|
|
1063
|
+
bounceIn: '弹跳进入', spinIn: '旋转进入', fadeOut: '淡出', flyOut: '飞出',
|
|
1064
|
+
wipeOut: '擦除退场', zoomOut: '缩小退场', disappear: '消失',
|
|
1065
|
+
pulse: '脉冲', grow: '放大缩小', teeter: '跷跷板', colorPulse: '颜色脉冲',
|
|
1066
|
+
};
|
|
1067
|
+
const TRIGGER_NAME_MAP = {
|
|
1068
|
+
onClick: '单击时',
|
|
1069
|
+
withPrevious: '与上一动画同时',
|
|
1070
|
+
afterPrevious: '上一动画之后',
|
|
1071
|
+
};
|
|
1072
|
+
const CATEGORY_NAME_MAP = {
|
|
1073
|
+
entrance: '入场', emphasis: '强调', exit: '退场',
|
|
1074
|
+
};
|
|
1075
|
+
/**
|
|
1076
|
+
* category + effect → PS 真正认的效果名。
|
|
1077
|
+
* 为什么要在 TS 侧合成:WPS COM 的 AddEffect 只吃一个效果 ID,不认"入场/强调/退场"这个维度。
|
|
1078
|
+
* 不做这层合成的话,category 就是一个装饰参数(PS 收不到、进不了动画窗格对应格),
|
|
1079
|
+
* 那才是真的骗人 —— 用户以为加了退场动画,实际加的还是入场。
|
|
1080
|
+
*/
|
|
1081
|
+
function resolveEffectId(category, effect) {
|
|
1082
|
+
const normalized = String(effect || '').trim();
|
|
1083
|
+
const lower = normalized.toLowerCase();
|
|
1084
|
+
if (category === 'exit') {
|
|
1085
|
+
const outMap = {
|
|
1086
|
+
fade: 'fadeOut', fly: 'flyOut', wipe: 'wipeOut', zoom: 'zoomOut',
|
|
1087
|
+
vanish: 'vanish', disappear: 'disappear', dissolve: 'dissolveOut',
|
|
1088
|
+
};
|
|
1089
|
+
// 已经带 Out 尾名的(fadeOut)原样送下去,不重复拼
|
|
1090
|
+
if (lower.endsWith('out') || lower === 'disappear' || lower === 'vanish')
|
|
1091
|
+
return normalized;
|
|
1092
|
+
return outMap[lower] || normalized;
|
|
1093
|
+
}
|
|
1094
|
+
const inMap = {
|
|
1095
|
+
fade: 'fadeIn', fly: 'flyIn', wipe: 'wipeIn', zoom: 'zoomIn',
|
|
1096
|
+
dissolve: 'dissolveIn', appear: 'appear',
|
|
1097
|
+
};
|
|
1098
|
+
if (lower.endsWith('in') || lower === 'appear')
|
|
1099
|
+
return normalized;
|
|
1100
|
+
return inMap[lower] || normalized;
|
|
1101
|
+
}
|
|
1150
1102
|
const setAnimationHandler = async (args) => {
|
|
1151
|
-
const
|
|
1103
|
+
const op = args.op || 'add';
|
|
1152
1104
|
try {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1105
|
+
if (op === 'reorder') {
|
|
1106
|
+
const { slideIndex, animationIndex, order } = args;
|
|
1107
|
+
if (!animationIndex || !order) {
|
|
1108
|
+
return {
|
|
1109
|
+
id: (0, uuid_1.v4)(),
|
|
1110
|
+
success: false,
|
|
1111
|
+
content: [{ type: 'text', text: `op=reorder 时必须同时给 animationIndex 和 order` }],
|
|
1112
|
+
error: 'Missing required parameter: animationIndex / order',
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
const response = await wps_client_1.wpsClient.executeMethod('setAnimationOrder', { slideIndex, animationIndex, newOrder: order }, wps_1.WpsAppType.PRESENTATION);
|
|
1116
|
+
if (response.success) {
|
|
1117
|
+
return {
|
|
1118
|
+
id: (0, uuid_1.v4)(),
|
|
1119
|
+
success: true,
|
|
1120
|
+
content: [
|
|
1121
|
+
{
|
|
1122
|
+
type: 'text',
|
|
1123
|
+
text: `动画顺序调整成功!\n幻灯片: 第 ${slideIndex} 页\n动画 ${animationIndex} → 新位置 ${order}`,
|
|
1124
|
+
},
|
|
1125
|
+
],
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
return {
|
|
1129
|
+
id: (0, uuid_1.v4)(),
|
|
1130
|
+
success: false,
|
|
1131
|
+
content: [{ type: 'text', text: `调整动画顺序失败: ${response.error}` }],
|
|
1132
|
+
error: response.error,
|
|
1158
1133
|
};
|
|
1134
|
+
}
|
|
1135
|
+
// op=add:effect 缺失时兜住旧的 animationType(第 2 轮起这个参数就叫 animationType)
|
|
1136
|
+
const raw = args;
|
|
1137
|
+
const legacy = !raw.effect && raw.animationType
|
|
1138
|
+
? splitLegacyAnimationType(String(raw.animationType))
|
|
1139
|
+
: null;
|
|
1140
|
+
const category = raw.category || (legacy ? legacy.category : undefined);
|
|
1141
|
+
const effect = raw.effect || (legacy ? legacy.effect : undefined);
|
|
1142
|
+
if (!raw.shapeIndex || !category || !effect) {
|
|
1159
1143
|
return {
|
|
1160
1144
|
id: (0, uuid_1.v4)(),
|
|
1161
|
-
success:
|
|
1145
|
+
success: false,
|
|
1162
1146
|
content: [
|
|
1163
1147
|
{
|
|
1164
1148
|
type: 'text',
|
|
1165
|
-
text:
|
|
1149
|
+
text: `op=add 时必须同时给 shapeIndex、category(entrance/emphasis/exit)和 effect`,
|
|
1166
1150
|
},
|
|
1167
1151
|
],
|
|
1152
|
+
error: 'Missing required parameter: shapeIndex / category / effect',
|
|
1168
1153
|
};
|
|
1169
1154
|
}
|
|
1170
|
-
|
|
1155
|
+
// category 在这里落地成真正的效果名(exit+fade → fadeOut),PS 侧只认效果 ID
|
|
1156
|
+
const effectId = resolveEffectId(category, effect);
|
|
1157
|
+
const response = await wps_client_1.wpsClient.executeMethod('addAnimation', {
|
|
1158
|
+
slideIndex: raw.slideIndex,
|
|
1159
|
+
shapeIndex: raw.shapeIndex,
|
|
1160
|
+
effect: effectId,
|
|
1161
|
+
trigger: raw.trigger || 'onClick',
|
|
1162
|
+
}, wps_1.WpsAppType.PRESENTATION);
|
|
1163
|
+
if (response.success) {
|
|
1164
|
+
const lines = [
|
|
1165
|
+
`动画设置成功!`,
|
|
1166
|
+
`幻灯片: 第 ${raw.slideIndex} 页`,
|
|
1167
|
+
`形状: 第 ${raw.shapeIndex} 个`,
|
|
1168
|
+
`类别: ${CATEGORY_NAME_MAP[category] || category}`,
|
|
1169
|
+
`动画: ${ANIM_NAME_MAP[effect] || effect}(${effectId})`,
|
|
1170
|
+
`触发: ${TRIGGER_NAME_MAP[raw.trigger || 'onClick'] || raw.trigger || 'onClick'}`,
|
|
1171
|
+
];
|
|
1172
|
+
if (response.data && response.data.animationIndex) {
|
|
1173
|
+
lines.push(`动画序号: ${response.data.animationIndex}`);
|
|
1174
|
+
}
|
|
1171
1175
|
return {
|
|
1172
1176
|
id: (0, uuid_1.v4)(),
|
|
1173
|
-
success:
|
|
1174
|
-
content: [{ type: 'text', text:
|
|
1175
|
-
error: response.error,
|
|
1177
|
+
success: true,
|
|
1178
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
1176
1179
|
};
|
|
1177
1180
|
}
|
|
1181
|
+
return {
|
|
1182
|
+
id: (0, uuid_1.v4)(),
|
|
1183
|
+
success: false,
|
|
1184
|
+
content: [{ type: 'text', text: `设置动画失败: ${response.error}` }],
|
|
1185
|
+
error: response.error,
|
|
1186
|
+
};
|
|
1178
1187
|
}
|
|
1179
1188
|
catch (error) {
|
|
1180
1189
|
const errMsg = error instanceof Error ? error.message : String(error);
|
|
@@ -1188,81 +1197,219 @@ const setAnimationHandler = async (args) => {
|
|
|
1188
1197
|
};
|
|
1189
1198
|
exports.setAnimationHandler = setAnimationHandler;
|
|
1190
1199
|
// ============================================================
|
|
1191
|
-
// 17. wps_ppt_set_background -
|
|
1200
|
+
// 17. wps_ppt_set_background - 设置背景(第 5 轮:background 族 6→1 合并)
|
|
1192
1201
|
// ============================================================
|
|
1193
1202
|
exports.setBackgroundDefinition = {
|
|
1194
1203
|
name: 'wps_ppt_set_background',
|
|
1195
|
-
description:
|
|
1204
|
+
description: `设置背景:某一页、整份文稿、或幻灯片母版。
|
|
1196
1205
|
|
|
1197
|
-
|
|
1198
|
-
-
|
|
1199
|
-
-
|
|
1200
|
-
-
|
|
1206
|
+
**三个维度一次说清**(合并了原来 6 个背景工具,别再找 set_background_color / _image / _gradient / set_slide_background / set_master_background):
|
|
1207
|
+
- \`target\`: slide(默认,单页)/ all(整份文稿)/ master(母版)
|
|
1208
|
+
- \`type\`: solid(纯色)/ image(图片)/ gradient(渐变)/ pattern
|
|
1209
|
+
- 具体的填充物:\`color\` / \`imagePath\` / \`gradient\`
|
|
1210
|
+
|
|
1211
|
+
什么时候用:
|
|
1212
|
+
- "把这页背景改成深蓝" → { target:'slide', slideIndex:2, type:'solid', color:'#003366' }
|
|
1213
|
+
- "整份文稿统一白底" → { target:'all', type:'solid', color:'#FFFFFF' }
|
|
1214
|
+
- "用这张图做背景" → { target:'slide', slideIndex:1, type:'image', imagePath:'C:\\\\pics\\\\bg.png' }
|
|
1215
|
+
- "母版加渐变" → { target:'master', type:'gradient', gradient:{ type:'linear', colors:['#FF0000','#00FF00'] } }
|
|
1216
|
+
|
|
1217
|
+
不填 \`type\` 也能用:按你给的 color / imagePath / gradient 自动推断(老名字走别名过来时就是这条路)。
|
|
1218
|
+
|
|
1219
|
+
限制(真限制,不是没实现):
|
|
1220
|
+
- \`target:'master'\` 只支持纯色与渐变 —— 母版背景换图片 WPS 不认,会明确报错而不是假装成功。
|
|
1221
|
+
- \`type:'pattern'\`(图案填充)WPS COM 没有对应接口,明确报错。`,
|
|
1201
1222
|
category: tools_1.ToolCategory.PRESENTATION,
|
|
1202
1223
|
inputSchema: {
|
|
1203
1224
|
type: 'object',
|
|
1204
1225
|
properties: {
|
|
1226
|
+
target: {
|
|
1227
|
+
type: 'string',
|
|
1228
|
+
enum: ['slide', 'all', 'master'],
|
|
1229
|
+
description: '作用范围:slide 单页(默认)/ all 整份文稿 / master 母版',
|
|
1230
|
+
},
|
|
1205
1231
|
slideIndex: {
|
|
1206
1232
|
type: 'number',
|
|
1207
|
-
description: '
|
|
1233
|
+
description: '页码(从1开始);target=all/master 时忽略',
|
|
1208
1234
|
},
|
|
1209
|
-
|
|
1235
|
+
type: {
|
|
1210
1236
|
type: 'string',
|
|
1211
|
-
|
|
1237
|
+
enum: ['solid', 'gradient', 'image', 'pattern'],
|
|
1238
|
+
description: '填充类型。不填则按 color→solid / imagePath→image / gradient→gradient 推断',
|
|
1212
1239
|
},
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1240
|
+
color: { type: 'string', description: 'type=solid 时的颜色,十六进制如 #FF0000' },
|
|
1241
|
+
imagePath: { type: 'string', description: 'type=image 时的图片路径' },
|
|
1242
|
+
gradient: {
|
|
1243
|
+
type: 'object',
|
|
1244
|
+
description: 'type=gradient 时的渐变配置:{ type:"linear"|"radial", colors:["#FF0000","#00FF00"] }。' +
|
|
1245
|
+
'WPS 只吃前两个颜色,多余的颜色会被忽略(会在提示里说明)',
|
|
1246
|
+
},
|
|
1247
|
+
pattern: { type: 'string', description: 'type=pattern 时的图案名(WPS 不支持,传了会明确报错)' },
|
|
1248
|
+
// 老名字(别名)可能会带过来的历史参数,接受但不推荐
|
|
1249
|
+
background: {
|
|
1250
|
+
type: 'object',
|
|
1251
|
+
description: '(历史形状){type,color,colors,imagePath,pattern},等价于把里面几项平铺到顶层',
|
|
1216
1252
|
},
|
|
1217
1253
|
},
|
|
1218
|
-
required
|
|
1254
|
+
// 刻意不 required['type']:草案里是必填,但那样 5 个旧名就没法走别名(别名不能注入参数),
|
|
1255
|
+
// 而合并的目标恰恰是"旧名无损映射"。改为按参数推断,并在描述里写明。
|
|
1256
|
+
required: [],
|
|
1219
1257
|
},
|
|
1220
1258
|
};
|
|
1259
|
+
/** 把老形状 background{} 摊平到顶层(只补缺失的键) */
|
|
1260
|
+
function flattenLegacyBackground(args) {
|
|
1261
|
+
const out = { ...args };
|
|
1262
|
+
const bg = args.background;
|
|
1263
|
+
if (bg && typeof bg === 'object') {
|
|
1264
|
+
for (const [k, v] of Object.entries(bg)) {
|
|
1265
|
+
if (out[k] === undefined)
|
|
1266
|
+
out[k] = v;
|
|
1267
|
+
}
|
|
1268
|
+
// 老形状里 "colors" 是渐变色数组
|
|
1269
|
+
if (out.gradient === undefined && Array.isArray(bg.colors)) {
|
|
1270
|
+
out.gradient = { type: 'linear', colors: bg.colors };
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
return out;
|
|
1274
|
+
}
|
|
1221
1275
|
const setBackgroundHandler = async (args) => {
|
|
1222
|
-
const
|
|
1276
|
+
const a = flattenLegacyBackground(args);
|
|
1277
|
+
const target = a.target || 'slide';
|
|
1278
|
+
const slideIndex = a.slideIndex;
|
|
1279
|
+
const color = a.color;
|
|
1280
|
+
const imagePath = a.imagePath;
|
|
1281
|
+
const pattern = a.pattern;
|
|
1282
|
+
const gradient = a.gradient;
|
|
1283
|
+
// type 推断:草案要求必填,但旧名走别名时给不出 type(别名不能注入参数)。
|
|
1284
|
+
// 按"给了什么填什么"推断 —— 唯一有歧义的情况是同时给了多个,那时按 image > gradient > color 取先。
|
|
1285
|
+
const type = a.type ||
|
|
1286
|
+
(imagePath ? 'image' : gradient ? 'gradient' : pattern ? 'pattern' : color ? 'solid' : '');
|
|
1287
|
+
const fail = (msg, err) => ({
|
|
1288
|
+
id: (0, uuid_1.v4)(),
|
|
1289
|
+
success: false,
|
|
1290
|
+
content: [{ type: 'text', text: msg }],
|
|
1291
|
+
error: err ?? msg,
|
|
1292
|
+
});
|
|
1293
|
+
const ok = (text) => ({
|
|
1294
|
+
id: (0, uuid_1.v4)(),
|
|
1295
|
+
success: true,
|
|
1296
|
+
content: [{ type: 'text', text }],
|
|
1297
|
+
});
|
|
1298
|
+
if (!type) {
|
|
1299
|
+
return fail('要说清怎么填:给 color(纯色)/ imagePath(图片)/ gradient(渐变)之一,或显式传 type。' +
|
|
1300
|
+
'示例:{ "target":"slide", "slideIndex":1, "type":"solid", "color":"#003366" }');
|
|
1301
|
+
}
|
|
1302
|
+
if (type === 'pattern') {
|
|
1303
|
+
return fail('WPS COM 没有图案填充的接口,type:"pattern" 无法执行(这不是参数问题,换 solid/gradient/image)。');
|
|
1304
|
+
}
|
|
1305
|
+
if (type === 'solid' && !color)
|
|
1306
|
+
return fail('type=solid 需要 color,例如 "#003366"。');
|
|
1307
|
+
if (type === 'image' && !imagePath)
|
|
1308
|
+
return fail('type=image 需要 imagePath(图片在本机的绝对路径)。');
|
|
1309
|
+
if (type === 'gradient') {
|
|
1310
|
+
const colors = (gradient && gradient.colors) || [];
|
|
1311
|
+
if (!Array.isArray(colors) || colors.length < 2) {
|
|
1312
|
+
return fail('type=gradient 需要 gradient.colors 至少两个颜色,例如 ["#FF0000","#00FF00"]。');
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
if (target === 'master' && type === 'image') {
|
|
1316
|
+
return fail('母版背景不支持图片(WPS 的母版 Fill 只吃纯色/渐变)。要整份文稿用图片背景,用 target:"all"。');
|
|
1317
|
+
}
|
|
1318
|
+
if (target === 'slide' && !slideIndex) {
|
|
1319
|
+
return fail('target=slide 需要 slideIndex(从 1 开始)。要改整份文稿用 target:"all"。');
|
|
1320
|
+
}
|
|
1321
|
+
// 一个内部小包装。注意:动作名走变量 → param-shape-audit(扫 executeMethod 的字面量)看不到这 4 个
|
|
1322
|
+
// 调用点,属于那个脚本自己写明的"动态拼参数抓不到 = 漏报"。所以这里的参数是【手工对着 PS 的读法核过的】:
|
|
1323
|
+
// setMasterBackground 读 color / color1 / color2
|
|
1324
|
+
// setBackgroundColor 读 color / applyToAll
|
|
1325
|
+
// setSlideBackground 读 slideIndex / color / imagePath
|
|
1326
|
+
// getSlideCount 无参数
|
|
1327
|
+
// 改这里的参数名时,请同步改上面这份清单(它就是这几个动作的"参数契约")。
|
|
1328
|
+
const exec = (action, params) => wps_client_1.wpsClient.executeMethod(action, params, wps_1.WpsAppType.PRESENTATION);
|
|
1329
|
+
const warnings = [];
|
|
1330
|
+
const where = target === 'all' ? '整份文稿' : target === 'master' ? '母版' : `第 ${slideIndex} 页`;
|
|
1223
1331
|
try {
|
|
1224
|
-
//
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1332
|
+
// ---- 母版 ----
|
|
1333
|
+
if (target === 'master') {
|
|
1334
|
+
const params = type === 'gradient'
|
|
1335
|
+
? { color1: gradient.colors[0], color2: gradient.colors[1] }
|
|
1336
|
+
: { color };
|
|
1337
|
+
const r = await exec('setMasterBackground', params);
|
|
1338
|
+
if (!r.success)
|
|
1339
|
+
return fail(`设置母版背景失败: ${r.error}`, r.error);
|
|
1340
|
+
return ok(`母版背景已设置:${type === 'gradient' ? `渐变 ${gradient.colors.slice(0, 2).join(' → ')}` : color}`);
|
|
1341
|
+
}
|
|
1342
|
+
// ---- 整份文稿 ----
|
|
1343
|
+
if (target === 'all') {
|
|
1344
|
+
if (type === 'solid') {
|
|
1345
|
+
const r = await exec('setBackgroundColor', { color, applyToAll: true });
|
|
1346
|
+
if (!r.success)
|
|
1347
|
+
return fail(`设置整份文稿背景失败: ${r.error}`, r.error);
|
|
1348
|
+
return ok(`整份文稿背景已设为 ${color}(applyToAll)`);
|
|
1349
|
+
}
|
|
1350
|
+
// 渐变/图片没有"一次全设"的动作 → 逐页设。先问页数,别拿失败当终止条件。
|
|
1351
|
+
const cnt = await exec('getSlideCount', {});
|
|
1352
|
+
const total = Number((cnt.data && cnt.data.count) || 0);
|
|
1353
|
+
if (!total)
|
|
1354
|
+
return fail('拿不到页数,无法逐页设置背景。');
|
|
1355
|
+
let done = 0;
|
|
1356
|
+
const failedPages = [];
|
|
1357
|
+
for (let i = 1; i <= total; i++) {
|
|
1358
|
+
const r = type === 'image'
|
|
1359
|
+
? await exec('setSlideBackground', { slideIndex: i, imagePath })
|
|
1360
|
+
: await exec('setSlideBackground', {
|
|
1361
|
+
slideIndex: i,
|
|
1362
|
+
color1: gradient.colors[0],
|
|
1363
|
+
color2: gradient.colors[1],
|
|
1364
|
+
});
|
|
1365
|
+
if (r.success)
|
|
1366
|
+
done++;
|
|
1367
|
+
else
|
|
1368
|
+
failedPages.push(i);
|
|
1369
|
+
}
|
|
1370
|
+
if (done === 0)
|
|
1371
|
+
return fail(`整份文稿逐页设置背景全部失败(共 ${total} 页)。`);
|
|
1372
|
+
if (failedPages.length) {
|
|
1373
|
+
warnings.push({
|
|
1374
|
+
step: 'set_background.all',
|
|
1375
|
+
message: `第 ${failedPages.join('、')} 页没设置成功(共 ${total} 页,成功 ${done} 页)`,
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1237
1378
|
return {
|
|
1238
1379
|
id: (0, uuid_1.v4)(),
|
|
1239
1380
|
success: true,
|
|
1240
|
-
content: [
|
|
1241
|
-
|
|
1242
|
-
type: 'text',
|
|
1243
|
-
text: `幻灯片背景设置成功!\n幻灯片: 第 ${slideIndex} 页\n${detail}`,
|
|
1244
|
-
},
|
|
1245
|
-
],
|
|
1381
|
+
content: [{ type: 'text', text: `整份文稿背景已设置:${done}/${total} 页` }],
|
|
1382
|
+
...(warnings.length ? { warnings } : {}),
|
|
1246
1383
|
};
|
|
1247
1384
|
}
|
|
1385
|
+
// ---- 单页 ----
|
|
1386
|
+
const params = { slideIndex };
|
|
1387
|
+
if (type === 'solid')
|
|
1388
|
+
params.color = color;
|
|
1389
|
+
else if (type === 'image')
|
|
1390
|
+
params.imagePath = imagePath;
|
|
1248
1391
|
else {
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
};
|
|
1392
|
+
params.color1 = gradient.colors[0];
|
|
1393
|
+
params.color2 = gradient.colors[1];
|
|
1394
|
+
}
|
|
1395
|
+
const r = await exec('setSlideBackground', params);
|
|
1396
|
+
if (!r.success)
|
|
1397
|
+
return fail(`设置背景失败: ${r.error}`, r.error);
|
|
1398
|
+
const detail = type === 'solid' ? `颜色 ${color}` : type === 'image' ? `图片 ${imagePath}` : `渐变 ${gradient.colors.slice(0, 2).join(' → ')}`;
|
|
1399
|
+
if (type === 'gradient' && gradient.colors.length > 2) {
|
|
1400
|
+
warnings.push({ step: 'gradient', message: 'WPS 的渐变只支持两个色标,多余的颜色已忽略' });
|
|
1255
1401
|
}
|
|
1256
|
-
}
|
|
1257
|
-
catch (error) {
|
|
1258
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1259
1402
|
return {
|
|
1260
1403
|
id: (0, uuid_1.v4)(),
|
|
1261
|
-
success:
|
|
1262
|
-
content: [{ type: 'text', text:
|
|
1263
|
-
|
|
1404
|
+
success: true,
|
|
1405
|
+
content: [{ type: 'text', text: `背景已设置:${where},${detail}` }],
|
|
1406
|
+
...(warnings.length ? { warnings } : {}),
|
|
1264
1407
|
};
|
|
1265
1408
|
}
|
|
1409
|
+
catch (error) {
|
|
1410
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1411
|
+
return fail(`设置背景出错: ${errMsg}`);
|
|
1412
|
+
}
|
|
1266
1413
|
};
|
|
1267
1414
|
exports.setBackgroundHandler = setBackgroundHandler;
|
|
1268
1415
|
// ============================================================
|
|
@@ -1270,7 +1417,7 @@ exports.setBackgroundHandler = setBackgroundHandler;
|
|
|
1270
1417
|
// ============================================================
|
|
1271
1418
|
exports.setSlideSizeDefinition = {
|
|
1272
1419
|
name: 'wps_ppt_set_slide_size',
|
|
1273
|
-
description:
|
|
1420
|
+
description: `设置演示文稿的幻灯片尺寸(按像素给,内部换算成 WPS 的磅)。
|
|
1274
1421
|
|
|
1275
1422
|
常用尺寸:
|
|
1276
1423
|
- 标准(4:3): 宽960, 高720
|
|
@@ -1279,6 +1426,8 @@ exports.setSlideSizeDefinition = {
|
|
|
1279
1426
|
- A4横版: 宽1123, 高794
|
|
1280
1427
|
- A4竖版: 宽794, 高1123
|
|
1281
1428
|
|
|
1429
|
+
注意:改尺寸会重排整份文稿,元素可能溢出页面。改完建议 wps_ppt_export_slide_as_image 看一眼。
|
|
1430
|
+
|
|
1282
1431
|
使用场景:
|
|
1283
1432
|
- "把PPT改成16:9宽屏"
|
|
1284
1433
|
- "设置幻灯片为A4尺寸"
|
|
@@ -1289,11 +1438,11 @@ exports.setSlideSizeDefinition = {
|
|
|
1289
1438
|
properties: {
|
|
1290
1439
|
width: {
|
|
1291
1440
|
type: 'number',
|
|
1292
|
-
description: '
|
|
1441
|
+
description: '幻灯片宽度(像素,96 DPI;内部 ×0.75 换算成磅)',
|
|
1293
1442
|
},
|
|
1294
1443
|
height: {
|
|
1295
1444
|
type: 'number',
|
|
1296
|
-
description: '
|
|
1445
|
+
description: '幻灯片高度(像素,96 DPI;内部 ×0.75 换算成磅)',
|
|
1297
1446
|
},
|
|
1298
1447
|
},
|
|
1299
1448
|
required: ['width', 'height'],
|
|
@@ -1341,164 +1490,112 @@ exports.setSlideSizeHandler = setSlideSizeHandler;
|
|
|
1341
1490
|
// ============================================================
|
|
1342
1491
|
exports.setTransitionDefinition = {
|
|
1343
1492
|
name: 'wps_ppt_set_transition',
|
|
1344
|
-
description:
|
|
1493
|
+
description: `设置幻灯片切换效果:单页 or 整份文稿(第 8 轮合并了切换族 3 个工具)。
|
|
1345
1494
|
|
|
1346
|
-
|
|
1347
|
-
- fade
|
|
1348
|
-
- push: 推入
|
|
1349
|
-
- wipe: 擦除
|
|
1350
|
-
- split: 拆分
|
|
1351
|
-
- reveal: 揭开
|
|
1352
|
-
- cover: 覆盖
|
|
1353
|
-
- dissolve: 溶解
|
|
1354
|
-
- curtains: 帷幕
|
|
1495
|
+
- \`target\`: slide(默认,只改 \`slideIndex\` 那一页)/ all(整份文稿统一)
|
|
1496
|
+
- \`effect\`(**必填**): fade 淡出 / push 推入 / wipe 擦除 / split 拆分 / reveal 揭开 / cover 覆盖 / dissolve 溶解 / curtains 帷幕 / **none 取消切换**
|
|
1355
1497
|
|
|
1356
|
-
|
|
1357
|
-
- "给第
|
|
1358
|
-
- "
|
|
1359
|
-
- "
|
|
1498
|
+
什么时候用:
|
|
1499
|
+
- "给第1页加个淡出切换" → { target:'slide', slideIndex:1, effect:'fade', duration:1 }
|
|
1500
|
+
- "所有页统一用推入" → { target:'all', effect:'push' }
|
|
1501
|
+
- "第2页不要切换效果" → { target:'slide', slideIndex:2, effect:'none' }
|
|
1502
|
+
|
|
1503
|
+
取消切换用 \`effect:'none'\`,不要去找"删除切换"的工具 —— 切换本来就是"切走时播放的东西",
|
|
1504
|
+
把它设成没有就等价于删掉,而且这样不会因为名字里有"删/删掉"而弹破坏性确认框。
|
|
1505
|
+
|
|
1506
|
+
真限制:没有"切换音效"参数。WPS 的 COM 接口里没有"切走时播一段音频"这个能力
|
|
1507
|
+
(那是 PowerPoint 的 AddMediaObject2),所以本工具不提供该参数 —— 要音效得先在 WPS 里录进切换设置。`,
|
|
1360
1508
|
category: tools_1.ToolCategory.PRESENTATION,
|
|
1361
1509
|
inputSchema: {
|
|
1362
1510
|
type: 'object',
|
|
1363
1511
|
properties: {
|
|
1512
|
+
target: {
|
|
1513
|
+
type: 'string',
|
|
1514
|
+
enum: ['slide', 'all'],
|
|
1515
|
+
description: '作用范围:slide 单页(默认)/ all 整份文稿',
|
|
1516
|
+
},
|
|
1364
1517
|
slideIndex: {
|
|
1365
1518
|
type: 'number',
|
|
1366
|
-
description: '幻灯片索引(从1
|
|
1519
|
+
description: '幻灯片索引(从1开始);target=all 时忽略',
|
|
1367
1520
|
},
|
|
1368
|
-
|
|
1521
|
+
effect: {
|
|
1369
1522
|
type: 'string',
|
|
1370
|
-
description: '
|
|
1523
|
+
description: '切换效果:fade / push / wipe / split / reveal / cover / dissolve / curtains;none = 取消切换',
|
|
1524
|
+
},
|
|
1525
|
+
duration: {
|
|
1526
|
+
type: 'number',
|
|
1527
|
+
description: '切换持续时间(秒),默认1秒',
|
|
1371
1528
|
},
|
|
1372
1529
|
},
|
|
1373
|
-
required: [
|
|
1530
|
+
required: [],
|
|
1374
1531
|
},
|
|
1375
1532
|
};
|
|
1533
|
+
const TRANS_NAME_MAP = {
|
|
1534
|
+
fade: '淡出', push: '推入', wipe: '擦除', split: '拆分',
|
|
1535
|
+
reveal: '揭开', cover: '覆盖', dissolve: '溶解', curtains: '帷幕',
|
|
1536
|
+
none: '取消切换',
|
|
1537
|
+
};
|
|
1376
1538
|
const setTransitionHandler = async (args) => {
|
|
1377
|
-
const { slideIndex,
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
content: [
|
|
1389
|
-
{
|
|
1390
|
-
type: 'text',
|
|
1391
|
-
text: `切换效果设置成功!\n幻灯片: 第 ${slideIndex} 页\n切换效果: ${transNameMap[transition] || transition}`,
|
|
1392
|
-
},
|
|
1393
|
-
],
|
|
1394
|
-
};
|
|
1395
|
-
}
|
|
1396
|
-
else {
|
|
1397
|
-
return {
|
|
1398
|
-
id: (0, uuid_1.v4)(),
|
|
1399
|
-
success: false,
|
|
1400
|
-
content: [{ type: 'text', text: `设置切换效果失败: ${response.error}` }],
|
|
1401
|
-
error: response.error,
|
|
1402
|
-
};
|
|
1403
|
-
}
|
|
1539
|
+
const { slideIndex, duration } = args;
|
|
1540
|
+
const target = (args.target || 'slide');
|
|
1541
|
+
// 第 2 轮起的旧参数名是 transition;旧名调用经别名进来时带的是它
|
|
1542
|
+
const effect = args.effect || args.transition;
|
|
1543
|
+
if (!effect) {
|
|
1544
|
+
return {
|
|
1545
|
+
id: (0, uuid_1.v4)(),
|
|
1546
|
+
success: false,
|
|
1547
|
+
content: [{ type: 'text', text: `必须给 effect(切换效果名,或 none 表示取消切换)` }],
|
|
1548
|
+
error: 'Missing required parameter: effect',
|
|
1549
|
+
};
|
|
1404
1550
|
}
|
|
1405
|
-
|
|
1406
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1551
|
+
if (target === 'slide' && !slideIndex) {
|
|
1407
1552
|
return {
|
|
1408
1553
|
id: (0, uuid_1.v4)(),
|
|
1409
1554
|
success: false,
|
|
1410
|
-
content: [{ type: 'text', text:
|
|
1411
|
-
error:
|
|
1555
|
+
content: [{ type: 'text', text: `target='slide' 时必须给 slideIndex` }],
|
|
1556
|
+
error: 'Missing required parameter: slideIndex',
|
|
1412
1557
|
};
|
|
1413
1558
|
}
|
|
1414
|
-
};
|
|
1415
|
-
exports.setTransitionHandler = setTransitionHandler;
|
|
1416
|
-
// ============================================================
|
|
1417
|
-
// 20. wps_ppt_add_chart - 在幻灯片中插入图表
|
|
1418
|
-
// ============================================================
|
|
1419
|
-
exports.addChartDefinition = {
|
|
1420
|
-
name: 'wps_ppt_add_chart',
|
|
1421
|
-
description: `在幻灯片中插入图表。
|
|
1422
|
-
|
|
1423
|
-
支持的图表类型:
|
|
1424
|
-
- bar: 柱形图
|
|
1425
|
-
- line: 折线图
|
|
1426
|
-
- pie: 饼图
|
|
1427
|
-
- scatter: 散点图
|
|
1428
|
-
- area: 面积图
|
|
1429
|
-
- doughnut: 圆环图
|
|
1430
|
-
|
|
1431
|
-
使用场景:
|
|
1432
|
-
- "在第1页插入一个柱形图"
|
|
1433
|
-
- "添加饼图展示数据"
|
|
1434
|
-
- "插入折线图显示趋势"`,
|
|
1435
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
1436
|
-
inputSchema: {
|
|
1437
|
-
type: 'object',
|
|
1438
|
-
properties: {
|
|
1439
|
-
slideIndex: {
|
|
1440
|
-
type: 'number',
|
|
1441
|
-
description: '幻灯片索引(从1开始)',
|
|
1442
|
-
},
|
|
1443
|
-
chartType: {
|
|
1444
|
-
type: 'string',
|
|
1445
|
-
description: '图表类型,如 bar, line, pie, scatter, area, doughnut',
|
|
1446
|
-
},
|
|
1447
|
-
data: {
|
|
1448
|
-
type: 'array',
|
|
1449
|
-
description: '图表数据数组,每项包含标签和数值',
|
|
1450
|
-
items: {
|
|
1451
|
-
type: 'object',
|
|
1452
|
-
properties: {
|
|
1453
|
-
label: { type: 'string', description: '数据标签' },
|
|
1454
|
-
value: { type: 'number', description: '数据值' },
|
|
1455
|
-
},
|
|
1456
|
-
},
|
|
1457
|
-
},
|
|
1458
|
-
},
|
|
1459
|
-
required: ['slideIndex', 'chartType', 'data'],
|
|
1460
|
-
},
|
|
1461
|
-
};
|
|
1462
|
-
const addChartHandler = async (args) => {
|
|
1463
|
-
const { slideIndex, chartType, data } = args;
|
|
1464
1559
|
try {
|
|
1465
|
-
|
|
1560
|
+
// 整份文稿走 PS 侧的 applyTransitionToAll:它是独立的动作,
|
|
1561
|
+
// 而 setSlideTransition 的循环版不在这个 case 里,硬塞 all 进去等于让 PS 认一个它不认的键。
|
|
1562
|
+
const response = target === 'all'
|
|
1563
|
+
? await wps_client_1.wpsClient.executeMethod('applyTransitionToAll', { effect, duration: duration || 1 }, wps_1.WpsAppType.PRESENTATION)
|
|
1564
|
+
: await wps_client_1.wpsClient.executeMethod('setSlideTransition', { slideIndex, effect, duration: duration || 1 }, wps_1.WpsAppType.PRESENTATION);
|
|
1466
1565
|
if (response.success) {
|
|
1467
|
-
const
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1566
|
+
const lines = [
|
|
1567
|
+
`切换效果设置成功!`,
|
|
1568
|
+
target === 'all' ? `范围: 全部幻灯片` : `幻灯片: 第 ${slideIndex} 页`,
|
|
1569
|
+
`切换效果: ${TRANS_NAME_MAP[effect] || effect}`,
|
|
1570
|
+
`持续时间: ${duration || 1} 秒`,
|
|
1571
|
+
];
|
|
1572
|
+
if (response.data && response.data.slideCount) {
|
|
1573
|
+
lines.push(`已应用: ${response.data.slideCount} 页`);
|
|
1574
|
+
}
|
|
1471
1575
|
return {
|
|
1472
1576
|
id: (0, uuid_1.v4)(),
|
|
1473
1577
|
success: true,
|
|
1474
|
-
content: [
|
|
1475
|
-
{
|
|
1476
|
-
type: 'text',
|
|
1477
|
-
text: `图表插入成功!\n幻灯片: 第 ${slideIndex} 页\n图表类型: ${chartNameMap[chartType] || chartType}\n数据点数: ${data.length}`,
|
|
1478
|
-
},
|
|
1479
|
-
],
|
|
1480
|
-
};
|
|
1481
|
-
}
|
|
1482
|
-
else {
|
|
1483
|
-
return {
|
|
1484
|
-
id: (0, uuid_1.v4)(),
|
|
1485
|
-
success: false,
|
|
1486
|
-
content: [{ type: 'text', text: `插入图表失败: ${response.error}` }],
|
|
1487
|
-
error: response.error,
|
|
1578
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
1488
1579
|
};
|
|
1489
1580
|
}
|
|
1581
|
+
return {
|
|
1582
|
+
id: (0, uuid_1.v4)(),
|
|
1583
|
+
success: false,
|
|
1584
|
+
content: [{ type: 'text', text: `设置切换效果失败: ${response.error}` }],
|
|
1585
|
+
error: response.error,
|
|
1586
|
+
};
|
|
1490
1587
|
}
|
|
1491
1588
|
catch (error) {
|
|
1492
1589
|
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1493
1590
|
return {
|
|
1494
1591
|
id: (0, uuid_1.v4)(),
|
|
1495
1592
|
success: false,
|
|
1496
|
-
content: [{ type: 'text', text:
|
|
1593
|
+
content: [{ type: 'text', text: `设置切换效果出错: ${errMsg}` }],
|
|
1497
1594
|
error: errMsg,
|
|
1498
1595
|
};
|
|
1499
1596
|
}
|
|
1500
1597
|
};
|
|
1501
|
-
exports.
|
|
1598
|
+
exports.setTransitionHandler = setTransitionHandler;
|
|
1502
1599
|
// ============================================================
|
|
1503
1600
|
// 21. wps_ppt_set_shape_fill - 设置形状填充颜色
|
|
1504
1601
|
// ============================================================
|
|
@@ -1620,14 +1717,12 @@ exports.addSpeakerNotesHandler = addSpeakerNotesHandler;
|
|
|
1620
1717
|
// ============================================================
|
|
1621
1718
|
exports.slideOpsTools = [
|
|
1622
1719
|
{ definition: exports.deleteSlideDefinition, handler: exports.deleteSlideHandler },
|
|
1623
|
-
{ definition: exports.duplicateSlideDefinition, handler: exports.duplicateSlideHandler },
|
|
1624
1720
|
{ definition: exports.moveSlideDefinition, handler: exports.moveSlideHandler },
|
|
1625
1721
|
{ definition: exports.getSlideCountDefinition, handler: exports.getSlideCountHandler },
|
|
1626
1722
|
{ definition: exports.getSlideInfoDefinition, handler: exports.getSlideInfoHandler },
|
|
1627
1723
|
{ definition: exports.switchSlideDefinition, handler: exports.switchSlideHandler },
|
|
1628
1724
|
{ definition: exports.setSlideLayoutDefinition, handler: exports.setSlideLayoutHandler },
|
|
1629
1725
|
{ definition: exports.getSlideNotesDefinition, handler: exports.getSlideNotesHandler },
|
|
1630
|
-
{ definition: exports.setSlideNotesDefinition, handler: exports.setSlideNotesHandler },
|
|
1631
1726
|
{ definition: exports.addShapeDefinition, handler: exports.addShapeHandler },
|
|
1632
1727
|
{ definition: exports.setShapeStyleDefinition, handler: exports.setShapeStyleHandler },
|
|
1633
1728
|
{ definition: exports.addTextboxDefinition, handler: exports.addTextboxHandler },
|
|
@@ -1638,7 +1733,6 @@ exports.slideOpsTools = [
|
|
|
1638
1733
|
{ definition: exports.setBackgroundDefinition, handler: exports.setBackgroundHandler },
|
|
1639
1734
|
{ definition: exports.setSlideSizeDefinition, handler: exports.setSlideSizeHandler },
|
|
1640
1735
|
{ definition: exports.setTransitionDefinition, handler: exports.setTransitionHandler },
|
|
1641
|
-
{ definition: exports.addChartDefinition, handler: exports.addChartHandler },
|
|
1642
1736
|
{ definition: exports.setShapeFillDefinition, handler: exports.setShapeFillHandler },
|
|
1643
1737
|
{ definition: exports.addSpeakerNotesDefinition, handler: exports.addSpeakerNotesHandler },
|
|
1644
1738
|
];
|