Skip to content

Commit

Permalink
添加了.eslintignore文件,更新了.sonner.client.ts文件,更新了auto-imports.d.ts文件,更新了.…
Browse files Browse the repository at this point in the history
…vscode/settings.json文件,更新了components.d.ts文件,更新了.vscode/extensions.json文件,添加了naiveui.ts文件,更新了assets/css/main.css文件,更新了app.vue文件。
  • Loading branch information
tymon42 committed Mar 29, 2024
1 parent e74da1c commit eedd681
Show file tree
Hide file tree
Showing 16 changed files with 11,231 additions and 10,188 deletions.
12 changes: 12 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules/
.backup/
.nuxt/
.output/
dist/
build/
public/

script/*

tsconfig.json
.gitignore
12 changes: 9 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{
"recommendations": [
"vue.volar",
"vue.vscode-typescript-vue-plugin",
"willjleong.nuxt-typescript-snippets",
"allanoricil.nuxt-vscode-extension",
"dbaeumer.vscode-eslint",
"redjue.git-commit-plugin",
"seatonjiang.gitmoji-vscode",
"eamodio.gitlens"
"eamodio.gitlens",
"bradlc.vscode-tailwindcss",
"standard.vscode-standard",
"stylelint.vscode-stylelint",
"mohsen1.prettify-json",
"xabikos.javascriptsnippets",
"heybourn.headwind",
"steoates.autoimport",
"antfu.iconify"
],
}
13 changes: 8 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"nuxt.isNuxtApp": true,
"prettier.enable": false,
"editor.formatOnSave": false,
"eslint.enable": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
"source.fixAll": "explicit",
"source.fixAll.eslint": "always",
"source.organizeImports": "always"
},
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 5000,
"prettier.enable": false,
}
29 changes: 21 additions & 8 deletions app.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script setup lang="ts">
import { Toaster } from 'vue-sonner'
import { Toaster } from 'vue-sonner';
import { darkTheme } from 'naive-ui';
const colorMode = useColorMode()
Expand All @@ -9,23 +11,34 @@ const themeString = computed(() => {
return colorMode.preference === 'dark' ? 'dark' : 'light'
})
const themeForNaive = computed(() => {
if (colorMode.preference === 'system')
return undefined
return colorMode.preference === 'dark' ? darkTheme : undefined
})
</script>

<template>
<NuxtLayout>
<NuxtPage />
<UNotifications class="z-50" />
<ClientOnly>
<Toaster class="z-50" position="top-left" :theme="themeString" rich-colors close-button :visible-toasts="5" />
</ClientOnly>
</NuxtLayout>
<NConfigProvider :theme="themeForNaive">
<NuxtLoadingIndicator />
<NuxtLayout>
<NuxtPage />
<UNotifications class="z-50" />
<ClientOnly>
<Toaster class="z-50" position="top-left" :theme="themeString" rich-colors close-button :visible-toasts="5" />
</ClientOnly>
</NuxtLayout>
</NConfigProvider>
</template>

<style>
body {
background-color: #fff;
color: #000;
}
.dark-mode body {
background-color: #000;
color: #fff;
Expand Down
54 changes: 53 additions & 1 deletion assets/css/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@tailwind utilities;

@layer components {
.line-tight {
@apply leading-tight;
}

.line-snug {
@apply leading-snug;
}

.line-normal {
@apply leading-normal;
}

.line-relaxed {
@apply leading-relaxed;
}

.line-loose {
@apply leading-loose;
}

.navbar {
@apply flex items-center m-0 display min-h-12 w-full
}

}

@layer utilities {
.no-scrollbar::-webkit-scrollbar {
/* Hide scrollbar for Chrome, Safari and Opera */
display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
-ms-overflow-style: none;
/* IE and Edge */
scrollbar-width: none;
/* Firefox */
}
}

body {
background-color: #fff;
color: rgba(0, 0, 0);
}

.dark body {
background-color: #000;
color: #ebf4f1;
}
7 changes: 6 additions & 1 deletion auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
export { }
declare global {
const Toaster: typeof import('toast')['Toaster']
const toast: typeof import('vue-sonner')['toast']
const useDialog: typeof import('naive-ui')['useDialog']
const useLoadingBar: typeof import('naive-ui')['useLoadingBar']
const useMessage: typeof import('naive-ui')['useMessage']
const useNotification: typeof import('naive-ui')['useNotification']
}
7 changes: 7 additions & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export {}

