Import virtual UnoCSS styles
masterTo enable UnoCSS utility classes in the project, you must import the virtual CSS module. This entry point connects the UnoCSS engine to the application's style pipeline.
import 'virtual:uno.css'repository·master·Indexed 25 days ago
https://github.com/kailong321200875/vue-element-plus-adminA backend integration solution based on Vue 3, Element Plus, TypeScript, and Vite 4. It features an admin dashboard with a routing system supporting static and dynamic routes, permission-based access control, and multi-tab management. The project includes a comprehensive set of APIs for dashboard analysis, user and department management, role-based access, and a configured Axios instance for HTTP requests.
To enable UnoCSS utility classes in the project, you must import the virtual CSS module. This entry point connects the UnoCSS engine to the application's style pipeline.
import 'virtual:uno.css'The application is initialized using an asynchronous setupAll function that orchestrates the mounting of various plugins, stores, and core services. To replicate the application setup or understand the initialization sequence, ensure the following plugins are applied to the Vue app instance in order:
setupI18n(app)setupStore(app)setupGlobCom(app)setupElementPlus(app)setupRouter(app)setupPermission(app)Finally, call app.mount('#app') to mount the application to the DOM element with ID app.
import { createApp } from 'vue'
import App from './App.vue'
const setupAll = async () => {
const app = createApp(App)
await setupI18n(app)
setupStore(app)
setupGlobCom(app)
setupElementPlus(app)
setupRouter(app)
setupPermission(app)
app.mount('#app')
}
setupAll()Use setupElementPlus to register necessary Element Plus plugins (like ElLoading) and components (like ElScrollbar) globally in your Vue application. This ensures that components used in dropdowns or overlays have the correct styles and functionality.
To optimize development speed, you can instruct the plugin to import all Element Plus styles at once by setting the VITE_USE_ALL_ELEMENT_PLUS_STYLE environment variable to 'true'.
virtual:svg-icons-register. This registration process allows the application to recognize and use SVG icons that are processed through the build pipeline.The project uses UnoCSS for utility-first CSS. The configuration includes presetUno with dark mode support via the class strategy and transformerVariantGroup to allow grouping of variants.
Custom utility rules are available for specific layout and styling needs:
overflow-ellipsis: Applies text-overflow: ellipsis.custom-hover: Applies flex layout, height, padding, cursor, and transition, with specific hover background colors for light and dark modes.layout-border__left, layout-border__right, layout-border__top, layout-border__bottom: Apply absolute positioned pseudo-elements to create borders using CSS variables like --el-border-color.The project uses stylelint with postcss-html custom syntax to support linting CSS within .vue and .html files. It extends stylelint-config-standard and uses stylelint-order for property and rule ordering.
Key configuration details:
stylelint-order is used to enforce specific property and rule sequences..js, .jsx, .tsx, .ts) are ignored by Stylelint..vue and .html files to allow Vue-specific pseudo-elements like v-deep, v-global, and v-slotted.When using tree utility functions, you can provide a configuration object to specify the property names used for identifying nodes and their hierarchy. If no config is provided, the following defaults are used:
id: 'id'children: 'children'pid: 'pid'interface TreeHelperConfig {
id: string
children: string
pid: string
}The project uses a flat configuration file (eslint.config.mjs) that integrates TypeScript, Vue, and Prettier. It targets .ts, .tsx, and .vue files within the src directory.
Key configuration features include:
vue-eslint-parser for .vue files and typescript-eslint for TypeScript syntax.eslint.configs.recommended, tseslint.configs.recommended, and pluginVue.configs['flat/essential'].eslint-plugin-prettier to treat Prettier formatting issues as ESLint errors.import pluginVue from 'eslint-plugin-vue'
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import vueParser from 'vue-eslint-parser'
import prettier from 'eslint-plugin-prettier'
export default tseslint.config({
files: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.vue'],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
...pluginVue.configs['flat/essential']
],
plugins: {
prettier
},
languageOptions: {
parser: vueParser,
parserOptions: {
parser: tseslint.parser,
sourceType: 'module',
ecmaVersion: 2020,
ecmaFeatures: {
jsx: true
}
}
},
rules: {
'prettier/prettier': 'error',
// ... other rules
}
})The project uses Prettier for code formatting. The following configuration is applied to maintain consistent code style across the repository:
printWidth: 100tabWidth: 2useTabs: falsesemi: falsevueIndentScriptAndStyle: falsesingleQuote: truequoteProps: 'as-needed'bracketSpacing: truetrailingComma: 'none'jsxSingleQuote: falsearrowParens: 'always'insertPragma: falserequirePragma: falseproseWrap: 'never'htmlWhitespaceSensitivity: 'strict'endOfLine: 'auto'rangeStart: 0module.exports = {
printWidth: 100,
tabWidth: 2,
useTabs: false,
semi: false,
vueIndentScriptAndStyle: false,
singleQuote: true,
quoteProps: 'as-needed',
bracketSpacing: true,
trailingComma: 'none',
jsxSingleQuote: false,
arrowParens: 'always',
insertPragma: false,
requirePragma: false,
proseWrap: 'never',
htmlWhitespaceSensitivity: 'strict',
endOfLine: 'auto',
rangeStart: 0
}The UnoCSS icon preset behavior is controlled by an environment variable.
VITE_USE_ONLINE_ICON is set to 'true', the presetIcons is disabled (returns an empty array).VITE_USE_ONLINE_ICON is not 'true', presetIcons is enabled with autoInstall: false and uses the project's defined ICON_PREFIX.Search component is the primary entrypoint for search functionality. It can be imported and used within your Vue application. You can control its internal state and schema via the exposed methods defined in SearchExpose.