diff --git a/my-mp/package.json b/my-mp/package.json index e98467b3e7b032f35ca7cd026588415896c90564..bf6afa95a6d30469a0a1f8fe5f525d4f92837305 100644 --- a/my-mp/package.json +++ b/my-mp/package.json @@ -23,6 +23,7 @@ "dependencies": { "@electron-toolkit/preload": "^1.0.2", "@electron-toolkit/utils": "^1.0.2", + "@electron/remote": "^2.0.8", "axios": "^1.1.3", "crypto-js": "^4.1.1", "electron-updater": "^4.6.5", diff --git a/my-mp/src/main/index.ts b/my-mp/src/main/index.ts index 40184c1def939daee2ff7c333ab7eec79e1c9ee5..5298a12d2eb636803416d4b93350220d40d16a33 100644 --- a/my-mp/src/main/index.ts +++ b/my-mp/src/main/index.ts @@ -23,7 +23,8 @@ function createWindow(): void { nodeIntegration: true, webSecurity: false, allowRunningInsecureContent: true, - contextIsolation: false + contextIsolation: false, + webviewTag: true } }) diff --git a/my-mp/src/renderer/src/utils/MyMp/index.ts b/my-mp/src/renderer/src/utils/MyMp/index.ts index 56f7a2a83a55bcbc2f9f9514962499f92ce5642f..50ba46fa1edbc40d90b261792e511558f89e2abd 100644 --- a/my-mp/src/renderer/src/utils/MyMp/index.ts +++ b/my-mp/src/renderer/src/utils/MyMp/index.ts @@ -226,6 +226,7 @@ class MyMp { // } // } }); + return; } // 3. 直接reject拒绝 diff --git a/my-mp/src/renderer/src/utils/MyMp/utils/cache4web.ts b/my-mp/src/renderer/src/utils/MyMp/utils/cache4web.ts index d30126721d8866484a00c0a942bfa23a65651b38..19c8d64df5e6c66456e5c2364ee9b75e6b51e1c5 100644 --- a/my-mp/src/renderer/src/utils/MyMp/utils/cache4web.ts +++ b/my-mp/src/renderer/src/utils/MyMp/utils/cache4web.ts @@ -5,7 +5,7 @@ export default class Cache { constructor(cacheName: string) { this.cacheName = cacheName; - this._data = localStorage.getItem(this.cacheName); + this._data = localStorage.getItem(this.cacheName) || {}; } get(key: string) { return this._data[key]; diff --git a/my-mp/src/renderer/src/utils/MyMp/utils/request.ts b/my-mp/src/renderer/src/utils/MyMp/utils/request.ts index 09fdbfb6a37cece099ea82a2994dce2d74768d69..79ab905fa2e3bf9757500670ab9a711baf5bedd3 100644 --- a/my-mp/src/renderer/src/utils/MyMp/utils/request.ts +++ b/my-mp/src/renderer/src/utils/MyMp/utils/request.ts @@ -34,7 +34,7 @@ WechatRequest.interceptors.request.use( // do something before request is sent // @ts-ignore - config.headers?.set!('Referer', Config.baseurl); + // config.headers?.set!('Referer', Config.baseurl); // if (store.getters.token) { // // let each request carry token // // ['X-Token'] is a custom headers key diff --git a/my-mp/src/renderer/src/views/my_wechat/lilili.vue b/my-mp/src/renderer/src/views/my_wechat/lilili.vue index 08b65036fefb1d6d451b0e0a2417e85e266dc1e7..c4ab89aefa717f70934eac99c1d0396a4d777e98 100644 --- a/my-mp/src/renderer/src/views/my_wechat/lilili.vue +++ b/my-mp/src/renderer/src/views/my_wechat/lilili.vue @@ -57,12 +57,12 @@ - 登录公众号 + 登录公众号 - 打开公众号 + 打开公众号
@@ -70,7 +70,9 @@
- + + +
@@ -117,6 +119,19 @@ export default { } this.mp = new MyMp(this.mp_info.usr, this.mp_info.pwd, this.$refs.qrcode) + + let qrcode = this.$refs.qrcode; + this.$refs.qrcode.addEventListener('dom-ready', () => { + let content = this.$refs.qrcode.getWebContentsId(); + setTimeout(() => { + console.log('setTimeout', content, document.cookie) + + }, 1000*3); + console.log(content, document.cookie) + // content = require('@electron/remote').webContents.fromId(content) + // content = require('electron').webContents.fromId(content) + // console.log('content', content) + }) }, created() { }, @@ -126,9 +141,14 @@ export default { // my_open_cmd(cmd, {'cwd': 'D:/_ALL/CODE/gitee/constellations/Capricorn/WeChat/my_cmd'}) console.log(cmd, wx) }, - mp_lg() { - // this.mp.checklogin(); - this.mp.login(this.mp_info.usr, this.mp_info.pwd) + async mp_lg() { + try { + let isLg = await this.mp.loginchk(); + console.log(isLg); + } catch (error) { + console.log('isLg = false.'); + } + // this.mp.login(this.mp_info.usr, this.mp_info.pwd) }, mp_open() {},