Skip to content

Commit c087959

Browse files
committed
feat: 完成登录注册基本界面
0 parents  commit c087959

31 files changed

+1091
-0
lines changed

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
# Build output
27+
dist-electron
28+
release

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["Vue.volar"]
3+
}

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Vue 3 + TypeScript + Vite
2+
3+
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
4+
5+
## Recommended IDE Setup
6+
7+
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
8+
9+
## Type Support For `.vue` Imports in TS
10+
11+
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
12+
13+
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
14+
15+
1. Disable the built-in TypeScript Extension
16+
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
17+
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
18+
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.

auto-imports.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* eslint-disable */
2+
/* prettier-ignore */
3+
// @ts-nocheck
4+
// noinspection JSUnusedGlobalSymbols
5+
// Generated by unplugin-auto-import
6+
// biome-ignore lint: disable
7+
export {}
8+
declare global {
9+
10+
}

components.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* eslint-disable */
2+
// @ts-nocheck
3+
// Generated by unplugin-vue-components
4+
// Read more: https://github.com/vuejs/core/pull/3399
5+
// biome-ignore lint: disable
6+
export {}
7+
8+
/* prettier-ignore */
9+
declare module 'vue' {
10+
export interface GlobalComponents {
11+
ElIcon: typeof import('element-plus/es')['ElIcon']
12+
ElLink: typeof import('element-plus/es')['ElLink']
13+
ElText: typeof import('element-plus/es')['ElText']
14+
RouterLink: typeof import('vue-router')['RouterLink']
15+
RouterView: typeof import('vue-router')['RouterView']
16+
}
17+
}

electron-builder.json5

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// @see - https://www.electron.build/configuration/configuration
2+
{
3+
"$schema": "https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json",
4+
"appId": "cn.programcx",
5+
"asar": true,
6+
"productName": "Flow Message",
7+
"directories": {
8+
"output": "release/${version}"
9+
},
10+
"files": [
11+
"dist",
12+
"dist-electron"
13+
],
14+
"mac": {
15+
"target": [
16+
"dmg"
17+
],
18+
"artifactName": "${productName}-Mac-${version}-Installer.${ext}",
19+
icon: "public/icon/icon.icns",
20+
},
21+
"win": {
22+
"target": [
23+
{
24+
"target": "nsis",
25+
"arch": [
26+
"x64"
27+
]
28+
}
29+
],
30+
"artifactName": "${productName}-Windows-${version}-Setup.${ext}",
31+
icon: "public/icon/icon.ico",
32+
},
33+
"nsis": {
34+
"oneClick": false,
35+
"perMachine": false,
36+
"allowToChangeInstallationDirectory": true,
37+
"deleteAppDataOnUninstall": false
38+
},
39+
"linux": {
40+
"target": [
41+
"AppImage"
42+
],
43+
"artifactName": "${productName}-Linux-${version}.${ext}"
44+
}
45+
}

electron/electron-env.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/// <reference types="vite-plugin-electron/electron-env" />
2+
3+
declare namespace NodeJS {
4+
interface ProcessEnv {
5+
/**
6+
* The built directory structure
7+
*
8+
* ```tree
9+
* ├─┬─┬ dist
10+
* │ │ └── index.html
11+
* │ │
12+
* │ ├─┬ dist-electron
13+
* │ │ ├── main.js
14+
* │ │ └── preload.js
15+
* │
16+
* ```
17+
*/
18+
APP_ROOT: string
19+
/** /dist/ or /public/ */
20+
VITE_PUBLIC: string
21+
}
22+
}
23+
24+
// Used in Renderer process, expose in `preload.ts`
25+
interface Window {
26+
ipcRenderer: import('electron').IpcRenderer
27+
}

