Commit e1e9ebcd by 无尘

add vue-header

parent 4f2c48ed
{
"presets": [
["env", { "modules": false }],
"stage-3"
]
}
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
.DS_Store
node_modules/
npm-debug.log
yarn-error.log
# Editor directories and files
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
\ No newline at end of file
# vue-gic-header
#
<<<<<<< HEAD
> A Vue.js vue-gic-header Plugin
## Install
- 记得需要切换 公司源
- 换源: npm config set registry http://www.gicdev.com:7001/ 或者使用 nrm 切换
```shell
npm install @gic-test/vue-gic-header -S
```
## how to use
```
// main.js
import vueGicHeader from '@gic-test/vue-gic-header'
Vue.use(vueGicHeader)
// 使用页面
<vue-gic-header :projectName="projectName" :collapseFlag="collapseFlag" @collapseTag="collapseTag" @toRouterView="toRouterView"></vue-gic-header>
data() {
return {
// 可传参数
projectName: '', // 当前项目名
collapseFlag: false, // 折叠参数
// 路由菜单
// 修改由插件请求
}
}
methods: {
// 处理路由跳转
toRouterView(val) {
var that = this;
// 模拟检查数据
console.log(val);
//有两个参数
//{
// name:,
// path:
//}
that.$router.push({
path: val.path
})
},
// 折叠事件
collapseTag(val){
var that = this;
console.log(val);
}
},
```
>注意,需要 增加 el-popover 样式
```
.user-header-pop {
min-width: 95px;
}
.el-popover.user-header-pop {
min-width: 95px;
}
```
Command line instructions
Git global setup
git config --global user.name "无尘"
git config --global user.email "yueheqing@demogic.com"
Create a new repository
git clone http://115.159.76.241/vue-plugins/vue-gic-header.git
cd vue-gic-header
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin http://115.159.76.241/vue-plugins/vue-gic-header.git
git add .
git commit -m "Initial commit"
git push -u origin master
Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin http://115.159.76.241/vue-plugins/vue-gic-header.git
git push -u origin --all
git push -u origin --tags
```
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>vue-gic-header</title>
</head>
<body>
<div id="app"></div>
<!-- <script src="/dist/build.js"></script> -->
<script src="/dist/vue-gic-header.js"></script>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "@gic-test/vue-gic-header",
"description": "vue-gic-header Plugin",
"author": "fairyly <498745097@qq.com>",
"version": "1.3.28",
"license": "MIT",
"private": false,
"main": "dist/vue-gic-header.js",
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"axios": "^0.18.0",
"vue": "^2.5.11"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-3": "^6.24.1",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
"less": "^3.0.4",
"less-loader": "^4.1.0",
"node-sass": "^4.5.3",
"sass-loader": "^6.0.6",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.9.1"
}
}
<template>
<div id="app">
<vue-gic-header :projectName="projectName" :collapseFlag="collapseFlag" @collapseTag="collapseTag" @toRouterView="toRouterView"></vue-gic-header>
</div>
</template>
<script>
import vueGicHeader from './lib/vue-gic-header'
export default {
name: 'app',
data () {
return {
projectName: '', // 当前项目名
// headerRouterOptions: {
collapseFlag: false, // 折叠参数
// 路由菜单
// 修改由插件请求
// },
}
},
components: {
vueGicHeader
},
methods: {
// 处理路由跳转
toRouterView(val) {
var that = this;
// 模拟检查数据
// //有两个参数
//{
// name:,
// path:
//}
console.log(val);
that.$router.push({
path: val.path
})
},
// 折叠事件
collapseTag(val){
var that = this;
console.log(val);
}
}
}
</script>
<style lang="scss">
* {
margin: 0;
padding: 0;
}
</style>
import axios from 'axios';
import qs from 'qs';
axios.defaults.timeout = 10000;
let base = "http://192.168.1.164:8282/gic/";
const timeout = 10000;
let token = ''//sessionStorage.getItem('user');
/*
*
* 统一 get 请求方法
* @url: 请求的 url
* @params: 请求带的参数
* @header: 带 token
*
*/
export const getRequest = (url, params) => {
return axios({
method: 'get',
url: `${base}${url}`,
data: {},
params: params,
headers: {'content-type': 'application/x-www-form-urlencoded'},// "token": token
});
}
import vueGicHeader from './vue-gic-header.vue' // 导入组件
const vueGic = {
install(Vue, options) {
Vue.component(vueGicHeader.name, vueGicHeader) // vueGicHeader.name 组件的name属性
// 类似通过 this.$xxx 方式调用插件的 其实只是挂载到原型上而已
// Vue.prototype.$xxx // 最终可以在任何地方通过 this.$xxx 调用
// 虽然没有明确规定用$开头 但是大家都默认遵守这个规定
}
}
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(vueGic);
}
export default vueGic
// export {
// vueGicHeader
// }
import Vue from 'vue'
import App from './App.vue'
new Vue({
el: '#app',
render: h => h(App)
})
var path = require('path')
var webpack = require('webpack')
module.exports = {
// entry: './src/main.js',
entry: './src/lib/index.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: './',
// filename: 'build.js',
filename: 'vue-gic-header.js',
library: 'vue-gic-header',
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
],
},
{
test: /\.sass$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
],
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
// the "scss" and "sass" values for the lang attribute to the right configs here.
// other preprocessors should work out of the box, no loader config like this necessary.
'scss': [
'vue-style-loader',
'css-loader',
'sass-loader'
],
'sass': [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
]
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
// options: {
// name: '[name].[ext]?[hash]'
// },
query : {
name : 'static/img/[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment