15815213711
2024-08-26 67b8b6731811983447e053d4396b3708c14dfe3c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//require('bytenode');
const Ps = require('../../ps');
 
/**
  * loadView 生成BrowserWindow的html content
  */
const loadView = function (opt = {}) {
  const webSecurity = opt.webSecurity;
  const src = opt.src;
  const title = opt.title;
  const script = opt.script;
 
  //const scriptUrl = new URL('eefile://' + src);
  const scriptUrl = 'eefile://' + src;
  console.log('[ee-core:job] scriptUrl: ', scriptUrl);
 
  // 脚本内容
  //const scriptBytenode = Ps.isDev() ? '' : `<script> require('bytenode') </script>`;
  const scriptContent = webSecurity ? `<script> ${ script } </script>` : `<script src='${scriptUrl}'></script>`;
 
  // html内容
  const htmlContent = (`
    <!DOCTYPE html>
    <html>
      <head>
        <title>${title}</title>
        <meta charset="UTF-8">
      </head>
      <body>
        ${scriptContent}
      </body>
    </html>
  `);
 
  const DataURI = 'data:text/html;charset=UTF-8,';
  const data = DataURI + encodeURIComponent(htmlContent);
 
  return data;
};
 
module.exports = loadView;