Skip to content

Commit

Permalink
♻️ refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
ileostar committed Jan 18, 2024
1 parent fb63e04 commit 081c2cf
Show file tree
Hide file tree
Showing 27 changed files with 669 additions and 368 deletions.
File renamed without changes.
7 changes: 7 additions & 0 deletions apps/web/locales/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## i18n

This directory is to serve your locale translation files. YAML under this folder would be loaded automatically and register with their filenames as locale code.

Check out [`vue-i18n`](https://github.com/intlify/vue-i18n-next) for more details.

If you are using VS Code, [`i18n Ally`](https://github.com/lokalise/i18n-ally) is recommended to make the i18n experience better.
14 changes: 14 additions & 0 deletions apps/web/locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
button:
about: About
back: Back
go: GO
home: Home
toggle_dark: Toggle dark mode
toggle_langs: Change languages
intro:
desc: Opinionated Vite Starter Template
dynamic-route: Demo of dynamic route
hi: Hi, {name}!
aka: Also known as
whats-your-name: What's your name?
not-found: Not found
14 changes: 14 additions & 0 deletions apps/web/locales/zh-CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
button:
about: 关于
back: 返回
go: 确定
home: 首页
toggle_dark: 切换深色模式
toggle_langs: 切换语言
intro:
desc: 固执己见的 Vite 项目模板
dynamic-route: 动态路由演示
hi: 你好,{name}
aka: 也叫
whats-your-name: 输入你的名字
not-found: 未找到页面
3 changes: 3 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"unocss-preset-daisy": "^7.0.0",
"unocss-preset-grid": "^1.4.2",
"vue": "^3.4.14",
"vue-i18n": "^9.8.0",
"vue-router": "^4.2.5"
},
"devDependencies": {
Expand All @@ -46,6 +47,7 @@
"@iconify-json/mdi": "^1.1.64",
"@iconify-json/streamline-emojis": "^1.1.8",
"@ileostar/eslint-config": "^0.3.0",
"@intlify/unplugin-vue-i18n": "^2.0.0",
"@types/node": "^20.11.3",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
Expand Down Expand Up @@ -84,6 +86,7 @@
"vite": "^5.0.11",
"vite-plugin-restart": "^0.4.0",
"vite-plugin-vue-devtools": "1.0.0-rc.5",
"vite-plugin-vue-layouts": "^0.11.0",
"vitest": "^1.2.0",
"vue-tsc": "^1.8.27",
"vue3-lottie": "^3.2.0"
Expand Down
4 changes: 1 addition & 3 deletions apps/web/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<template>
<main font-sans text="center gray-700 dark:gray-200" relative m-0 h-full w-full>
<RouterView />
</main>
<RouterView />
</template>
97 changes: 16 additions & 81 deletions apps/web/src/components/AuthBox.vue
Original file line number Diff line number Diff line change
@@ -1,94 +1,29 @@
<script setup>
import 'css-doodle';
import { Vue3Lottie } from 'vue3-lottie'
import LogoJSON from '@/assets/lottie/logo.json'
import AuthPlantJSON from '@/assets/lottie/login.json'
const doodle = document.querySelector('css-doodle');
document.addEventListener('click', function(e) {
doodle.update();
});
</script>

<template>
<div class="auth-box" m-0 relative justify-center items-center w-full h-full overflow-hidden>
<div class="auth-box__content" flex w-2xl h-110 rd-8 bg="gray/30" p-5 opacity-90>
<aside class="lottie-anime" w-70 flex="~ col" overflow-hidden>
<h2 my-7 text-center font-bold color-white flex items-center>
<p w-20><Vue3Lottie :animationData="LogoJSON"/></p>
<p color-green-700><slot name="title"></slot></p>
</h2>
<div flex-1 >
<slot name="lottie"></slot>
</div>
</aside>
<div class="auth-item" flex="~ 1 col" opacity-80 rd-8 px-8>
<h2 my-2 mt-8 font-bold text-5 color-green-500 text-center>
<slot name="header"></slot>
</h2>
<div h-50>
<slot name="content"></slot>
</div>
</div>
<aside class="lottie-anime" w-70 flex="~ col" overflow-hidden>
<h2 my-7 text-center font-bold color-white flex items-center>
<p w-20><Vue3Lottie :animationData="LogoJSON"/></p>
<p color-green-700><slot name="title"></slot></p>
</h2>
<div flex-1 >
<slot name="lottie"></slot>
</div>
</aside>
<div class="auth-item" flex="~ 1 col" opacity-80 rd-8 px-8>
<h2 my-2 mt-8 font-bold text-5 color-green-500 text-center>
<slot name="header"></slot>
</h2>
<div h-50>
<slot name="content"></slot>
</div>
<css-doodle w-full>
:doodle {
@grid: 2x40 / 100vmin;
}
@place-cell: center;
width: @rand(60vmin, 100vmin);
height: @rand(60vmin, 100vmin);
transform: translate(@rand(-120%, 120%), @rand(-80%, 80%)) scale(@rand(.8, 2.8)) skew(@rand(45deg));
clip-path: polygon(
@r(0, 30%) @r(0, 50%),
@r(30%, 60%) @r(0%, 30%),
@r(60%, 100%) @r(0%, 50%),
@r(60%, 100%) @r(50%, 100%),
@r(30%, 60%) @r(60%, 100%),
@r(0, 30%) @r(60%, 100%)
);
background: @pick(#e6437d, #ebbf4d, #5ee463, #f8e645, #ffc107, #43f8bf, #e136eb, #f57c23, #32ed39);
opacity: @rand(.45, .65);
position: relative;
top: @rand(-80%, 80%);
left: @rand(-80%, 80%);
animation: colorChange @rand(6.1s, 26.1s) infinite @rand(-.5s, -2.5s) linear alternate;
@keyframes colorChange {
100% {
left: 0;
top: 0;
filter: hue-rotate(360deg);
}
}
</css-doodle>
</div>
</div>
</template>

<style scoped>
.auth-box::after {
content: "";
position: absolute;
top: -100%;
left: -100%;
right: -100%;
bottom: -100%;
backdrop-filter: blur(100px);
z-index: 1;
}
.auth-box__content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 24px;
color: #000;
z-index: 10;
backdrop-filter: blur(10px);
background-color: rgba(216, 227, 223, 0.6);
box-shadow: 6px 6px 20px 0px rgba(255, 255, 255, 0.4), inset -5px -5px 10px 0px rgba(145, 192, 255, 0.6), inset 0px 8px 8px 0px rgb(255, 255, 255);
}
.auth-item {
background: rgba(216, 227, 223, 0.6);
box-shadow: inset 9px 9px 18px rgba(177, 213, 200),
Expand Down
Empty file.
21 changes: 21 additions & 0 deletions apps/web/src/components/StateCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<div>
<dl>
<dt>State</dt>
<dd>
<div class="state-card">
<div class="state-card-content">
<div class="state-card-state">
<div class="state-card-state-icon">
<slot name="icons"></slot>
</div>
<div class="state-card-state-label">
<slot name="infos"></slot>
</div>
</div>
</div>
</div>
</dd>
</dl>
</div>
</template>
5 changes: 2 additions & 3 deletions apps/web/src/components/TheHeader.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<script setup>
import { Vue3Lottie } from 'vue3-lottie'
import LogoJSON from '@/assets/lottie/logo.json'
import config from '~/config/all.config'
</script>

<template>
<div w-full h-full flex items-center justify-between ml="-1.2">
<div flex items-center>
<p w-18><Vue3Lottie :animationData="LogoJSON"/></p>
<h1 font-bold color-green-800 text-4>植物监测系统</h1>
<h1 font-bold color-green-800 text-4>{{ config.web.projectName }}</h1>
</div>
<div pr-3 flex items-center gap-3>
<div class="flex-none">
Expand Down
17 changes: 17 additions & 0 deletions apps/web/src/layouts/404.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script setup lang="ts">
const router = useRouter()
</script>

<template>
<main p="x4 y10" text="center teal-700 dark:gray-200">
<div text-4xl>
<div i-carbon-warning inline-block />
</div>
<RouterView />
<div>
<button text-sm btn m="3 t8" @click="router.back()">
404
</button>
</div>
</main>
</template>
14 changes: 14 additions & 0 deletions apps/web/src/layouts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Layouts

Vue components in this dir are used as layouts.

By default, `default.vue` will be used unless an alternative is specified in the route meta.

With [`unplugin-vue-router`](https://github.com/posva/unplugin-vue-router) and [`vite-plugin-vue-layouts`](https://github.com/JohnCampionJr/vite-plugin-vue-layouts), you can specify the layout in the page's SFCs like this:

```vue
<route lang="yaml">
meta:
layout: home
</route>
```
74 changes: 74 additions & 0 deletions apps/web/src/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<script setup>
import 'css-doodle';
const doodle = document.querySelector('css-doodle');
document.addEventListener('click', function(e) {
doodle.update();
});
</script>

<template>
<main font-sans text="center gray-700 dark:gray-200" relative m-0 h-full w-full>
<div class="auth-box" m-0 relative justify-center items-center w-full h-full overflow-hidden>
<div class="auth-box__content" flex w-2xl h-110 rd-8 bg="gray/30" p-5 opacity-90>
<RouterView />
</div>
<css-doodle h-full w-full>
:doodle {
@grid: 2x40 / 100vmin;
}
@place-cell: center;
width: @rand(60vmin, 100vmin);
height: @rand(60vmin, 100vmin);
transform: translate(@rand(-120%, 120%), @rand(-80%, 80%)) scale(@rand(.8, 2.8)) skew(@rand(45deg));
clip-path: polygon(
@r(0, 30%) @r(0, 50%),
@r(30%, 60%) @r(0%, 30%),
@r(60%, 100%) @r(0%, 50%),
@r(60%, 100%) @r(50%, 100%),
@r(30%, 60%) @r(60%, 100%),
@r(0, 30%) @r(60%, 100%)
);
background: @pick(#e6437d, #ebbf4d, #5ee463, #f8e645, #ffc107, #43f8bf, #e136eb, #f57c23, #32ed39);
opacity: @rand(.45, .65);
position: relative;
top: @rand(-80%, 80%);
left: @rand(-80%, 80%);
animation: colorChange @rand(6.1s, 26.1s) infinite @rand(-.5s, -2.5s) linear alternate;
@keyframes colorChange {
100% {
left: 0;
top: 0;
filter: hue-rotate(360deg);
}
}
</css-doodle>
</div>
</main>
</template>

<style scoped>
.auth-box::after {
content: "";
position: absolute;
top: -100%;
left: -100%;
right: -100%;
bottom: -100%;
backdrop-filter: blur(100px);
z-index: 1;
}
.auth-box__content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 24px;
color: #000;
z-index: 10;
backdrop-filter: blur(10px);
background-color: rgba(216, 227, 223, 0.6);
box-shadow: 6px 6px 20px 0px rgba(255, 255, 255, 0.4), inset -5px -5px 10px 0px rgba(145, 192, 255, 0.6), inset 0px 8px 8px 0px rgb(255, 255, 255);
}
</style>
41 changes: 41 additions & 0 deletions apps/web/src/layouts/home.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<el-container class="index-main" h-full overflow-hidden>
<el-header>
<TheHeader/>
</el-header>
<el-container>
<el-aside px-2 flex items-center>
<SideMenu/>
</el-aside>
<el-main>
<RouterView/>
</el-main>
</el-container>
</el-container>
</template>

<style scoped>
.index-main {
backdrop-filter: blur(20px);
background: #CCDAED; /* fallback for old browsers */
background: -webkit-linear-gradient(180deg, rgba(237, 242, 224,.7), rgba(0, 201, 255,.7)); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(260deg, rgba(237, 242, 224,.9), rgba(211, 223, 223,.8), rgba(0, 201, 255,.4)); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.el-header {
padding: 0;
}
.el-aside {
width: auto;
}
.el-main {
backdrop-filter: blur(6px) saturate(170%);
-webkit-backdrop-filter: blur(6px) saturate(170%);
background-color: rgba(255,255,255,0.76);
border-top-left-radius: 1.5rem;
padding: 1rem;
border: 1px solid rgba(209, 213, 219, 0.3);
}
</style>
2 changes: 2 additions & 0 deletions apps/web/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createRouter, createWebHistory } from 'vue-router/auto'
import { setupLayouts } from 'virtual:generated-layouts'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import Vue3Lottie from 'vue3-lottie'
import OnuUI from 'onu-ui'
Expand All @@ -13,6 +14,7 @@ const app = createApp(App)

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
extendRoutes: (routes) => setupLayouts(routes),
})
store.use(piniaPluginPersistedstate)
app.use(Vue3Lottie, { name: 'LottieAnimation' })
Expand Down
10 changes: 6 additions & 4 deletions apps/web/src/pages/[...all].vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<template>
<div>
<div i-streamline-emojis-magnifying-glass-tilted-left inline-block text-4xl />
<p>
Not Found
</p>
not-found
</div>
</template>

<route lang="yaml">
meta:
layout: 404
</route>
Loading

0 comments on commit 081c2cf

Please sign in to comment.