3232 <el-table-column prop =" suiteVersion" label =" 版本" width =" 80" />
3333 <el-table-column prop =" suiteDesc" label =" 描述" show-overflow-tooltip />
3434 <el-table-column prop =" createdAt" label =" 创建时间" width =" 180" show-overflow-tooltip />
35- <el-table-column label =" 操作" width =" 220 " fixed =" right" >
35+ <el-table-column label =" 操作" width =" 270 " fixed =" right" >
3636 <template #default =" { row } " >
3737 <el-button size =" small" type =" primary" link @click =" goApiList(row)" >接口管理</el-button >
3838 <el-button size =" small" link @click =" openEdit(row)" >编辑</el-button >
3939 <el-button size =" small" type =" info" link @click =" openPublish(row)" >发布</el-button >
40+ <el-button size =" small" type =" warning" link @click =" openShare(row)" >分享</el-button >
4041 <el-button size =" small" type =" warning" link @click =" doExport(row)" >导出</el-button >
4142 <el-button size =" small" type =" danger" link @click =" doDelete(row)" >删除</el-button >
4243 </template >
7172 <MarketPublishDialog v-model :visible =" publishVisible " item-type="api"
7273 :default-name =" publishForm .itemName " :default-desc =" publishForm .description " :default-group =" publishForm .groupName "
7374 :content-json =" publishForm .contentJson " />
75+
76+ <!-- 分享到官方市场(GitHub PR) -->
77+ <MarketShareDialog v-model :visible =" shareVisible " item-type="api"
78+ :item-name =" shareForm .itemName " :description =" shareForm .description "
79+ :content-json =" shareForm .contentJson " />
7480 </div >
7581</template >
7682
@@ -80,28 +86,49 @@ import { useRouter } from 'vue-router'
8086import { ElMessage , ElMessageBox } from ' element-plus'
8187import request from ' ../../utils/request'
8288import MarketPublishDialog from ' ../../components/MarketPublishDialog.vue'
89+ import MarketShareDialog from ' ../../components/MarketShareDialog.vue'
8390
8491// 发布到市场(套件及其全部接口)
8592const publishVisible = ref (false )
8693const publishForm = ref <any >({ itemName: ' ' , description: ' ' , groupName: ' ' , contentJson: ' {}' })
94+
95+ /** 组装套件内容 JSON(套件 + 全部接口) */
96+ async function buildSuiteContentJson(row : any ) {
97+ const apisRes: any = await request .post (' /suite/api/list' , { suiteCode: row .suiteCode })
98+ const apis = (apisRes .data || []).map ((a : any ) => ({
99+ suiteCode: a .suiteCode , methodCode: a .methodCode , methodName: a .methodName ,
100+ methodDesc: a .methodDesc , url: a .url , requestType: a .requestType || ' POST'
101+ }))
102+ return JSON .stringify ({
103+ suites: [{ suiteCode: row .suiteCode , suiteName: row .suiteName , suiteDesc: row .suiteDesc }], apis
104+ })
105+ }
106+
87107async function openPublish(row : any ) {
88108 try {
89- const apisRes: any = await request .post (' /suite/api/list' , { suiteCode: row .suiteCode })
90- const apis = (apisRes .data || []).map ((a : any ) => ({
91- suiteCode: a .suiteCode , methodCode: a .methodCode , methodName: a .methodName ,
92- methodDesc: a .methodDesc , url: a .url , requestType: a .requestType || ' POST'
93- }))
94109 publishForm .value = {
95110 itemName: row .suiteName || row .suiteCode || ' ' ,
96111 description: row .suiteDesc || ' ' ,
97112 groupName: ' ' ,
98- contentJson: JSON .stringify ({
99- suites: [{ suiteCode: row .suiteCode , suiteName: row .suiteName , suiteDesc: row .suiteDesc }], apis
100- })
113+ contentJson: await buildSuiteContentJson (row )
101114 }
102115 publishVisible .value = true
103116 } catch { /* 拦截器已提示 */ }
104117}
118+
119+ // 分享到官方市场(GitHub PR)
120+ const shareVisible = ref (false )
121+ const shareForm = ref <any >({ itemName: ' ' , description: ' ' , contentJson: ' {}' })
122+ async function openShare(row : any ) {
123+ try {
124+ shareForm .value = {
125+ itemName: row .suiteName || row .suiteCode || ' ' ,
126+ description: row .suiteDesc || ' ' ,
127+ contentJson: await buildSuiteContentJson (row )
128+ }
129+ shareVisible .value = true
130+ } catch { /* 拦截器已提示 */ }
131+ }
105132import { Document , Packer , Paragraph , Table , TableRow , TableCell , WidthType , HeadingLevel , AlignmentType , BorderStyle } from ' docx'
106133import { saveAs } from ' file-saver'
107134
0 commit comments