Skip to content

Commit

Permalink
🚀 💡 [修改代码] 更新wails到稳定版,优化应用启动效果,去除黑屏现象
Browse files Browse the repository at this point in the history
  • Loading branch information
alanchenchen committed Dec 2, 2022
1 parent f933579 commit 56a6e9a
Show file tree
Hide file tree
Showing 22 changed files with 578 additions and 919 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ build/bin

# fronted resources
frontend/node_modules
frontend/wailsjs
frontend/src/wailsjs
frontend/dist/index.html
frontend/dist/assets
frontend/dist/assets
frontend/package.json.md5
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> An application to count code in wails(golang)
> version: 2.0.0
> version: 2.0.1
> Author: Alan Chen
Expand Down Expand Up @@ -39,7 +39,7 @@
├─count code counter的主要go module
├─frontend wails展示的前端静态资源,wails不强关联前端框架和构建工具
│ ├─src
─wailsjs wails在加载静态资源时自动生成的方法bindings,见wails文档
─wailsjs wails在加载静态资源时自动生成的方法bindings,见wails文档
│ ├─index.html
│ ├─package.json
│ └─vite.config.js vite config配置
Expand All @@ -65,6 +65,10 @@
- wails读取前端静态资源的策略比较奇怪,所以不建议使用wails的frontend构建

#### Build
```bash
# 使用upx压缩打包
$ wails build --upx
```
- target是mac平台
- 本机必须是mac系统,可以同时编译amd64、arm64架构
- target是windows平台
Expand Down
1 change: 1 addition & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (a *App) startup(ctx context.Context) {
// domReady is called after the front-end dom has been loaded
func (a *App) domReady(ctx context.Context) {
// Add your action here
runtime.WindowShow(a.ctx)
}

// beforeClose is called when the application is about to quit,
Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "code-counter",
"version": "2.0.0",
"version": "2.0.1",
"author": "alanchenchen",
"private": true,
"scripts": {
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div id="app">
<div class="nav_bar">
<span data-wails-drag class="title">{{ title }}</span>
<span style="--wails-draggable:drag" class="title">{{ title }}</span>
<Icon
v-if="!isHome"
type="android-arrow-back"
Expand Down Expand Up @@ -46,7 +46,8 @@
</template>

<script>
import go from "./wailsjs/go";
import * as Native from "./wailsjs/go/main/App";
import { WindowMinimise } from "./wailsjs/runtime/runtime";
export default {
name: "App",
Expand Down Expand Up @@ -90,15 +91,15 @@ export default {
},
//最小化
minimize() {
window.runtime.WindowMinimise();
WindowMinimise();
},
//退出程序
exit() {
this.$Modal.confirm({
title: "提示",
content: "确定关闭程序吗?",
onOk: () => {
go.main.App.Quit();
Native.Quit();
},
});
},
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Vue.use(iView);
//路由跳转加入loadingbar全局提示
router.beforeEach((to, from, next) => {
iView.LoadingBar.start();
next()
next();
});

router.afterEach(route => {
iView.LoadingBar.finish()
iView.LoadingBar.finish();
});

new Vue({
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/AddFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
</template>

<script>
import go from "../wailsjs/go";
import * as Native from "../wailsjs/go/main/App";
import CModal from "@/components/CModal.vue";
import CItem from "@/components/CItem.vue";
Expand Down Expand Up @@ -147,7 +147,7 @@ export default {
// 添加文件夹路径
async addFileDir() {
try {
const res = await go.main.App.OpenDirectoryDialog({
const res = await Native.OpenDirectoryDialog({
Title: "选择需要计算代码行数的文件夹",
ShowHiddenFiles: false,
TreatPackagesAsDirectories: true,
Expand Down Expand Up @@ -236,7 +236,7 @@ export default {
const startTime = new Date().getTime();
const countTime = new Date().toLocaleString();
const res = await go.main.App.ReadCodeLinesByDirFiles(
const res = await Native.ReadCodeLinesByDirFiles(
fileDir,
exclude,
rule
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</template>

<script>
import { BrowserOpenURL } from "../wailsjs/runtime/runtime";
export default {
name: "Home",
Expand All @@ -25,7 +26,7 @@ export default {
this.$router.push("/addFile");
},
open(link) {
window.runtime.BrowserOpenURL(link);
BrowserOpenURL(link);
},
},
};
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/ShowResult.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</template>

<script>
import go from "../wailsjs/go";
import * as Native from "../wailsjs/go/main/App";
export default {
data() {
Expand Down Expand Up @@ -65,9 +65,9 @@ export default {
DefaultFilename: defaultName,
Filters: [{ DisplayName: "Text (*.txt)", Pattern: "*.txt" }],
};
const filename = await go.main.App.SaveFileDialog(options);
const filename = await Native.SaveFileDialog(options);
if (filename) {
await go.main.App.WriteFile(filename, str);
await Native.WriteFile(filename, str);
//任务栏窗口闪烁提示用户
// const currentWindow = this.$electron.remote.getCurrentWindow();
// currentWindow.flashFrame(true);
Expand Down
19 changes: 0 additions & 19 deletions frontend/src/wailsjs/go/bindings.d.ts

This file was deleted.

61 changes: 0 additions & 61 deletions frontend/src/wailsjs/go/bindings.js

This file was deleted.

Loading

0 comments on commit 56a6e9a

Please sign in to comment.