{"id":997,"date":"2024-05-15T23:41:00","date_gmt":"2024-05-15T15:41:00","guid":{"rendered":"https:\/\/gjweb.top\/?p=997"},"modified":"2024-05-15T19:42:50","modified_gmt":"2024-05-15T11:42:50","slug":"electron-%e5%ad%90%e7%aa%97%e5%8f%a3%e9%81%87%e5%88%b0-hash-%e8%b7%af%e7%94%b1%e6%97%a0%e6%b3%95%e5%8a%a0%e8%bd%bd","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=997","title":{"rendered":"electron \u5b50\u7a97\u53e3\u9047\u5230 hash \u8def\u7531\u65e0\u6cd5\u52a0\u8f7d"},"content":{"rendered":"\n<p>\u573a\u666f\u63cf\u8ff0\uff1a\u5728\u5f00\u53d1\u684c\u9762\u684c\u9762\u7aef\u5e94\u7528\u65f6\u4f1a\u7ed3\u5408 vue \u6216\u8005 react \u7b49\u6846\u67b6\uff0c\u5982\u679c\u5728\u5355\u9875\u9762\u5e94\u7528\u4e2d\u6307\u5b9a\u5b50\u7a97\u53e3\u9875\u9762\u8def\u7531\u5728\u751f\u4ea7\u73af\u5883\u4e0b\u65f6\u65e0\u6cd5\u52a0\u8f7d\u3002<\/p>\n\n\n\n<p>\u7ecf\u8fc7\u9a8c\u8bc1\u53d1\u73b0 electron \u5bf9\u6846\u67b6\u4e2d\u8def\u7531\u7684 <code>History<\/code> \u6a21\u5f0f\u65e0\u6cd5\u89e3\u6790\uff0c\u53ea\u80fd\u4f7f\u7528 <code>hash<\/code> \u6a21\u5f0f<\/p>\n\n\n\n<p>\u793a\u4f8b<\/p>\n\n\n\n<p>\u521b\u5efa\u5b50\u7a97\u53e3\uff0c\u5728\u5f00\u53d1\u73af\u5883\u548c\u751f\u4ea7\u73af\u5883\u6307\u5b9a\u8def\u7531<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { is } from '@electron-toolkit\/utils';<br>import { BrowserWindow } from 'electron'<br>import path from 'path';<br>import url from \"url\";<br>const createNewWindow = ()=&gt;{<br> &nbsp;let newWindow = new BrowserWindow({<br> &nbsp; &nbsp;width: 400,<br> &nbsp; &nbsp;height: 300,<br> &nbsp; &nbsp;frame:false, \/\/ \u9690\u85cf\u6807\u9898\u680f<br> &nbsp; &nbsp;webPreferences: {<br> &nbsp; &nbsp; &nbsp;nodeIntegration: true<br> &nbsp;  }<br>  });<br> &nbsp;if (is.dev &amp;&amp; process.env['ELECTRON_RENDERER_URL']) {<br> &nbsp; &nbsp;\/*\u5f00\u53d1\u73af\u5883\u8bbf\u95ee\u5730\u5740 localhost:prot\/#\/repair*\/<br> &nbsp; &nbsp;newWindow.loadURL(`${process.env['ELECTRON_RENDERER_URL']}\/#\/repair`) <br>  } else {<br> &nbsp; &nbsp;\/**\u751f\u4ea7\u73af\u5883\u4e2d\u6307\u5b9a\u8def\u7531\uff0c\u7edd\u5bf9\u8def\u5f84\u7684\u65b9\u5f0f*\/<br> &nbsp; &nbsp;const newUrl = url.format({<br> &nbsp; &nbsp; &nbsp;pathname: path.join(__dirname, '..\/renderer', 'index.html'),<br> &nbsp; &nbsp; &nbsp;protocol: 'file:',<br> &nbsp; &nbsp; &nbsp;slashes: true,<br> &nbsp; &nbsp; &nbsp;hash: 'repair'<br> &nbsp;  });<br> &nbsp; &nbsp;newWindow.loadURL(newUrl);<br>  }<br> &nbsp;\/\/ newWindow.webContents.openDevTools(); \/\/ \u53ef\u9009\uff0c\u6253\u5f00\u5f00\u53d1\u8005\u5de5\u5177<br>}<br>\u200b<br>export &nbsp;default createNewWindow;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u573a\u666f\u63cf\u8ff0\uff1a\u5728\u5f00\u53d1\u684c\u9762\u684c\u9762\u7aef\u5e94\u7528\u65f6\u4f1a\u7ed3\u5408 vue \u6216\u8005 react \u7b49\u6846\u67b6\uff0c\u5982\u679c\u5728\u5355\u9875\u9762\u5e94\u7528\u4e2d\u6307\u5b9a\u5b50\u7a97\u53e3\u9875\u9762\u8def\u7531 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-997","post","type-post","status-publish","format-standard","hentry","category-electron"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=997"}],"version-history":[{"count":1,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/997\/revisions"}],"predecessor-version":[{"id":998,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/997\/revisions\/998"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}