main
Zaeyee 2024-08-30 10:41:43 +08:00
parent 8b4fdceb8f
commit 203881c5b2
8 changed files with 2345 additions and 119 deletions

View File

@ -0,0 +1,3 @@
import unocss from '@unocss/eslint-config/flat'
export default [unocss]

View File

@ -10,14 +10,18 @@
"tauri": "tauri" "tauri": "tauri"
}, },
"dependencies": { "dependencies": {
"vue": "^3.3.4", "@tauri-apps/api": "^1",
"@tauri-apps/api": "^1" "@unocss/reset": "^0.62.3",
"vue": "^3.4.38"
}, },
"devDependencies": { "devDependencies": {
"@vitejs/plugin-vue": "^5.0.5", "@tauri-apps/cli": "^1",
"typescript": "^5.2.2", "@unocss/eslint-config": "^0.62.3",
"vite": "^5.3.1", "@vitejs/plugin-vue": "^5.1.3",
"vue-tsc": "^2.0.22", "eslint": "^9.9.1",
"@tauri-apps/cli": "^1" "typescript": "^5.5.4",
"unocss": "^0.62.3",
"vite": "^5.4.2",
"vue-tsc": "^2.1.2"
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +1,28 @@
<script setup lang="ts"> <script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs import { ref } from 'vue'
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup import { invoke } from '@tauri-apps/api/tauri'
import Greet from "./components/Greet.vue";
const greetMsg = ref('')
const name = ref('')
async function greet() {
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
greetMsg.value = await invoke('greet', { name: name.value })
}
</script> </script>
<template> <template>
<div class="container"> <div class="container text-center py-4">
<h1>Welcome to Tauri!</h1> <form class="flex justify-center" @submit.prevent="greet">
<input v-model="name" placeholder="Enter a name..." />
<button type="submit" class="ml-2">Greet</button>
</form>
<div class="row"> <p class="mt-4">{{ greetMsg }}</p>
<a href="https://vitejs.dev" target="_blank">
<img src="/vite.svg" class="logo vite" alt="Vite logo" />
</a>
<a href="https://tauri.app" target="_blank">
<img src="/tauri.svg" class="logo tauri" alt="Tauri logo" />
</a>
<a href="https://vuejs.org/" target="_blank">
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
</a>
</div>
<p>Click on the Tauri, Vite, and Vue logos to learn more.</p>
<Greet />
</div> </div>
</template> </template>
<style scoped> <style scoped>
.logo.vite:hover {
filter: drop-shadow(0 0 2em #747bff);
}
.logo.vue:hover {
filter: drop-shadow(0 0 2em #249b73);
}
:root { :root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif; font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px; font-size: 16px;
@ -51,45 +39,6 @@ import Greet from "./components/Greet.vue";
-webkit-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;
} }
.container {
margin: 0;
padding-top: 10vh;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: 0.75s;
}
.logo.tauri:hover {
filter: drop-shadow(0 0 2em #24c8db);
}
.row {
display: flex;
justify-content: center;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
h1 {
text-align: center;
}
input, input,
button { button {
border-radius: 8px; border-radius: 8px;
@ -121,20 +70,12 @@ button {
outline: none; outline: none;
} }
#greet-input {
margin-right: 5px;
}
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
:root { :root {
color: #f6f6f6; color: #f6f6f6;
background-color: #2f2f2f; background-color: #2f2f2f;
} }
a:hover {
color: #24c8db;
}
input, input,
button { button {
color: #ffffff; color: #ffffff;
@ -144,5 +85,4 @@ button {
background-color: #0f0f0f69; background-color: #0f0f0f69;
} }
} }
</style> </style>

View File

@ -1,21 +0,0 @@
<script setup lang="ts">
import { ref } from "vue";
import { invoke } from "@tauri-apps/api/tauri";
const greetMsg = ref("");
const name = ref("");
async function greet() {
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
greetMsg.value = await invoke("greet", { name: name.value });
}
</script>
<template>
<form class="row" @submit.prevent="greet">
<input id="greet-input" v-model="name" placeholder="Enter a name..." />
<button type="submit">Greet</button>
</form>
<p>{{ greetMsg }}</p>
</template>

View File

@ -1,4 +1,7 @@
import { createApp } from "vue"; import { createApp } from 'vue'
import App from "./App.vue"; import App from './App.vue'
createApp(App).mount("#app"); import '@unocss/reset/tailwind.css'
import 'virtual:uno.css'
createApp(App).mount('#app')

23
uno.config.ts 100644
View File

@ -0,0 +1,23 @@
import { defineConfig, presetUno, presetIcons, transformerDirectives, transformerVariantGroup } from 'unocss'
export default defineConfig({
shortcuts: {},
theme: {
colors: {
primary: 'var(--c-primary)'
}
},
presets: [
presetUno(),
presetIcons({
prefix: '',
extraProperties: {
display: 'inline-block',
width: '1.125em',
height: '1.125em',
'vertical-align': 'middle'
}
})
],
transformers: [transformerDirectives(), transformerVariantGroup()]
})

View File

@ -1,9 +1,10 @@
import { defineConfig } from "vite"; import { defineConfig } from 'vite'
import vue from "@vitejs/plugin-vue"; import vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite'
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig(async () => ({ export default defineConfig(async () => ({
plugins: [vue()], plugins: [vue(), UnoCSS()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// //
@ -15,7 +16,7 @@ export default defineConfig(async () => ({
strictPort: true, strictPort: true,
watch: { watch: {
// 3. tell vite to ignore watching `src-tauri` // 3. tell vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"], ignored: ['**/src-tauri/**']
}, }
}, }
})); }))