electron/main.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { app, BrowserWindow, Menu, ipcMain } from 'electron'
2+
import { createRequire } from 'node:module'
3+
import { fileURLToPath } from 'node:url'
4+
import path from 'node:path'
5+
6+
const require = createRequire(import.meta.url)
7+
require;
8+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
9+
10+
// The built directory structure
11+
//
12+
// ├─┬─┬ dist
13+
// │ │ └── index.html
14+
// │ │
15+
// │ ├─┬ dist-electron
16+
// │ │ ├── main.js
17+
// │ │ └── preload.mjs
18+
// │
19+
process.env.APP_ROOT = path.join(__dirname, '..')
20+
21+
// 🚧 Use ['ENV_NAME'] avoid vite:define plugin - [email protected]
22+
export const VITE_DEV_SERVER_URL = process.env['VITE_DEV_SERVER_URL']
23+
export const MAIN_DIST = path.join(process.env.APP_ROOT, 'dist-electron')
24+
export const RENDERER_DIST = path.join(process.env.APP_ROOT, 'dist')
25+
26+
process.env.VITE_PUBLIC = VITE_DEV_SERVER_URL ? path.join(process.env.APP_ROOT, 'public') : RENDERER_DIST
27+
28+
let win: BrowserWindow | null
29+
30+
function createWindow() {
31+
Menu.setApplicationMenu(null) ; // Hide menu bar
32+
win = new BrowserWindow({
33+
icon: path.join(process.env.VITE_PUBLIC, 'icons/icon.ico'),
34+
webPreferences: {
35+
preload: path.join(__dirname, 'preload.mjs'),
36+
},
37+
frame: true,
38+
})
39+
40+
// Test active push message to Renderer-process.
41+
win.webContents.on('did-finish-load', () => {
42+
win?.webContents.send('main-process-message', (new Date).toLocaleString())
43+
})
44+
45+
if (VITE_DEV_SERVER_URL) {
46+
win.loadURL(VITE_DEV_SERVER_URL)
47+
win.webContents.openDevTools()
48+
} else {
49+
// win.loadFile('dist/index.html')
50+
win.loadFile(path.join(RENDERER_DIST, 'index.html'))
51+
}
52+
53+
ipcMain.on('resize-window', (event, width:number, height:number) => {
54+
if (win) {
55+
win.setSize(width, height)
56+
}
57+
});
58+
59+
ipcMain.on('set-window-frame-visible', (event, isFrameVisible:boolean) => {
60+
if (win) {
61+
win.setMenuBarVisibility(isFrameVisible)
62+
win.setResizable(isFrameVisible)
63+
}
64+
});
65+
ipcMain.on('set-window-title', (event, title:string) => {
66+
if (win) {
67+
win.setTitle(title)
68+
}
69+
});
70+
71+
}
72+
73+
// Quit when all windows are closed, except on macOS. There, it's common
74+
// for applications and their menu bar to stay active until the user quits
75+
// explicitly with Cmd + Q.
76+
app.on('window-all-closed', () => {
77+
if (process.platform !== 'darwin') {
78+
app.quit()
79+
win = null
80+
}
81+
})
82+
83+
app.on('activate', () => {
84+
// On OS X it's common to re-create a window in the app when the
85+
// dock icon is clicked and there are no other windows open.
86+
if (BrowserWindow.getAllWindows().length === 0) {
87+
createWindow()
88+
}
89+
})
90+
91+
app.whenReady().then(createWindow)

electron/preload.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { ipcRenderer, contextBridge } from 'electron';
2+
3+
// --------- Expose some API to the Renderer process ---------
4+
contextBridge.exposeInMainWorld('electron', {
5+
// Resize the window
6+
resizeWindow: (width: number, height: number) => ipcRenderer.send('resize-window', width, height),
7+
8+
// Control window frame visibility
9+
setWindowFrameVisible: (visible: boolean) => ipcRenderer.send('set-window-frame-visible', visible),
10+
11+
// Set window title
12+
setWindowTitle: (title: string) => ipcRenderer.send('set-window-title', title),
13+
14+
// Other IPC APIs
15+
on(...args: Parameters<typeof ipcRenderer.on>) {
16+
const [channel, listener] = args;
17+
return ipcRenderer.on(channel, (event, ...args) => listener(event, ...args));
18+
},
19+
off(...args: Parameters<typeof ipcRenderer.off>) {
20+
const [channel, ...omit] = args;
21+
return ipcRenderer.off(channel, ...omit);
22+
},
23+
send(...args: Parameters<typeof ipcRenderer.send>) {
24+
const [channel, ...omit] = args;
25+
return ipcRenderer.send(channel, ...omit);
26+
},
27+
invoke(...args: Parameters<typeof ipcRenderer.invoke>) {
28+
const [channel, ...omit] = args;
29+
return ipcRenderer.invoke(channel, ...omit);
30+
},
31+
});

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en" >
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>FlowMessage</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.ts"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)