Browse Source

fix: 修改readme

main
npmrun 4 months ago
parent
commit
b0a60b74cb
  1. 35
      README.md
  2. 2
      src/main/commands/TabsCommand.ts
  3. 12
      src/main/modules/tabs/index.ts

35
README.md

@ -1,34 +1,3 @@
# my-app ## Electron + Tabs + WebContentsView
An Electron application with Vue and TypeScript 尝试开发一个类edge的浏览器。
## Recommended IDE Setup
- [VSCode](https://code.visualstudio.com/) + [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) + [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin)
## Project Setup
### Install
```bash
$ pnpm install
```
### Development
```bash
$ pnpm dev
```
### Build
```bash
# For windows
$ pnpm build:win
# For macOS
$ pnpm build:mac
# For Linux
$ pnpm build:linux
```

2
src/main/commands/TabsCommand.ts

@ -11,7 +11,7 @@ class TabsCommand {
@inject(WindowManager) private _WindowManager: WindowManager, @inject(WindowManager) private _WindowManager: WindowManager,
) { ) {
this.listenerTabActive = this.listenerTabActive.bind(this) this.listenerTabActive = this.listenerTabActive.bind(this)
this._Tabs.events.addListener("tab-active", this.listenerTabActive) this._Tabs.events.addListener("update", this.listenerTabActive)
} }
reload() { reload() {

12
src/main/modules/tabs/index.ts

@ -29,24 +29,24 @@ class Tabs extends BaseClass {
tab.events.on("window-open", ev => { tab.events.on("window-open", ev => {
debug(ev) debug(ev)
this.add(ev.url, true, win) this.add(ev.url, true, win)
this.events.emit("tab-active") this.events.emit("update")
// tab.navigate(ev.url) // tab.navigate(ev.url)
}) })
tab.events.on("update", () => { tab.events.on("update", () => {
this.events.emit("tab-active") this.events.emit("update")
}) })
this._tabs.push(tab) this._tabs.push(tab)
if (active) { if (active) {
this.changeActive(this._tabs.length - 1) this.changeActive(this._tabs.length - 1)
} }
this.events.emit("tab-active") this.events.emit("update")
} }
changeActive(index: number) { changeActive(index: number) {
this._tabs.forEach((tab, i) => { this._tabs.forEach((tab, i) => {
tab.setActive(i === index) tab.setActive(i === index)
}) })
this.events.emit("tab-active", index) this.events.emit("update", index)
} }
openDevtool(index: number) { openDevtool(index: number) {
@ -73,7 +73,7 @@ class Tabs extends BaseClass {
this.changeActive(index - 1) this.changeActive(index - 1)
} }
this._tabs.splice(index, 1) this._tabs.splice(index, 1)
this.events.emit("tab-active") this.events.emit("update")
} }
removeAll(index: number[]) { removeAll(index: number[]) {
@ -87,7 +87,7 @@ class Tabs extends BaseClass {
this._tabs = this._tabs.filter(v => { this._tabs = this._tabs.filter(v => {
return !v.isDestory return !v.isDestory
}) })
this.events.emit("tab-active") this.events.emit("update")
} }
} }

Loading…
Cancel
Save