diff --git a/image-studio/deploy/add-homepage-card.mjs b/image-studio/deploy/add-homepage-card.mjs new file mode 100644 index 0000000..dd76520 --- /dev/null +++ b/image-studio/deploy/add-homepage-card.mjs @@ -0,0 +1,89 @@ +/** + * 在guanghulab.com首页添加图片工作室入口卡片 + */ + +const GZ = { ip: '43.139.217.141', port: 3910, key: 'zy_gtw_4a155446b7acc09fe46a2a29972c0ca5d9954da19c35dc23' } + +async function callGK(srv, method, path, body = null) { + const url = `http://${srv.ip}:${srv.port}${path}` + const opts = { method, headers: { 'Authorization': `Bearer ${srv.key}`, 'Content-Type': 'application/json' } } + if (body) opts.body = JSON.stringify(body) + const res = await fetch(url, opts) + const text = await res.text() + try { return { status: res.status, data: JSON.parse(text) } } + catch { return { status: res.status, data: { raw: text } } } +} + +async function readFile(srv, path) { + const r = await callGK(srv, 'POST', '/file/read', { path }) + if (r.status === 200) return r.data.content + return null +} + +async function writeFile(srv, path, content) { + return (await callGK(srv, 'POST', '/file/write', { path, content })).status === 200 +} + +async function main() { + // 读取首页HTML + const html = await readFile(GZ, '/opt/guanghulab-repo/homepage/index.html') + if (!html) { + console.log('❌ 读取失败') + return + } + + console.log('当前首页大小:', html.length, '字符') + + // 在语料采集系统卡片和架构进度卡片之间插入图片工作室卡片 + // 找到语料采集卡片关闭后的位置 + + // 插入标记:在 语料采集系统card 的 之后、架构进度的grid之前插入 + const marker = '' + const insertIdx = html.indexOf(marker) + + if (insertIdx === -1) { + console.log('❌ 找不到插入位置') + return + } + + const imageStudioCard = ` + +
+
铸渊图片工作室 神笔马良
+
+
+ 🎨 +
+
+
+
神笔马良 · 你说我画
+
告诉铸渊内容和场景,自动生成小红书/即刻配图、海报、通知卡片
+
+
小红书 · 即刻 · 海报
+
自动配色 · 内容自适应
+
新加坡渲染 · 广州分发
+
+
+
+
+
+ +` + + const newHtml = html.slice(0, insertIdx) + imageStudioCard + html.slice(insertIdx) + + if (await writeFile(GZ, '/opt/guanghulab-repo/homepage/index.html', newHtml)) { + console.log('✅ 首页更新成功') + console.log('更新后大小:', newHtml.length, '字符') + + // 验证 + const verify = await readFile(GZ, '/opt/guanghulab-repo/homepage/index.html') + if (verify && verify.includes('图片工作室')) { + console.log('✅ 图片工作室入口已添加到首页') + } + } else { + console.log('❌ 写入失败') + } +} + +main().catch(err => console.error('❌', err)) diff --git a/image-studio/deploy/check-homepage.mjs b/image-studio/deploy/check-homepage.mjs new file mode 100644 index 0000000..36e1114 --- /dev/null +++ b/image-studio/deploy/check-homepage.mjs @@ -0,0 +1,51 @@ +/** + * 查看guanghulab.com首页 + */ + +const GZ = { ip: '43.139.217.141', port: 3910, key: 'zy_gtw_4a155446b7acc09fe46a2a29972c0ca5d9954da19c35dc23' } + +async function callGK(srv, method, path, body = null) { + const url = `http://${srv.ip}:${srv.port}${path}` + const opts = { method, headers: { 'Authorization': `Bearer ${srv.key}`, 'Content-Type': 'application/json' } } + if (body) opts.body = JSON.stringify(body) + const res = await fetch(url, opts) + const text = await res.text() + try { return { status: res.status, data: JSON.parse(text) } } + catch { return { status: res.status, data: { raw: text } } } +} + +async function exec(srv, cmd) { + const r = await callGK(srv, 'POST', '/exec', { cmd }) + return r.data +} + +async function readFile(srv, path) { + const r = await callGK(srv, 'POST', '/file/read', { path }) + if (r.status === 200) return r.data.content + return null +} + +async function main() { + // 查看首页目录 + console.log('📂 首页目录结构:') + const r1 = await exec(GZ, 'ls -la /opt/guanghulab-repo/homepage/ 2>&1') + console.log(r1.stdout || r1.stderr) + + // 读取index.html + console.log('\n📄 index.html:') + const html = await readFile(GZ, '/opt/guanghulab-repo/homepage/index.html') + if (html) console.log(html) + else console.log('(读取失败)') + + // 看看子目录 + console.log('\n📂 首页子目录:') + const r2 = await exec(GZ, 'find /opt/guanghulab-repo/homepage/ -type f 2>&1') + console.log(r2.stdout || r2.stderr) + + // 看首页通过Nginx访问的效果 + console.log('\n🔍 首页HTML:') + const r3 = await exec(GZ, `curl -s -k -H "Host: guanghulab.com" https://localhost/ 2>&1 | head -100`) + console.log(r3.stdout || r3.stderr) +} + +main().catch(err => console.error('❌', err)) diff --git a/image-studio/deploy/verify-homepage.mjs b/image-studio/deploy/verify-homepage.mjs new file mode 100644 index 0000000..c40ba1b --- /dev/null +++ b/image-studio/deploy/verify-homepage.mjs @@ -0,0 +1,39 @@ +/** + * 验证首页更新 + */ + +const GZ = { ip: '43.139.217.141', port: 3910, key: 'zy_gtw_4a155446b7acc09fe46a2a29972c0ca5d9954da19c35dc23' } + +async function callGK(srv, method, path, body = null) { + const url = `http://${srv.ip}:${srv.port}${path}` + const opts = { method, headers: { 'Authorization': `Bearer ${srv.key}`, 'Content-Type': 'application/json' } } + if (body) opts.body = JSON.stringify(body) + const res = await fetch(url, opts) + const text = await res.text() + try { return { status: res.status, data: JSON.parse(text) } } + catch { return { status: res.status, data: { raw: text } } } +} + +async function exec(srv, cmd) { + const r = await callGK(srv, 'POST', '/exec', { cmd }) + return r.data +} + +async function main() { + // 查看首页的图片工作室相关部分 + const r1 = await exec(GZ, `grep -n -A15 "图片工作室" /opt/guanghulab-repo/homepage/index.html`) + console.log('=== 图片工作室入口卡片 ===') + console.log(r1.stdout || r1.stderr) + + // 通过Nginx验证 + console.log('\n=== Nginx渲染验证 ===') + const r2 = await exec(GZ, `curl -s -k -H "Host: guanghulab.com" https://localhost/ 2>&1 | grep -o '图片工作室\|神笔马良\|/images/' | head -5`) + console.log('首页包含:', (r2.stdout || r2.stderr || '(无)').replace(/\n/g, ' · ')) + + // 确认图片工作室可访问 + console.log('\n=== 点击跳转验证 ===') + const r3 = await exec(GZ, `curl -s -k --connect-timeout 5 -H "Host: guanghulab.com" -w "\\nHTTP:%{http_code}" https://localhost/images/ 2>&1 | tail -3`) + console.log('/images/ 可访问:', (r3.stdout || '').slice(0, 100)) +} + +main().catch(err => console.error('❌', err))