-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 56dea07
Showing
13 changed files
with
7,349 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
这是一个vite+Electron+vue3+ts的脚手架模板. | ||
======= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/render/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "my-vite-electron-app", | ||
"version": "0.0.8", | ||
"main": "./src/main.js", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"serve": "vite preview", | ||
"start": "electron-forge start", | ||
"package": "electron-forge package", | ||
"make": "electron-forge make" | ||
}, | ||
"dependencies": { | ||
"electron-fetch": "^1.7.3", | ||
"electron-prebuilt-compile": "^8.2.0", | ||
"fs-extra": "^9.1.0", | ||
"vue": "^3.0.5" | ||
}, | ||
"devDependencies": { | ||
"@electron-forge/cli": "^6.0.0-beta.54", | ||
"@electron-forge/maker-zip": "^6.0.0-beta.54", | ||
"@vitejs/plugin-vue": "^1.1.4", | ||
"@vue/compiler-sfc": "^3.0.5", | ||
"@vuedx/typecheck": "^0.6.0", | ||
"@vuedx/typescript-plugin-vue": "^0.6.0", | ||
"electron": "^11.2.3", | ||
"electron-squirrel-startup": "^1.0.0", | ||
"typescript": "^4.1.3", | ||
"vite": "^2.0.0", | ||
"vue": "^3.0.5" | ||
}, | ||
"config": { | ||
"forge": { | ||
"packagerConfig": { | ||
"ignore": [ | ||
"src/(render)", | ||
"userData", | ||
"(\\.vscode)", | ||
"node_modules/(@.+|\\..+)" | ||
], | ||
"name": "my-vite-electron-app" | ||
}, | ||
"makers": [ | ||
{ | ||
"name": "@electron-forge/maker-zip", | ||
"platforms": [ | ||
"win32" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const { app, BrowserWindow } = require("electron"); | ||
|
||
const isDev = !app.isPackaged; | ||
let win = null; | ||
|
||
function createWindow() { | ||
win = new BrowserWindow({ | ||
width: 888, | ||
height: 550, | ||
webPreferences: { | ||
nodeIntegration: true, | ||
}, | ||
}); | ||
win.setMenuBarVisibility(false); | ||
isDev | ||
? win.loadURL(`http://localhost:3000`) | ||
: win.loadFile("./dist/index.html"); | ||
} | ||
|
||
app.whenReady().then(createWindow); | ||
|
||
app.on("window-all-closed", () => { | ||
if (process.platform !== "darwin") { | ||
app.quit(); | ||
} | ||
}); | ||
|
||
app.on("activate", () => { | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow(); | ||
} | ||
}); | ||
|
||
const getWin = () => win; | ||
|
||
exports.getWin = getWin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<img alt="Vue logo" src="./assets/logo.png" /> | ||
<HelloWorld msg="Hello Vue 3 + TypeScript + Vite" /> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from "vue"; | ||
import HelloWorld from "./components/HelloWorld.vue"; | ||
|
||
export default defineComponent({ | ||
name: "App", | ||
components: { | ||
HelloWorld, | ||
}, | ||
}); | ||
</script> | ||
|
||
<style> | ||
#app { | ||
font-family: Avenir, Helvetica, Arial, sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
text-align: center; | ||
color: #2c3e50; | ||
margin-top: 60px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<template> | ||
<h1>{{ msg }}</h1> | ||
|
||
<label> | ||
<input type="checkbox" v-model="useScriptSetup" /> Use | ||
<code><script setup></code> | ||
</label> | ||
<label> | ||
<input type="checkbox" v-model="useTsPlugin" /> Provide types for | ||
<code>*.vue</code> imports | ||
</label> | ||
|
||
<p> | ||
Recommended IDE setup: | ||
<a href="https://code.visualstudio.com/" target="_blank">VSCode</a> | ||
+ | ||
<template v-if="!useScriptSetup"> | ||
<a | ||
href="https://marketplace.visualstudio.com/items?itemName=octref.vetur" | ||
target="_blank" | ||
>Vetur</a> | ||
+ | ||
<a | ||
href="https://marketplace.visualstudio.com/items?itemName=znck.vue-language-features" | ||
target="_blank" | ||
>Vue DX</a> | ||
</template> | ||
<template v-else> | ||
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a> | ||
</template> | ||
</p> | ||
<p v-if="useTsPlugin"> | ||
tsconfig setup: | ||
<br />1. Install and add | ||
<code>@vuedx/typescript-plugin-vue</code> to tsconfig plugins | ||
<br />2. Delete <code>src/shims-vue.d.ts</code> | ||
<br />3. Open | ||
<code>src/main.ts</code> in VSCode | ||
<br />4. Open VSCode command input | ||
<br />5. Search and run "Select TypeScript version" -> "Use workspace version" | ||
</p> | ||
<button @click="count++">count is: {{ count }}</button> | ||
<p> | ||
Edit | ||
<code>components/HelloWorld.vue</code> to test hot module replacement. | ||
</p> | ||
|
||
<p> | ||
<a href="https://vitejs.dev/guide/features.html" target="_blank">Vite Docs</a> | | ||
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a> | ||
</p> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { ref, defineComponent } from 'vue' | ||
export default defineComponent({ | ||
name: 'HelloWorld', | ||
props: { | ||
msg: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
setup: () => { | ||
const count = ref(0) | ||
const useScriptSetup = ref(false); | ||
const useTsPlugin = ref(false); | ||
return { count, useScriptSetup, useTsPlugin } | ||
} | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
a { | ||
color: #42b983; | ||
} | ||
|
||
label { | ||
margin: 0 0.5em; | ||
font-weight: bold; | ||
} | ||
|
||
code { | ||
background-color: #eee; | ||
padding: 2px 4px; | ||
border-radius: 4px; | ||
color: #304455; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
|
||
createApp(App).mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare module '*.vue' { | ||
import { DefineComponent } from 'vue' | ||
const component: DefineComponent<{}, {}, any> | ||
export default component | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"strict": true, | ||
"jsx": "preserve", | ||
"sourceMap": true, | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
"lib": ["esnext", "dom"], | ||
"types": ["vite/client"] | ||
}, | ||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from "vite"; | ||
import vue from "@vitejs/plugin-vue"; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [vue()], | ||
base: "./", | ||
optimizeDeps: {}, | ||
}); |
Oops, something went wrong.