1.0.1 • Published 2 years ago
nginx-config-helper v1.0.1
nginx-config-helper
功能
- 获取nginx静态仓库配置文件
- 仓库配置文件变动无感知更新
安装
使用 npm:
$ npm install nginx-config-helper
使用 bower:
$ bower install nginx-config-helper
使用 yarn:
$ yarn add nginx-config-helper
用法
新框架集成用法
main.js引入插件
//main.js
import NginxConfigHelper from 'nginx-config-helper2'
Vue.use(NginxConfigHelper, () => {
new Vue({
el: '#app',
router,
store,
render: h => h(App)
})
...
})
//cnofig.js加入下面配置
window.CONFIG_SERVER = {
host: '', //[必填]nginx静态服务器地址
appName: '', //[必填]json文件名,带.json后缀
fetchPolicies: 'always', //[可选]获取配置策略 always | once | close
intervalTime: 10000, //[可选]间隔时间ms 策略为always该配置生效
showLog: true, //[可选]是否显示日志
requestTimeout: 30000, //[可选]请求超时时间ms
needBlock: true, //[可选]是否需要等待配置中心返回(第一次获取生效)
blockTimeout: 30000 //[可选]获取配置最大等待时间ms
}
一般框架集成用法
main.js引入插件
//main.js
import NginxConfigHelper from 'nginx-config-helper2'
Vue.use(NginxConfigHelper, () => {
new Vue({
el: '#app',
router,
store,
render: h => h(App)
})
...
})
public或static文件夹下面添加config.js文件
//config.js
window.CONFIG_SERVER = {
host: '', //[必填]nginx静态服务器地址
appName: '', //[必填]json文件名,带.json后缀
fetchPolicies: 'always', //[可选]获取配置策略 always | once | close
intervalTime: 10000, //[可选]间隔时间ms 策略为always该配置生效
showLog: true, //[可选]是否显示日志
requestTimeout: 30000, //[可选]请求超时时间ms
needBlock: true, //[可选]是否需要等待配置中心返回(第一次获取生效)
blockTimeout: 30000 //[可选]获取配置最大等待时间ms
}
获取数据
window.WEB_CONFIG
//或者在vue文件内部使用
this.WEB_CONFIG