@universal-interface/components
v1.0.17
Published
Universal Interface Components for Vue.js
Downloads
84
Maintainers
Readme
Universal Interface Components
A collection of Vue.js components for building admin interfaces and dashboards.
Installation
npm install @universal-interface/componentsUsage
As a Plugin
import Vue from 'vue'
import ElementPlus from 'element-plus'
import UniversalInterface from '@universal-interface/components'
// Element Plus is required for these components
Vue.use(ElementPlus)
Vue.use(UniversalInterface)Individual Components
import { Account, Order, Product } from '@universal-interface/components'
export default {
components: {
Account,
Order,
Product
}
}Components
View Components
Account- Account management interfaceOrder- Order management interfaceProduct- Product management interfaceMarket- Product market displayTemplate- Template management interfaceCanvas- Canvas editor componentCanvasViewer- Canvas viewer componentDetail- Template detail viewDashboard- Dashboard overviewLogin- Login formUsers- User management interfaceRoles- Role management interfaceConsts- Constants configuration interfaceStatusExample- Status constants usage exampleAppView- Main application view
Layout Components
Layout- Main layout container with sidebar and headerSidebar- Navigation sidebar with menu itemsBreadcrumb- Breadcrumb navigation with user dropdown
Event Handling
Most components emit events for handling user interactions:
success- When an operation completes successfullyerror- When an error occursconfirm- When user confirmation is requiredwarning- When a warning should be displayedinfo- When informational messages should be displayed
Example:
<template>
<Account
@success="handleSuccess"
@error="handleError"
@confirm="handleConfirm"
/>
</template>
<script>
import { Account } from '@universal-interface/components'
export default {
components: { Account },
methods: {
handleSuccess(message) {
this.$message.success(message)
},
handleError(message) {
this.$message.error(message)
},
handleConfirm(config) {
this.$confirm(config.message, config.title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (config.onConfirm) config.onConfirm()
}).catch(() => {
if (config.onCancel) config.onCancel()
})
}
}
}
</script>API Integration
Components accept API implementations as props, allowing you to customize data fetching:
<template>
<Account :account-api="customAccountApi" />
</template>
<script>
import { Account } from '@universal-interface/components'
export default {
components: { Account },
data() {
return {
customAccountApi: {
list: (params) => {
// Your custom implementation
return Promise.resolve({ code: 200, data: { list: [], total: 0 } })
},
update: (data) => {
// Your custom implementation
return Promise.resolve({ code: 200, message: 'Success' })
}
// ... other methods
}
}
}
}
</script>Layout Components Usage
Layout components can be used to create a complete admin interface:
<template>
<Layout>
<router-view />
</Layout>
</template>
<script>
import { Layout } from '@universal-interface/components'
export default {
components: { Layout }
}
</script>The layout components accept props for customization:
<template>
<Layout :sidebar-collapsed="sidebarCollapsed">
<Sidebar
:routes="routes"
:current-path="currentPath"
:collapsed="sidebarCollapsed"
@toggle-collapse="handleToggleCollapse"
@menu-select="handleMenuSelect"
/>
<Breadcrumb
:user-info="userInfo"
:matched-routes="matchedRoutes"
@logout="handleLogout"
@profile="handleProfile"
/>
</Layout>
</template>Building and Publishing to npm
Prerequisites
Before building and publishing, ensure you have:
- An npm account (create one at https://www.npmjs.com/signup if you don't have one)
- Logged in to npm registry locally:
npm login
Building the Package
To build the package for distribution:
npm run buildThis will:
- Compile all Vue components
- Generate three output formats:
- ES Module (index.esm.js)
- CommonJS (index.js)
- UMD (index.min.js)
- Extract and bundle CSS styles
- Generate source maps for debugging
The built files will be located in the dist/ directory.
Publishing to npm
Update the version in
package.json:npm version patch # for bug fixes npm version minor # for new features npm version major # for breaking changesOr manually update the version field in
package.json.Publish the package:
npm publishFor scoped packages (like
@universal-interface/components), make sure to set the access level:npm publish --access public
Publishing to a Private Registry
If you want to publish to a private npm registry:
Set the registry URL:
npm config set registry https://your-private-registry.com/Publish as usual:
npm publish
Testing Before Publishing
To test the package locally before publishing:
Link the package:
npm linkIn another project, link to this package:
npm link @universal-interface/componentsTest the components in your project.
When finished testing, unlink:
npm unlink @universal-interface/components
Dependencies
This package depends on the following libraries:
- vue ^2.6.14
- element-plus ^2.4.0
- vue-cookies ^1.7.4
- vue-json-viewer ^2.2.22
- vuedraggable ^2.24.3
Make sure to install these dependencies in your project:
npm install vue element-plus vue-cookies vue-json-viewer vuedraggableDevelopment
To run the example:
npm run exampleTo build the package:
npm run buildLicense
MIT
