| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- const fs = require('fs')
- const paths = [
- 'd:/ylrz_saas_new/saas-companyui/public/chat-aggregate.html',
- 'd:/ylrz_saas_new/saas-mgnui/public/chat-aggregate.html',
- 'd:/ylrz_saas_new/adminui/public/chat-aggregate.html',
- 'd:/ylrz_saas_new/java/fs-comm-gateway/src/main/resources/static/chat-aggregate.html',
- 'd:/ylrz_saas_new/java/fs-saas-company/src/main/resources/static/chat-aggregate.html'
- ]
- const fnBlock = `
- const formatLobsterDateTime = (time) => {
- if (time === null || time === undefined || time === '') return '??';
- const date = time instanceof Date ? time : new Date(time);
- if (isNaN(date.getTime())) return '??';
- const y = date.getFullYear();
- const m = String(date.getMonth() + 1).padStart(2, '0');
- const d = String(date.getDate()).padStart(2, '0');
- const h = String(date.getHours()).padStart(2, '0');
- const mi = String(date.getMinutes()).padStart(2, '0');
- const s = String(date.getSeconds()).padStart(2, '0');
- return \`\${y}-\${m}-\${d} \${h}:\${mi}:\${s}\`;
- };
- `
- for (const p of paths) {
- if (!fs.existsSync(p)) {
- console.log('skip', p)
- continue
- }
- let c = fs.readFileSync(p, 'utf8')
- if (c.includes('const formatLobsterDateTime')) {
- console.log('already', p)
- continue
- }
- c = c.replace(
- /return await response\.json\(\);\r?\n };\r?\n\r?\n \/\/ �˻��б�/,
- 'return await response.json();\n };\n\n const formatLobsterDateTime = (time) => {\n if (time === null || time === undefined || time === \'\') return \'��\';\n const date = time instanceof Date ? time : new Date(time);\n if (isNaN(date.getTime())) return \'��\';\n const y = date.getFullYear();\n const m = String(date.getMonth() + 1).padStart(2, \'0\');\n const d = String(date.getDate()).padStart(2, \'0\');\n const h = String(date.getHours()).padStart(2, \'0\');\n const mi = String(date.getMinutes()).padStart(2, \'0\');\n const s = String(date.getSeconds()).padStart(2, \'0\');\n return `${y}-${m}-${d} ${h}:${mi}:${s}`;\n };\n\n // �˻��б�'
- )
- c = c.replace(
- '<div class="session-time">{{sess.lastTime||\'\'}}</div>',
- '<div class="session-time">{{formatLobsterDateTime(sess.lastTime)}}</div>'
- )
- c = c.replace(
- '<div class="msg-time">{{msg.time}}</div>',
- '<div class="msg-time">{{formatLobsterDateTime(msg.time)}}</div>'
- )
- c = c.replace(
- '<span class="value">{{currentSession?.createTime||\'-\'}}</span>',
- '<span class="value">{{formatLobsterDateTime(currentSession?.createTime)}}</span>'
- )
- c = c.replace(
- '<div class="time">{{record.time}}</div>',
- '<div class="time">{{formatLobsterDateTime(record.time)}}</div>'
- )
- c = c.replace(
- /new Date\(\)\.toLocaleTimeString\('zh-CN',\{hour:'2-digit',minute:'2-digit'\}\)/g,
- 'new Date()'
- )
- c = c.replace(/new Date\(\)\.toLocaleDateString\('zh-CN'\)/g, 'new Date()')
- c = c.replace(
- /selectAccount, selectSession, sendMessage, toggleControlMode, channelName/,
- 'selectAccount, selectSession, sendMessage, toggleControlMode, channelName, formatLobsterDateTime'
- )
- fs.writeFileSync(p, c, 'utf8')
- console.log('updated', p)
- }
|