提交 c064e68a 编写于 作者: N ninecents

webview 应用

上级 097121bf
......@@ -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",
......
......@@ -23,7 +23,8 @@ function createWindow(): void {
nodeIntegration: true,
webSecurity: false,
allowRunningInsecureContent: true,
contextIsolation: false
contextIsolation: false,
webviewTag: true
}
})
......
......@@ -226,6 +226,7 @@ class MyMp {
// }
// }
});
return;
}
// 3. 直接reject拒绝
......
......@@ -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];
......
......@@ -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
......
......@@ -57,12 +57,12 @@
</el-row>
<el-row :gutter="10">
<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 :span="6">
</el-col>
<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-row>
<br>
......@@ -70,7 +70,9 @@
<!-- 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>
......@@ -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() {},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册