chore: initialize deployable website and CMS
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
import { initDB, getDB } from './db.js';
|
||||
import bcrypt from 'bcryptjs';
|
||||
import crypto from 'crypto';
|
||||
import 'dotenv/config';
|
||||
|
||||
await initDB();
|
||||
const db = getDB();
|
||||
const now = new Date().toISOString();
|
||||
|
||||
// 首次初始化密码由环境变量提供;未提供时生成一次性随机密码并打印。
|
||||
const adminPassword = process.env.CMS_ADMIN_PASSWORD || crypto.randomBytes(12).toString('base64url');
|
||||
const hash = bcrypt.hashSync(adminPassword, 10);
|
||||
db.run(`INSERT OR IGNORE INTO admins (id, username, password_hash, created_at) VALUES (?, ?, ?, ?)`, ['admin-1', 'admin', hash, now]);
|
||||
|
||||
// 全局配置
|
||||
db.get(`SELECT id FROM global_config WHERE id=1`, (err, row) => {
|
||||
if (!row) {
|
||||
db.run(`INSERT INTO global_config (id, site_title, slogan, seo_title, seo_desc, seo_keywords, hotline, contact_email, contact_address, cta_text, cta_link, updated_at) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
['阿美巴咨询|企业进化陪跑', '让企业进化被看见、被度量、被落地', '阿美巴咨询|企业进化陪跑 · 体系化增长落地', '以企业进化为主线,四大价值坐标与A/M/B状态坐标为观察系', '阿美巴,企业进化,四大价值,A/M/B', '400-XXX-XXXX', 'contact@aiameiba.com', '【占位】成都市', '咨询获取方案', '/contact', now]);
|
||||
}
|
||||
});
|
||||
// 首页板块
|
||||
const sections = [
|
||||
['home-hero', 'home-hero', '让企业进化被看见、被度量、被落地', '以企业进化为主线', '首屏主标题', 1, 100],
|
||||
['home-ameba', 'home-ameba', '关于阿美巴', '克制理性的企业服务', '阿美巴摘要', 1, 90],
|
||||
['home-evolution', 'home-evolution', '企业进化 · 观察坐标', '思想 → 价值 → 状态', '进化摘要', 1, 80],
|
||||
['home-methods', 'home-methods', '方法与能力', '方法×能力×工具', '方法摘要', 1, 70],
|
||||
['home-cases', 'home-cases', '实践案例', '9段固定插槽', '案例摘要', 1, 60],
|
||||
['home-services', 'home-services', '产品服务 · 下一步行动', '禁止电商逻辑', '服务摘要', 1, 50],
|
||||
['home-insights', 'home-insights', '认知观察', '持续观察与沉淀', '观察摘要', 1, 40],
|
||||
];
|
||||
sections.forEach(s => db.run(`INSERT OR IGNORE INTO home_sections (id, key, title, subtitle, summary, visible, sort_order, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [...s, now]));
|
||||
// 阿美巴页面
|
||||
db.get(`SELECT id FROM ameba_page WHERE id=1`, (e, r) => {
|
||||
if (!r) db.run(`INSERT INTO ameba_page (id, brand_position, mission, philosophy, practice, updated_at) VALUES (1, ?, ?, ?, ?, ?)`,
|
||||
['以企业进化经营哲学为底色', '陪跑企业体系化增长落地', '利他、务实、陪跑', '十年以上实战沉淀', now]);
|
||||
});
|
||||
// evolution_thought
|
||||
db.get(`SELECT id FROM evolution_thought WHERE id=1`, (e, r) => {
|
||||
if (!r) db.run(`INSERT INTO evolution_thought (id, content, updated_at) VALUES (1, ?, ?)`, ['进化是持续迭代,而非一次性变革', now]);
|
||||
});
|
||||
// four_values
|
||||
const fvs = [
|
||||
['fv-1', 'value1', '战略价值坐标', '观察企业战略清晰度', '战略价值说明【占位】', 100],
|
||||
['fv-2', 'value2', '组织价值坐标', '观察组织活力', '组织价值说明【占位】', 90],
|
||||
['fv-3', 'value3', '经营价值坐标', '观察经营机制', '经营价值说明【占位】', 80],
|
||||
['fv-4', 'value4', '人的价值坐标', '观察人的成长', '人的价值说明【占位】', 70],
|
||||
];
|
||||
fvs.forEach(f => db.run(`INSERT OR IGNORE INTO four_values (id, key, name, definition, description, sort_order, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)`, [...f, now]));
|
||||
// amb_states 固定说明
|
||||
const ambs = [
|
||||
['amb-A', 'A', 'A 状态|自进化', '具备自驱动', 'A状态说明【占位】', 'A/M/B不绑定企业规模的说明文案固定:同一企业不同价值维度可处不同状态', 100],
|
||||
['amb-M', 'M', 'M 状态|待突破', '存在卡点', 'M状态说明【占位】', '同上固定说明', 90],
|
||||
['amb-B', 'B', 'B 状态|待构建', '基础待构建', 'B状态说明【占位】', '同上固定说明', 80],
|
||||
];
|
||||
ambs.forEach(a => db.run(`INSERT OR IGNORE INTO amb_states (id, key, name, definition, description, fixed_note, sort_order, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [...a, now]));
|
||||
// ten_systems
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
db.run(`INSERT OR IGNORE INTO ten_systems (id, name, description, sort_order, updated_at) VALUES (?, ?, ?, ?, ?)`, [`sys-${i}`, `系统${i}`, `第${i}系统说明【占位】`, 100 - i * 5, now]);
|
||||
}
|
||||
db.get(`SELECT id FROM evolution_process WHERE id=1`, (e, r) => {
|
||||
if (!r) db.run(`INSERT INTO evolution_process (id, steps, scenarios, description, updated_at) VALUES (1, ?, ?, ?, ?)`, ['步骤1→步骤2→步骤3', '适用场景【占位】', '企业进化梳理说明', now]);
|
||||
});
|
||||
db.get(`SELECT id FROM self_check WHERE id=1`, (e, r) => {
|
||||
if (!r) db.run(`INSERT INTO self_check (id, guide, questions, logic_text, next_guide, updated_at) VALUES (1, ?, ?, ?, ?, ?)`, ['轻量自我对照引导文案', JSON.stringify([{q:"战略是否清晰?",options:["A","M","B"]}]), '归位逻辑文案【占位】', '下一步引导:预约咨询', now]);
|
||||
});
|
||||
// 诊断配置
|
||||
db.get(`SELECT id FROM diagnosis_config WHERE id=1`, (e, r) => {
|
||||
if (!r) db.run(`INSERT INTO diagnosis_config (id, weights, thresholds, templates, share_expire_days, updated_at) VALUES (1, ?, ?, ?, ?, ?)`, [
|
||||
JSON.stringify({value1:1, value2:1, value3:1, value4:1}),
|
||||
JSON.stringify({B_max:2.5, M_max:3.8}),
|
||||
JSON.stringify({
|
||||
disclaimer:"本报告基于企业自填信息的初步分析,仅供参考,不替代人工咨询,不做绝对化结论与收益预测。",
|
||||
intro:"基于四大价值坐标与A/M/B状态坐标的初步进化分析"
|
||||
}),
|
||||
30, now
|
||||
]);
|
||||
});
|
||||
// 诊断问卷 16题(每维度4题,单选/量表)
|
||||
const diagQuestions = [
|
||||
// 价值创造
|
||||
['dq-1','value1','价值创造','single','公司未来3年战略方向是否清晰且全员认同?', JSON.stringify([{label:'非常清晰',score:5},{label:'较清晰',score:4},{label:'一般',score:3},{label:'较模糊',score:2},{label:'非常模糊',score:1}]), 100],
|
||||
['dq-2','value1','价值创造','scale','战略目标分解到季度/月度的颗粒度', JSON.stringify([{label:'1分',score:1},{label:'2分',score:2},{label:'3分',score:3},{label:'4分',score:4},{label:'5分',score:5}]), 95],
|
||||
['dq-3','value1','价值创造','single','是否定期进行战略复盘与迭代?', JSON.stringify([{label:'每月',score:5},{label:'每季度',score:4},{label:'每半年',score:3},{label:'每年',score:2},{label:'很少',score:1}]), 90],
|
||||
['dq-4','value1','价值创造','single','核心产品/服务的差异化优势是否明确?', JSON.stringify([{label:'非常明确',score:5},{label:'较明确',score:4},{label:'一般',score:3},{label:'较模糊',score:2},{label:'无',score:1}]), 85],
|
||||
// 价值传递
|
||||
['dq-5','value2','价值传递','single','组织架构是否支撑战略落地?', JSON.stringify([{label:'非常支撑',score:5},{label:'较支撑',score:4},{label:'一般',score:3},{label:'较不支撑',score:2},{label:'完全不支撑',score:1}]), 80],
|
||||
['dq-6','value2','价值传递','scale','跨部门协同效率自评', JSON.stringify([{label:'1分',score:1},{label:'2分',score:2},{label:'3分',score:3},{label:'4分',score:4},{label:'5分',score:5}]), 75],
|
||||
['dq-7','value2','价值传递','single','人才梯队与关键岗位备份情况', JSON.stringify([{label:'非常完善',score:5},{label:'较完善',score:4},{label:'一般',score:3},{label:'较薄弱',score:2},{label:'无',score:1}]), 70],
|
||||
['dq-8','value2','价值传递','single','企业文化与价值观落地程度', JSON.stringify([{label:'高度落地',score:5},{label:'较好',score:4},{label:'一般',score:3},{label:'较弱',score:2},{label:'无',score:1}]), 65],
|
||||
// 价值交付
|
||||
['dq-9','value3','价值交付','single','核心业务流程是否标准化且可复制?', JSON.stringify([{label:'高度标准化',score:5},{label:'较标准化',score:4},{label:'部分',score:3},{label:'较弱',score:2},{label:'无',score:1}]), 60],
|
||||
['dq-10','value3','价值交付','scale','经营数据(产销存/财务)透明度', JSON.stringify([{label:'1分',score:1},{label:'2分',score:2},{label:'3分',score:3},{label:'4分',score:4},{label:'5分',score:5}]), 55],
|
||||
['dq-11','value3','价值交付','single','目标→执行→复盘→改进闭环完整度', JSON.stringify([{label:'非常完整',score:5},{label:'较完整',score:4},{label:'一般',score:3},{label:'较不完整',score:2},{label:'无闭环',score:1}]), 50],
|
||||
['dq-12','value3','价值交付','single','客户交付质量与一致性', JSON.stringify([{label:'非常高',score:5},{label:'较高',score:4},{label:'一般',score:3},{label:'较低',score:2},{label:'很低',score:1}]), 45],
|
||||
// 价值支持
|
||||
['dq-13','value4','价值支持','single','激励机制与价值创造的关联度', JSON.stringify([{label:'高度关联',score:5},{label:'较关联',score:4},{label:'一般',score:3},{label:'较弱',score:2},{label:'无关联',score:1}]), 40],
|
||||
['dq-14','value4','价值支持','scale','员工成长与学习机制完善度', JSON.stringify([{label:'1分',score:1},{label:'2分',score:2},{label:'3分',score:3},{label:'4分',score:4},{label:'5分',score:5}]), 35],
|
||||
['dq-15','value4','价值支持','single','信息化/数字化工具对经营的支持', JSON.stringify([{label:'非常强',score:5},{label:'较强',score:4},{label:'一般',score:3},{label:'较弱',score:2},{label:'无',score:1}]), 30],
|
||||
['dq-16','value4','价值支持','single','企业抗风险与持续改进能力', JSON.stringify([{label:'非常强',score:5},{label:'较强',score:4},{label:'一般',score:3},{label:'较弱',score:2},{label:'很弱',score:1}]), 25],
|
||||
];
|
||||
diagQuestions.forEach(q=> db.run(`INSERT OR IGNORE INTO diagnosis_questions (id, group_key, group_name, type, title, options, sort_order, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, 'published', ?, ?)`, [...q, now, now]));
|
||||
console.log('seed done');
|
||||
console.log(`admin username: admin\nadmin password: ${adminPassword}`);
|
||||
setTimeout(() => process.exit(0), 800);
|
||||
Reference in New Issue
Block a user