提交 c064e68a 编写于 作者: N ninecents

webview 应用

上级 097121bf
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
"dependencies": { "dependencies": {
"@electron-toolkit/preload": "^1.0.2", "@electron-toolkit/preload": "^1.0.2",
"@electron-toolkit/utils": "^1.0.2", "@electron-toolkit/utils": "^1.0.2",
"@electron/remote": "^2.0.8",
"axios": "^1.1.3", "axios": "^1.1.3",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"electron-updater": "^4.6.5", "electron-updater": "^4.6.5",
......
...@@ -23,7 +23,8 @@ function createWindow(): void { ...@@ -23,7 +23,8 @@ function createWindow(): void {
nodeIntegration: true, nodeIntegration: true,
webSecurity: false, webSecurity: false,
allowRunningInsecureContent: true, allowRunningInsecureContent: true,
contextIsolation: false contextIsolation: false,
webviewTag: true
} }
}) })
......
...@@ -226,6 +226,7 @@ class MyMp { ...@@ -226,6 +226,7 @@ class MyMp {
// } // }
// } // }
}); });
return;
} }
// 3. 直接reject拒绝 // 3. 直接reject拒绝
......
...@@ -5,7 +5,7 @@ export default class Cache { ...@@ -5,7 +5,7 @@ export default class Cache {
constructor(cacheName: string) { constructor(cacheName: string) {
this.cacheName = cacheName; this.cacheName = cacheName;
this._data = localStorage.getItem(this.cacheName); this._data = localStorage.getItem(this.cacheName) || {};
} }
get(key: string) { get(key: string) {
return this._data[key]; return this._data[key];
......
...@@ -34,7 +34,7 @@ WechatRequest.interceptors.request.use( ...@@ -34,7 +34,7 @@ WechatRequest.interceptors.request.use(
// do something before request is sent // do something before request is sent
// @ts-ignore // @ts-ignore
config.headers?.set!('Referer', Config.baseurl); // config.headers?.set!('Referer', Config.baseurl);
// if (store.getters.token) { // if (store.getters.token) {
// // let each request carry token // // let each request carry token
// // ['X-Token'] is a custom headers key // // ['X-Token'] is a custom headers key
......
...@@ -57,12 +57,12 @@ ...@@ -57,12 +57,12 @@
</el-row> </el-row>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="6"> <el-col :span="6">
<el-button type="primary" plain @click.native=mp_lg() round>登录公众号</el-button> <el-button type="primary" plain @click.native=mp_lg() round>登录公众号</el-button>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-button type="primary" plain @click.native=mp_open() round disabled>打开公众号</el-button> <el-button type="primary" plain @click.native=mp_open() round disabled>打开公众号</el-button>
</el-col> </el-col>
</el-row> </el-row>
<br> <br>
...@@ -70,7 +70,9 @@ ...@@ -70,7 +70,9 @@
<!-- right --> <!-- right -->
<div class="right"> <div class="right">
<img ref="qrcode" src="" alt="" style="width:100%"> <!-- <img ref="qrcode" src="" alt="" style="width:100%"> -->
<webview ref="qrcode" src="https://mp.weixin.qq.com" alt="" style="width:256px;height:256px">
</webview>
</div> </div>
</div> </div>
...@@ -117,6 +119,19 @@ export default { ...@@ -117,6 +119,19 @@ export default {
} }
this.mp = new MyMp(this.mp_info.usr, this.mp_info.pwd, this.$refs.qrcode) 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() { created() {
}, },
...@@ -126,9 +141,14 @@ export default { ...@@ -126,9 +141,14 @@ export default {
// my_open_cmd(cmd, {'cwd': 'D:/_ALL/CODE/gitee/constellations/Capricorn/WeChat/my_cmd'}) // my_open_cmd(cmd, {'cwd': 'D:/_ALL/CODE/gitee/constellations/Capricorn/WeChat/my_cmd'})
console.log(cmd, wx) console.log(cmd, wx)
}, },
mp_lg() { async mp_lg() {
// this.mp.checklogin(); try {
this.mp.login(this.mp_info.usr, this.mp_info.pwd) 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() {}, mp_open() {},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册