From 6ba07440a70b8c46d3fe61fa881f26d4c8d81083 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 31 May 2024 15:22:53 +0800 Subject: [PATCH] chore: +tailwindcss --- package.json | 7 ++++++- postcss.config.js | 6 ++++++ src/assets/global.css | 8 ++++++-- src/config.js | 1 + src/i18n/LanguageSwitcher.jsx | 2 +- src/views/App.jsx | 6 +++++- tailwind.config.js | 19 +++++++++++++++++++ vite.config.js | 11 ++++++++++- 8 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 postcss.config.js create mode 100644 tailwind.config.js diff --git a/package.json b/package.json index ebe26db..4b32e18 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,11 @@ "@types/react-dom": "^18.0.11", "@vitejs/plugin-legacy": "^4.0.2", "@vitejs/plugin-react": "^3.1.0", - "vite": "^4.2.0" + "autoprefixer": "^10.4.19", + "postcss": "^8.4.38", + "tailwindcss": "^3.4.3", + "vite": "^4.2.0", + "vite-plugin-windicss": "^1.9.3", + "windicss": "^3.5.6" } } diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/src/assets/global.css b/src/assets/global.css index c668291..ca0ad13 100644 --- a/src/assets/global.css +++ b/src/assets/global.css @@ -1,3 +1,7 @@ +@import 'tailwindcss/base'; +@import 'tailwindcss/components'; +@import 'tailwindcss/utilities'; + .logo { float: left; height: 36px; @@ -5,7 +9,7 @@ background: rgba(255, 255, 255, 0.3); } -.reservation-highlight { +.reservation-highlight { color: rgba(255, 255, 255, 1); background-color: rgba(255, 0, 0, 0.6); } @@ -16,4 +20,4 @@ align-items: center; justify-content: center; width: 100%; -} \ No newline at end of file +} diff --git a/src/config.js b/src/config.js index 930f853..ef4330a 100644 --- a/src/config.js +++ b/src/config.js @@ -38,3 +38,4 @@ export const DATE_PRESETS = [ // 去年: [dayjs().subtract(1, "year").startOf("year"), moment().subtract(1, "year").endOf("year")], ]; export const arrManager = ["testzp","testzac","testycc","testlyj","testqqs","testjjh","testhn"];//特定账号加修改所属供应商的菜单 zp +export const BUILD_VERSION = process.env.NODE_ENV === 'production' ? __BUILD_VERSION__ : process.env.NODE_ENV; diff --git a/src/i18n/LanguageSwitcher.jsx b/src/i18n/LanguageSwitcher.jsx index f2ac02d..ac1f009 100644 --- a/src/i18n/LanguageSwitcher.jsx +++ b/src/i18n/LanguageSwitcher.jsx @@ -19,7 +19,7 @@ const Language = () => { /* 🌏🌐 */ return ( -
🌐{t(`lang.${i18n.language}`)}
+
🌐{t(`lang.${i18n.language}`)}
); }; diff --git a/src/views/App.jsx b/src/views/App.jsx index d944c87..93665b4 100644 --- a/src/views/App.jsx +++ b/src/views/App.jsx @@ -14,6 +14,7 @@ import { useTranslation } from 'react-i18next'; import zhLocale from 'antd/locale/zh_CN'; import enLocale from 'antd/locale/en_US'; import 'dayjs/locale/zh-cn'; +import { BUILD_VERSION, } from '@/config'; const { Header, Content, Footer } = Layout; const { Title } = Typography; @@ -193,7 +194,10 @@ function App() { v{BUILD_VERSION}, key: 'BUILD_VERSION' }, + ], }} trigger={['click']} > diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..9af3619 --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,19 @@ +/** @type {import('tailwindcss').Config} */ +import colors from 'tailwindcss/colors' +export default { + content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'], + darkMode: 'media', + theme: { + colors: { + ...colors, + 'primary': '#00b96b', + }, + extend: {}, + }, + plugins: [], + corePlugins: { + preflight: false, + divideColor: true, + }, +} + diff --git a/vite.config.js b/vite.config.js index e411044..a1ae783 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,11 +1,20 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import legacy from "@vitejs/plugin-legacy"; +import WindiCSS from 'vite-plugin-windicss'; +import packageJson from './package.json'; +import dayjs from 'dayjs' + +const today = new dayjs().format('YYYY-MM-DD HH:mm:ss') // https://vitejs.dev/config/ export default defineConfig({ + define: { + __BUILD_DATE__: JSON.stringify(`${today}`), + __BUILD_VERSION__: JSON.stringify(`${packageJson.version}`), + }, plugins: [ - react(), + react(), WindiCSS(), legacy({ targets: ["defaults", "not IE 11"], }),