declare module 'vue' {
export interface GlobalComponents {
NCollapse: typeof import('naive-ui')['NCollapse']
NCollapseItem: typeof import('naive-ui')['NCollapseItem']
NColorPicker: typeof import('naive-ui')['NColorPicker']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDatePicker: typeof import('naive-ui')['NDatePicker']
NNumberAnimation: typeof import('naive-ui')['NNumberAnimation']
NQrCode: typeof import('naive-ui')['NQrCode']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}
Expand Down
29 changes: 10 additions & 19 deletions components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ const toast = useToast()

<template>
<UContainer>

<div class="sm:text-center">
<UAvatar
size="3xl"
<UAvatar size="3xl"
src="https://avatars.githubusercontent.com/u/15265627?s=400&u=d2d9280bdbc5b88bd3573702e5be258dc3c61c2a&v=4"
alt="Harry Wong" chip-color="primary" chip-position="top-right"
/>
alt="Harry Wong" chip-color="primary" chip-position="top-right" />
<br>
<ThemeSwitch />
<UBadge size="lg">
Fast
</UBadge>
Expand Down Expand Up @@ -80,23 +80,14 @@ const toast = useToast()
</UDropdown>
<br>
<br>
<UInput
name="input1"
loading icon="i-heroicons-magnifying-glass-20-solid" size="xl" color="primary" variant="outline"
placeholder="Search..."
/>
<UInput
name="input2"
icon="i-heroicons-magnifying-glass-20-solid" size="xl" color="primary" variant="outline"
placeholder="Search..."
/>
<UInput name="input1" loading icon="i-heroicons-magnifying-glass-20-solid" size="xl" color="primary"
variant="outline" placeholder="Search..." />
<UInput name="input2" icon="i-heroicons-magnifying-glass-20-solid" size="xl" color="primary" variant="outline"
placeholder="Search..." />
<br>
<UTextarea name="textarea" color="primary" variant="outline" placeholder="Textarea" />
<USelect
name="select"
size="sm" color="primary" variant="outline" placeholder="Select"
:options="['United States', 'Canada', 'Mexico']"
/>
<USelect name="select" size="sm" color="primary" variant="outline" placeholder="Select"
:options="['United States', 'Canada', 'Mexico']" />

<USelectMenu v-model="selected" :options="people" />
<br>
Expand Down
61 changes: 37 additions & 24 deletions components/ThemeSwitch.vue
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
<script setup lang="ts">
type Theme = 'light' | 'dark' | 'system'
const colorTheme: Ref<Theme> = ref('system')
import { themeChange } from 'theme-change';
function setColorTheme() {
if (colorTheme.value === 'system')
colorTheme.value = 'light'
else if (colorTheme.value === 'light')
colorTheme.value = 'dark'
else if (colorTheme.value === 'dark')
colorTheme.value = 'system'
const colorMode = useColorMode()
const themes = [
{
icon: 'i-heroicons-computer-desktop',
theme: 'system',
}, {
icon: 'i-heroicons-sun',
theme: 'light',
}, {
icon: 'i-heroicons-moon',
theme: 'dark',
},
]
useColorMode().preference = colorTheme.value
const currentThemeIcon = computed(() => {
return themes.find((item) => item.theme === colorMode.preference)?.icon
})
function setTheme(name: string) {
colorMode.preference = name
}
onMounted(() => {
themeChange(false)
})
</script>

<template>
<UButton v-if="colorTheme === 'dark'" color="gray" icon="i-heroicons-moon" variant="ghost" @click="setColorTheme()" />
<UButton v-if="colorTheme === 'light'" color="gray" icon="i-heroicons-sun" variant="ghost" @click="setColorTheme()" />
<UButton v-if="colorTheme === 'system'" color="gray" icon="i-heroicons-computer-desktop" variant="ghost" @click="setColorTheme()" />
<div class="dropdown dropdown-end">
<button tabindex="0" class="btn btn-sm btn-ghost">
<UIcon class="w-6 h-6" :name="currentThemeIcon" dynamic />
</button>
<ul tabindex="0" class="dropdown-content z-[1] menu p-1 shadow bg-base-100 rounded-box min-w-max space-y-1">
<li v-for="item of themes" :key="item.theme">
<button class="btn btn-sm min-w-max" @click="setTheme(item.theme)">
<UIcon class="w-6 h-6" :name="item.icon" />
<!-- {{ item.icon }} {{ item.theme }} -->
</button>
</li>
</ul>
</div>
</template>

<style>
body {
background-color: #fafafa;
color: #000000;
}
.dark body {
background-color: #000000;
color: #fafafa;
}
</style>
21 changes: 14 additions & 7 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: {
enabled: true,

timeline: {
enabled: true,
},
},
build: {
// transpile: ['vue-sonner'],
Expand All @@ -32,8 +36,7 @@ export default defineNuxtConfig({
}),
],
},

modules: ['@nuxt/ui', '@vueuse/nuxt', '@nuxtjs/color-mode'],
modules: ['@nuxt/ui', '@vueuse/nuxt', '@nuxtjs/color-mode', '@pinia/nuxt', '@pinia-plugin-persistedstate/nuxt', '@formkit/auto-animate/nuxt'],
colorMode: {
classSuffix: '',
preference: 'system', // default theme
Expand All @@ -54,9 +57,9 @@ export default defineNuxtConfig({
},
},
routeRules: {
'/api/v1/**': {
// proxy: { to: 'http://localhost:8888/api/v1/**' },
proxy: { to: `${process.env.BASE_URL}/api/v1/**` },
'/request/api/**': {
proxy: { to: `${process.env.BASE_URL}/api/**` },
// proxy: { to: 'http://127.0.0.1:4523/m1/3732090-0-default/api/**' },
},
},
app: {
Expand All @@ -66,4 +69,8 @@ export default defineNuxtConfig({
],
},
},
})
ignore: [
'**/*.test.*',
'**/script/**',
],
})
Loading

0 comments on commit eedd681

Please sign in to comment.