duqing2026 commited on
Commit
258ca69
·
1 Parent(s): bd4dbec

修复 SWOT 分析页面空白问题 (添加数据迁移逻辑)

Browse files
Files changed (1) hide show
  1. templates/index.html +13 -0
templates/index.html CHANGED
@@ -343,6 +343,12 @@
343
  cost: ['OpenAI API 费用', '服务器运维成本'],
344
  revenue: ['个人版免费', '团队版 $5/人/月']
345
  },
 
 
 
 
 
 
346
  experiments: [
347
  {
348
  hypothesis: '如果我在 V2EX 发布产品介绍,会有至少 50 人注册试用。',
@@ -439,6 +445,13 @@
439
  }
440
  }
441
 
 
 
 
 
 
 
 
442
  if (projects.value.length === 0) {
443
  // 使用 JSON.parse(JSON.stringify(...)) 深拷贝,避免引用问题
444
  projects.value = [JSON.parse(JSON.stringify(DEFAULT_PROJECT))];
 
343
  cost: ['OpenAI API 费用', '服务器运维成本'],
344
  revenue: ['个人版免费', '团队版 $5/人/月']
345
  },
346
+ swot: {
347
+ strengths: ['自动化程度高', '支持多种导出格式'],
348
+ weaknesses: ['依赖 OpenAI API,成本较高', '初次配置较繁琐'],
349
+ opportunities: ['远程办公趋势增加', '开发者工具市场增长'],
350
+ threats: ['GitHub Copilot 等竞品集成类似功能']
351
+ },
352
  experiments: [
353
  {
354
  hypothesis: '如果我在 V2EX 发布产品介绍,会有至少 50 人注册试用。',
 
445
  }
446
  }
447
 
448
+ // 数据迁移:确保所有项目都有 swot 字段
449
+ projects.value.forEach(p => {
450
+ if (!p.swot) {
451
+ p.swot = { strengths: [], weaknesses: [], opportunities: [], threats: [] };
452
+ }
453
+ });
454
+
455
  if (projects.value.length === 0) {
456
  // 使用 JSON.parse(JSON.stringify(...)) 深拷贝,避免引用问题
457
  projects.value = [JSON.parse(JSON.stringify(DEFAULT_PROJECT))];