Skip to content

Commit

Permalink
fix resize not work
Browse files Browse the repository at this point in the history
  • Loading branch information
XuNeal committed Mar 23, 2021
1 parent c346403 commit 6ee68ed
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 55 deletions.
Binary file modified connector.dylib
Binary file not shown.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"release": "node .electron-vue/build.js && electron-builder"
},
"build": {
"afterSign": "build/notarize.js",
"productName": "imKey Manager",
"appId": "com.imkey.imkey-manager",
"copyright": "Copyright © 2020 imkey",
Expand Down
16 changes: 13 additions & 3 deletions src/api/ethereumdapp_imkey_web3.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ const fs = require('fs')

// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
console.log('file path: ', path.resolve(__dirname))
contextBridge.exposeInMainWorld(
'imKeyManager',
{
accounts: () => {
return ipcRenderer.sendSync('imkey-accounts')
},
callNativeApi: async (data) => {
console.log('call Native Api before ipcRender')
return await ipcRenderer.invoke('imkey-api', data)
}
}
Expand All @@ -41,7 +39,7 @@ const imkeyWeb3ProviderSrc =
: require('path').resolve(__dirname, 'imkey-web3-provider.js')

const scriptContent = fs.readFileSync(imkeyWeb3ProviderSrc, { encoding: 'utf-8' })
console.log(scriptContent)
// console.log(scriptContent)
// let pathToInjectScript = `file://${imkeyWeb3ProviderSrc}`

// window.accounts = store.accounts;
Expand All @@ -57,6 +55,18 @@ process.on('document-start', () => {
// document.documentElement.appendChild(script);
})

// process.on('document-start', () => {
// // var script = document.createElement("script");
// // script.type = "text/javascript";
// // script.src = "http://localhost:8000/main.imkey-web3-provider.js";
// // document.documentElement.appendChild(script);
// var script = document.createElement("script");
// script.type = "text/javascript";
// script.src = "http://localhost:8000/imkey-web3-provider.js";
// document.documentElement.appendChild(script);
// })


// document.addEventListener(
// "DOMContentLoaded",
// function() {
Expand Down
55 changes: 17 additions & 38 deletions src/api/imkey-web3-provider.js

Large diffs are not rendered by default.

34 changes: 23 additions & 11 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
Tray,
dialog,
crashReporter,
ipcRenderer
ipcRenderer,
screen
} from 'electron'
// 自动更新相关
import { autoUpdater } from 'electron-updater'
Expand Down Expand Up @@ -542,21 +543,31 @@ function createBrowserView (url, isClose) {
if (isClose) {
if (view) {
mainWindow.removeBrowserView(view)
view = null;
// view.destroy()
}

return
}

if (process.platform === 'win32') {
view.setBounds({ x: 300, y: 0, width: 1050, height: 700 })
} else if (process.platform === 'darwin') {
view.setBounds({ x: 300, y: 62, width: 1200, height: 758 })
} else {
view.setBounds({ x: 300, y: 0, width: 1140, height: 820 })

mainWindow.on('resized', resetBounds);

function resetBounds() {
let mainWindowBounds = mainWindow.getBounds()
if (process.platform === 'win32') {
view.setBounds({ x: 300, y: 0, width: 1050, height: 700 })
} else if (process.platform === 'darwin') {
view.setBounds({ x: 300, y: 62, width: mainWindowBounds.width - 300, height: mainWindowBounds.height -62 })
} else {
view.setBounds({ x: 300, y: 0, width: 1140, height: 820 })
}
}

view.setAutoResize({ width: true, height: true })
resetBounds();


// view.setAutoResize({ horizontal: true, vertical: true })
const options = {
userAgent:
'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19'
Expand Down Expand Up @@ -740,7 +751,7 @@ if (!gotTheLock) {
createWorkerWindow()
createTray()
autoUpdate()
// crashReport()
crashReport()
// protocalHandler()
initimKeyMessageHandler()
renderDeviceManagerHandler()
Expand All @@ -751,7 +762,7 @@ if (!gotTheLock) {

function initimKeyMessageHandler () {
ipcMain.handle('imkey-api', async (event, json) => {
console.log('receive imkey-api in mainnet')
console.log("receive imkey-api in mainnet");
return new Promise((resolve, reject) => {
try {
const rsp = api(json)
Expand All @@ -764,8 +775,9 @@ function initimKeyMessageHandler () {

ipcMain.on('imkey-accounts', (event, arg) => {
console.log(arg) // prints "ping"
event.returnValue = ['0xa6c82cf246f820f70d3c11b1b518b2d0eaca3258']
event.returnValue = ["0xa6c82cf246f820f70d3c11b1b518b2d0eaca3258"]
})

}

app.on('window-all-closed', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/views/dapp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ export default {
this.iconUrl = 'https://app.sushi.com/favicon.ico'
}
if (urlType === 'Uniswap') {
url = 'http://localhost:3000'
url = 'https://app.uniswap.org'
this.title = 'Uniswap'
this.iconUrl = 'https://app.uniswap.org/favicon.png'
}
Expand Down Expand Up @@ -756,7 +756,6 @@ export default {
}
.container2 {
position: relative;
top: -5px;
/* width: 120px;
margin: 100px auto; */
display: none;
Expand Down

0 comments on commit 6ee68ed

Please sign in to comment.