feat: 引入prettier来保证前端代码风格一致

This commit is contained in:
lanyeeee
2025-07-08 20:51:58 +08:00
parent 03632eb321
commit a5010edd98
7 changed files with 62 additions and 44 deletions

9
.prettierrc Normal file
View File

@@ -0,0 +1,9 @@
{
"printWidth": 120,
"tabWidth": 2,
"singleQuote": true,
"semi": false,
"bracketSameLine": true,
"endOfLine": "auto",
"htmlWhitespaceSensitivity": "ignore"
}

View File

@@ -10,15 +10,16 @@
"tauri": "tauri"
},
"dependencies": {
"vue": "^3.5.13",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2"
"@tauri-apps/plugin-opener": "^2",
"vue": "^3.5.13"
},
"devDependencies": {
"@tauri-apps/cli": "^2",
"@vitejs/plugin-vue": "^5.2.1",
"prettier": "3.6.2",
"typescript": "~5.6.2",
"vite": "^6.0.3",
"vue-tsc": "^2.1.10",
"@tauri-apps/cli": "^2"
"vue-tsc": "^2.1.10"
}
}

10
pnpm-lock.yaml generated
View File

@@ -24,6 +24,9 @@ importers:
'@vitejs/plugin-vue':
specifier: ^5.2.1
version: 5.2.4(vite@6.3.5)(vue@3.5.17(typescript@5.6.3))
prettier:
specifier: 3.6.2
version: 3.6.2
typescript:
specifier: ~5.6.2
version: 5.6.3
@@ -521,6 +524,11 @@ packages:
resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==}
engines: {node: ^10 || ^12 || >=14}
prettier@3.6.2:
resolution: {integrity: sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==}
engines: {node: '>=14'}
hasBin: true
rollup@4.44.2:
resolution: {integrity: sha512-PVoapzTwSEcelaWGth3uR66u7ZRo6qhPHc0f2uRO9fX6XDVNrIiGYS0Pj9+R8yIIYSD/mCx2b16Ws9itljKSPg==}
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
@@ -973,6 +981,8 @@ snapshots:
picocolors: 1.1.1
source-map-js: 1.2.1
prettier@3.6.2: {}
rollup@4.44.2:
dependencies:
'@types/estree': 1.0.8

View File

@@ -1,13 +1,13 @@
<script setup lang="ts">
import { ref } from "vue";
import { invoke } from "@tauri-apps/api/core";
import { ref } from 'vue'
import { invoke } from '@tauri-apps/api/core'
const greetMsg = ref("");
const name = ref("");
const greetMsg = ref('')
const name = ref('')
async function greet() {
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
greetMsg.value = await invoke("greet", { name: name.value });
greetMsg.value = await invoke('greet', { name: name.value })
}
</script>
@@ -44,7 +44,6 @@ async function greet() {
.logo.vue:hover {
filter: drop-shadow(0 0 2em #249b73);
}
</style>
<style>
:root {
@@ -156,5 +155,4 @@ button {
background-color: #0f0f0f69;
}
}
</style>
</style>

View File

@@ -1,4 +1,4 @@
import { createApp } from "vue";
import App from "./App.vue";
import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount("#app");
createApp(App).mount('#app')

8
src/vite-env.d.ts vendored
View File

@@ -1,7 +1,7 @@
/// <reference types="vite/client" />
declare module "*.vue" {
import type { DefineComponent } from "vue";
const component: DefineComponent<{}, {}, any>;
export default component;
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}

View File

@@ -1,32 +1,32 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST;
const host = process.env.TAURI_DEV_HOST
// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [vue()],
plugins: [vue()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 5005,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 5005,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: 'ws',
host,
port: 1421,
}
: undefined,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ['**/src-tauri/**'],
},
}));
},
}))