1.0.9 • Published 3 years ago
hitsystemset v1.0.9
NPM包发布更新
1.设置npm源为npm官方源
npm config set registry http://www.npmjs.org
2.登录npm账号,按提示输入npm用户名,邮箱,密码
npm login
3.检查是否登录成功.返回用户名,就代表登录成功
npm whoami
4.修改代码后重新打包
npm run lib
5.package.json中修改version后发布更新
npm publish
hitsystemset包使用
1.安装hitsystemset包
npm i hitsystemset
2.main.js导入
import SystemSettings from 'hitsystemset'
import 'hitsystemset/lib/hitsystemset.css'
Vue.use(SystemSettings)
3.确保index.html文件有<link rel="shortcut icon" href="/favicon.ico" />
浏览器窗口小图标的文件引入
4.App.vue引入getInfo方法
import getInfo from 'hitsystemset/package/utils/index'
import { base } from '@/api/index.js'
created() {
this.getInfo()
},
methods: {
async getInfo() {
await getInfo(base)
}
}
5.项目中用到sessionStorage,为了防止退出登录清空sessionStorage,需要在login组件中引入getInfo方法,同上
6.在项目中的单文件组件中引入SystemSettings公共组件
<template>
<div>
<System-Settings :base="base" :frontVersion="frontVersion"></System-Settings>
</div>
</template>
<script>
import { base } from '../../api/index' // 基地址
import packageJson from '../../../package.json' // 导入项目中的package.json文件,为了获取前端version
export default {
name: "SystemSetting",
computed: {
base() {
return base
},
frontVersion() {
return packageJson.version
}
},
}
</script>
<style>
</style>
7.将上述单文件组件挂载到前端路由router,即可在前端页面中通过路由直接跳转访问