Skip to content

Commit

Permalink
create new branch of feature/electron
Browse files Browse the repository at this point in the history
  • Loading branch information
wbh1328551759 committed Mar 1, 2021
1 parent c7fb79c commit 7814184
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 819 deletions.
38 changes: 3 additions & 35 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
on:
push:
branches:
- v2.0.10
- feature/electron
pull_request:
branches:
- v2.0.10
- feature/electron
jobs:
release-windows:
runs-on: windows-latest
Expand All @@ -24,44 +24,12 @@ jobs:

- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
env:
BRANCH: v2.0.10
with:
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.github_token }}
build_script_name: packElectron:win
build_script_name: releaseElectron:win

# If the commit is tagged with a version (e.g. "v1.0.0"),
# release the app after building
release: ${{ startsWith(github.ref, 'refs/tags/v') }}

# release-mac:
# runs-on: ${{ matrix.os }}
#
# strategy:
# matrix:
# os: macos-latest
#
# steps:
# - name: Check out Git repository
# uses: actions/checkout@v1
#
# - name: Install Node.js, NPM and Yarn
# uses: actions/setup-node@v1
# with:
# node-version: 10
#
# - name: Build/release Electron app
# uses: samuelmeuli/action-electron-builder@v1
# env:
# BRANCH: v2.0.10
# with:
# # GitHub token, automatically provided to the action
# # (No need to define this secret in the repo settings)
# github_token: ${{ secrets.github_token }}
# build_script_name: packElectron:mac
#
# # If the commit is tagged with a version (e.g. "v1.0.0"),
# # release the app after building
# release: ${{ startsWith(github.ref, 'refs/tags/v') }}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "packages/apps-electron/build/electron.js",
"description": "An Apps portal into the Polkadot network",
"author": "chainx-org",
"version": "2.1.4",
"version": "2.1.5",
"license": "Apache-2",
"private": true,
"homepage": ".",
Expand Down Expand Up @@ -43,7 +43,8 @@
"build:electronMain": "cd packages/apps-electron && NODE_ENV=production webpack --config webpack.main.config.js",
"packElectron:test": "yarn build:release:electron && electron-builder --dir",
"packElectron:mac": "yarn build:release:electron && electron-builder build --mac",
"packElectron:win": "yarn build:release:electron && yarn clean:electronRelease && electron-builder build --win -p always",
"packElectron:win": "yarn build:release:electron && electron-builder build --win",
"releaseElectron:win": "yarn build:release:electron && yarn clean:electronRelease && electron-builder build --win -p always",
"packElectron:linux": "yarn build:release:electron && electron-builder build --linux",
"packElectron": "yarn build:release:electron && yarn clean:electronRelease && electron-builder build -mwl",
"docs": "echo \"skipping docs\"",
Expand Down
50 changes: 27 additions & 23 deletions packages/apps-electron/src/electron/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,33 @@ export function createWindow(environment: string): Promise<unknown> {


async function getRelease() {
const {data} = await axios.get('https://api.github.com/repos/chainx-org/chainx-dapp-wallet-v2/releases/latest');
const fileNameList: string[] = await data.assets.map((file: any) => file.name);
const fileNameToDownload: string | string[] = await fileNameList.filter((fileName: string) => (fileName.indexOf('.exe') !== -1 || fileName.indexOf('.dmg') !== -1) && fileName.indexOf('.blockmap') === -1);
const filesToDownload = await data.assets.filter((file: any) => file.name === fileNameToDownload[0] || file.name === fileNameToDownload[1]);
const latestVersion = data.tag_name.slice(1)
const fileOfWin = filesToDownload.find((file: any) => file.name.indexOf('.exe') !== -1)
const fileOfMac = filesToDownload.find((file: any) => file.name.indexOf('.dmg') !== -1)

if (packageJson.version !== latestVersion) {

require('electron')
.dialog
.showMessageBox(win, {
title: '温馨提示',
message: `您访问的版本不是最新版本哦,如果可以,请使用我们的最新版本,点击下方按钮进入下载页面:`,
buttons: ['mac 下载入口', 'windows 下载入口']
}).then((index) => {
if (index.response === 0) {
shell.openExternal(fileOfWin.browser_download_url);
} else if (index.response === 1) {
shell.openExternal(fileOfMac.browser_download_url);
}
});
try{
const {data} = await axios.get('https://api.github.com/repos/chainx-org/chainx-dapp-wallet-v2/releases/latest');
const fileNameList: string[] = await data.assets.map((file: any) => file.name);
const fileNameToDownload: string | string[] = await fileNameList.filter((fileName: string) => (fileName.indexOf('.exe') !== -1 || fileName.indexOf('.dmg') !== -1) && fileName.indexOf('.blockmap') === -1);
const filesToDownload = await data.assets.filter((file: any) => file.name === fileNameToDownload[0] || file.name === fileNameToDownload[1]);
const latestVersion = data.tag_name.slice(1)
const fileOfWin = filesToDownload.find((file: any) => file.name.indexOf('.exe') !== -1)
const fileOfMac = filesToDownload.find((file: any) => file.name.indexOf('.dmg') !== -1)

if (packageJson.version !== latestVersion) {

require('electron')
.dialog
.showMessageBox(win, {
title: '温馨提示',
message: `您访问的版本不是最新版本哦,如果可以,请使用我们的最新版本,点击下方按钮进入下载页面:`,
buttons: ['mac 下载入口', 'windows 下载入口']
}).then((index) => {
if (index.response === 0) {
shell.openExternal(fileOfWin.browser_download_url);
} else if (index.response === 1) {
shell.openExternal(fileOfMac.browser_download_url);
}
});
}
}catch (err) {
console.log(err)
}
}

Expand Down
4 changes: 4 additions & 0 deletions packages/apps/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,10 @@
"Chinese Node": "中国节点",
"Overseas Node": "海外节点",
"Test Node": "测试节点",
"Prompt": "温馨提示",
"The version you are visiting is not the latest version. If you can, please use our latest version and click the button below to enter the download page:": "您访问的版本不是最新版本哦,如果可以,请使用我们的最新版本,点击下方按钮进入下载页面:",
"Download entry of mac": "mac 下载入口",
"Download entry of windows": "windows 下载入口",
"{{balance}} voted": "{{balance}} 投票",
"{{blocks}} blocks": "{{blocks}} 区块",
"{{count}} key/value pairs encoded for submission": "{{count}}为提交而编码的密钥/值对",
Expand Down
Loading

0 comments on commit 7814184

Please sign in to comment.