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"
},
"dependencies": {
"vue": "^3.3.4",
"@tauri-apps/api": "^1"
"@tauri-apps/api": "^1",
"@unocss/reset": "^0.62.3",
"vue": "^3.4.38"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.5",
"typescript": "^5.2.2",
"vite": "^5.3.1",
"vue-tsc": "^2.0.22",
"@tauri-apps/cli": "^1"
"@tauri-apps/cli": "^1",
"@unocss/eslint-config": "^0.62.3",
"@vitejs/plugin-vue": "^5.1.3",
"eslint": "^9.9.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">
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
import Greet from "./components/Greet.vue";
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>
<div class="container">
<h1>Welcome to Tauri!</h1>
<div class="container text-center py-4">
<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">
<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 />
<p class="mt-4">{{ greetMsg }}</p>
</div>
</template>
<style scoped>
.logo.vite:hover {
filter: drop-shadow(0 0 2em #747bff);
}
.logo.vue:hover {
filter: drop-shadow(0 0 2em #249b73);
}
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
@ -51,45 +39,6 @@ import Greet from "./components/Greet.vue";
-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,
button {
border-radius: 8px;
@ -121,20 +70,12 @@ button {
outline: none;
}
#greet-input {
margin-right: 5px;
}
@media (prefers-color-scheme: dark) {
:root {
color: #f6f6f6;
background-color: #2f2f2f;
}
a:hover {
color: #24c8db;
}
input,
button {
color: #ffffff;
@ -144,5 +85,4 @@ button {
background-color: #0f0f0f69;
}
}
</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 App from "./App.vue";
import { createApp } from '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 vue from "@vitejs/plugin-vue";
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite'
// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [vue()],
plugins: [vue(), UnoCSS()],
// 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,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
}));
ignored: ['**/src-tauri/**']
}
}
}))