Commit e7366c54 authored by looker's avatar looker

init

parent 4c293573
MIT License
Copyright (c) 2017-present PanJiaChen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
开发环境启动 npm run dev
打包 npm run build
\ No newline at end of file
# vue-admin-template
> A minimal vue admin template with Element UI & axios & iconfont & permission control & lint
# install dependencies
**Live demo:** http://panjiachen.github.io/vue-admin-template
[中文文档](https://github.com/PanJiaChen/vue-admin-template/blob/master/README-zh.md)
## Build Setup
```bash
# Clone project
git clone https://github.com/PanJiaChen/vue-admin-template.git
# Install dependencies
npm install
# serve with hot reload at localhost:8080
# Serve with hot reload at localhost:9528
npm run dev
# build for production with minification
# Build for production with minification
npm run build
# build for production and view the bundle analyzer report
# Build for production and view the bundle analyzer report
npm run build --report
```
## Demo
![demo](https://github.com/PanJiaChen/PanJiaChen.github.io/blob/master/images/demo.gif)
## Extra
If you want router permission && generate menu by user roles , you can use this branch [permission-control](https://github.com/PanJiaChen/vue-admin-template/tree/permission-control)
This project is based on `webpack4` development. If you want to use `webpack3` development, please use this branch [webpack3](https://github.com/PanJiaChen/vue-admin-template/tree/webpack3)
For `typescript` version, you can use [vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) (Credits: [@Armour](https://github.com/Armour))
## Related Project
[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
[electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin)
[vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template)
### Element-Ui using cdn tutorial
First find `index.html`([root directory](https://github.com/PanJiaChen/vue-admin-template/blob/element-ui-cdn/index.html))
Import css and js of `Element`, and then import vue. Because `Element` is vue-dependent, vue must be import before it.
Then find [webpack.base.conf.js](https://github.com/PanJiaChen/vue-admin-template/blob/element-ui-cdn/build/webpack.base.conf.js)
Add `externals` to make webpack not package vue and element.
```
externals: {
vue: 'Vue',
'element-ui':'ELEMENT'
}
```
Finally there is a small detail to pay attention to that if you import vue in global, you don't need to manually `Vue.use(Vuex)`, it will be automatically mounted, see
[issue](https://github.com/vuejs/vuex/issues/731)
And you can use `npm run build --report` to see the effect
Pictured:
![demo](https://panjiachen.github.io/images/element-cdn.png)
**[Detailed code](https://github.com/PanJiaChen/vue-admin-template/commit/746aff560932704ae821f82f10b8b2a9681d5177)**
**[Branch](https://github.com/PanJiaChen/vue-admin-template/tree/element-ui-cdn)**
## License
[MIT](https://github.com/PanJiaChen/vue-admin-template/blob/master/LICENSE) license.
Copyright (c) 2017-present PanJiaChen
'use strict'
require('./check-versions')()
process.env.NODE_ENV = 'production'
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')
const spinner = ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, (err, stats) => {
spinner.stop()
if (err) throw err
process.stdout.write(
stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n\n'
)
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan(' Build complete.\n'))
console.log(
chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
" Opening index.html over file:// won't work.\n"
)
)
})
})
'use strict'
require('./check-versions')()
process.env.NODE_ENV = 'test'
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')
const spinner = ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, (err, stats) => {
spinner.stop()
if (err) throw err
process.stdout.write(
stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n\n'
)
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan(' Build complete.\n'))
console.log(
chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
" Opening index.html over file:// won't work.\n"
)
)
})
})
require('./check-versions')()
process.env.NODE_ENV = 'production'
var ora = require('ora')
var rm = require('rimraf')
var path = require('path')
var chalk = require('chalk')
var webpack = require('webpack')
var config = require('../config')
var webpackConfig = require('./webpack.prod.conf')
var spinner = ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, function (err, stats) {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n\n')
console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})
var chalk = require('chalk')
var semver = require('semver')
var packageConfig = require('../package.json')
var shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec(cmd) {
return require('child_process')
.execSync(cmd)
.toString()
.trim()
}
var versionRequirements = [
const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
},
}
]
if (shell.which('npm')) {
......@@ -22,26 +27,37 @@ if (shell.which('npm')) {
})
}
module.exports = function () {
var warnings = []
for (var i = 0; i < versionRequirements.length; i++) {
var mod = versionRequirements[i]
module.exports = function() {
const warnings = []
for (let i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
warnings.push(
mod.name +
': ' +
chalk.red(mod.currentVersion) +
' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log(
chalk.yellow(
'To use this template, you must update following to modules:'
)
)
console.log()
for (var i = 0; i < warnings.length; i++) {
var warning = warnings[i]
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
......
/* eslint-disable */
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
hotClient.subscribe(function (event) {
if (event.action === 'reload') {
window.location.reload()
}
})
require('./check-versions')()
var config = require('../config')
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
}
var opn = require('opn')
var path = require('path')
var express = require('express')
var webpack = require('webpack')
var proxyMiddleware = require('http-proxy-middleware')
var webpackConfig = require('./webpack.dev.conf')
// default port where dev server listens for incoming traffic
var port = process.env.PORT || config.dev.port
// automatically open browser, if not set will be false
var autoOpenBrowser = !!config.dev.autoOpenBrowser
// Define HTTP proxies to your custom API backend
// https://github.com/chimurai/http-proxy-middleware
var proxyTable = config.dev.proxyTable
var app = express()
var compiler = webpack(webpackConfig)
var devMiddleware = require('webpack-dev-middleware')(compiler, {
publicPath: webpackConfig.output.publicPath,
quiet: true
})
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
log: () => {}
})
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', function (compilation) {
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
hotMiddleware.publish({ action: 'reload' })
cb()
})
})
// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
var options = proxyTable[context]
if (typeof options === 'string') {
options = { target: options }
}
app.use(proxyMiddleware(options.filter || context, options))
})
// handle fallback for HTML5 history API
app.use(require('connect-history-api-fallback')())
// serve webpack bundle output
app.use(devMiddleware)
// enable hot-reload and state-preserving
// compilation error display
app.use(hotMiddleware)
// serve pure static assets
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
app.use(staticPath, express.static('./static'))
var uri = 'http://localhost:' + port
var _resolve
var readyPromise = new Promise(resolve => {
_resolve = resolve
})
console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri)
}
_resolve()
})
var server = app.listen(port)
module.exports = {
ready: readyPromise,
close: () => {
server.close()
}
}
var path = require('path')
var config = require('../config')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
exports.assetsPath = function (_path) {
var assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
'use strict'
const path = require('path')
const config = require('../config')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const packageConfig = require('../package.json')
exports.assetsPath = function(_path) {
const assetsSubDirectory =
process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function (options) {
exports.cssLoaders = function(options) {
options = options || {}
var cssLoader = {
const cssLoader = {
loader: 'css-loader',
options: {
minimize: process.env.NODE_ENV === 'production',
sourceMap: options.sourceMap
}
}
const postcssLoader = {
loader: 'postcss-loader',
options: {
sourceMap: options.sourceMap
}
}
// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
var loaders = [cssLoader]
function generateLoaders(loader, loaderOptions) {
const loaders = []
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
loaders.push(MiniCssExtractPlugin.loader)
} else {
loaders.push('vue-style-loader')
}
loaders.push(cssLoader)
if (options.usePostCSS) {
loaders.push(postcssLoader)
}
if (loader) {
loaders.push({
loader: loader + '-loader',
......@@ -32,24 +57,16 @@ exports.cssLoaders = function (options) {
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
return loaders
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
sass: generateLoaders('sass', {
indentedSyntax: true
}),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
......@@ -57,15 +74,35 @@ exports.cssLoaders = function (options) {
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
var output = []
var loaders = exports.cssLoaders(options)
for (var extension in loaders) {
var loader = loaders[extension]
exports.styleLoaders = function(options) {
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
exports.createNotifierCallback = () => {
const notifier = require('node-notifier')
return (severity, errors) => {
if (severity !== 'error') return
const error = errors[0]
const filename = error.file && error.file.split('!').pop()
notifier.notify({
title: packageConfig.name,
message: severity + ': ' + error.name,
subtitle: filename || '',
icon: path.join(__dirname, 'logo.png')
})
}
}
var utils = require('./utils')
var config = require('../config')
var isProduction = process.env.NODE_ENV === 'production'
'use strict'
module.exports = {
loaders: utils.cssLoaders({
sourceMap: isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap,
extract: isProduction
})
//You can set the vue-loader configuration by yourself.
}
var path = require('path')
var utils = require('./utils')
var config = require('../config')
var vueLoaderConfig = require('./vue-loader.conf')
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const { VueLoaderPlugin } = require('vue-loader')
const vueLoaderConfig = require('./vue-loader.conf')
function resolve (dir) {
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
const createLintingRule = () => ({
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter'),
emitWarning: !config.dev.showEslintErrorsInOverlay
}
})
module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
publicPath:
process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'vue$': 'vue/dist/vue.common.js',
'@': resolve('src')
}
},
module: {
rules: [
...(config.dev.useEslint ? [createLintingRule()] : []),
{
test: /\.vue$/,
loader: 'vue-loader',
......@@ -35,16 +51,39 @@ module.exports = {
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test')]
include: [
resolve('src'),
resolve('test'),
// resolve('static'),
resolve('node_modules/element-ui/packages'),
resolve('node_modules/webpack-dev-server/client')
]
},
{
test: /\.svg$/,
loader: 'svg-sprite-loader',
include: [resolve('src/icons')],
options: {
symbolId: 'icon-[name]'
}
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
exclude: [resolve('src/icons')],
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
......@@ -54,5 +93,18 @@ module.exports = {
}
}
]
},
plugins: [new VueLoaderPlugin()],
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
}
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
})
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
module.exports = merge(baseWebpackConfig, {
const devWebpackConfig = merge(baseWebpackConfig, {
mode: 'development',
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
rules: utils.styleLoaders({
sourceMap: config.dev.cssSourceMap,
usePostCSS: true
})
},
// cheap-module-eval-source-map is faster for development
devtool: '#cheap-module-eval-source-map',
devtool: config.dev.devtool,
// these devServer options should be customized in /config/index.js
devServer: {
clientLogLevel: 'warning',
historyApiFallback: true,
hot: true,
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': config.dev.env
'process.env': require('../config/dev.env')
}),
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
new FriendlyErrorsPlugin()
inject: true,
favicon: resolve('favicon.ico'),
title: 'vue-admin-template'
})
]
})
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(
new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [
`Your application is running here: http://${
devWebpackConfig.devServer.host
}:${port}`
]
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
})
)
resolve(devWebpackConfig)
}
})
})
var path = require('path')
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var CopyWebpackPlugin = require('copy-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
var env = config.build.env
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
const env = require('../config/prod.env')
var webpackConfig = merge(baseWebpackConfig, {
// For NamedChunksPlugin
const seen = new Set()
const nameLength = 4
const webpackConfig = merge(baseWebpackConfig, {
mode: 'production',
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true
extract: true,
usePostCSS: true
})
},
devtool: config.build.productionSourceMap ? '#source-map' : false,
devtool: config.build.productionSourceMap ? config.build.devtool : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
filename: utils.assetsPath('js/[name].[chunkhash:8].js'),
chunkFilename: utils.assetsPath('js/[name].[chunkhash:8].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
sourceMap: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css')
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: {
safe: true
}
new MiniCssExtractPlugin({
filename: utils.assetsPath('css/[name].[contenthash:8].css'),
chunkFilename: utils.assetsPath('css/[name].[contenthash:8].css')
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
......@@ -53,36 +54,42 @@ var webpackConfig = merge(baseWebpackConfig, {
filename: config.build.index,
template: 'index.html',
inject: true,
favicon: resolve('favicon.ico'),
title: 'vue-admin-template',
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module, count) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
// default sort mode uses toposort which cannot handle cyclic deps
// in certain cases, and in webpack 4, chunk order in HTML doesn't
// matter anyway
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
chunks: ['vendor']
new ScriptExtHtmlWebpackPlugin({
//`runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/
}),
// keep chunk.id stable when chunk has no name
new webpack.NamedChunksPlugin(chunk => {
if (chunk.name) {
return chunk.name
}
const modules = Array.from(chunk.modulesIterable)
if (modules.length > 1) {
const hash = require('hash-sum')
const joinedHash = hash(modules.map(m => m.id).join('_'))
let len = nameLength
while (seen.has(joinedHash.substr(0, len))) len++
seen.add(joinedHash.substr(0, len))
return `chunk-${joinedHash.substr(0, len)}`
} else {
return modules[0].id
}
}),
// keep module.id stable when vender modules does not change
new webpack.HashedModuleIdsPlugin(),
// copy custom static assets
new CopyWebpackPlugin([
{
......@@ -91,20 +98,52 @@ var webpackConfig = merge(baseWebpackConfig, {
ignore: ['.*']
}
])
]
],
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial' // 只打包初始时依赖的第三方
},
elementUI: {
name: 'chunk-elementUI', // 单独将 elementUI 拆包
priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app
test: /[\\/]node_modules[\\/]element-ui[\\/]/
}
}
},
runtimeChunk: 'single',
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
mangle: {
safari10: true
}
},
sourceMap: config.build.productionSourceMap,
cache: true,
parallel: true
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSAssetsPlugin()
]
}
})
if (config.build.productionGzip) {
var CompressionWebpackPlugin = require('compression-webpack-plugin')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
'\\.(' + config.build.productionGzipExtensions.join('|') + ')$'
),
threshold: 10240,
minRatio: 0.8
......@@ -112,9 +151,28 @@ if (config.build.productionGzip) {
)
}
if (config.build.bundleAnalyzerReport) {
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
if (config.build.generateAnalyzerReport || config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin
if (config.build.bundleAnalyzerReport) {
webpackConfig.plugins.push(
new BundleAnalyzerPlugin({
analyzerPort: 8080,
generateStatsFile: false
})
)
}
if (config.build.generateAnalyzerReport) {
webpackConfig.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: 'bundle-report.html',
openAnalyzer: false
})
)
}
}
module.exports = webpackConfig
var merge = require('webpack-merge')
var prodEnv = require('./prod.env')
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
API_URL:'"/api/"',
WX_ADDRESS: '"http://imdev.chenzhen.shop:9093/"',
// WX_ADDRESS: '"http://imdev.chenzhen.shop:9093/"',
WX_ADDRESS: '"172.16.22.67:9093/"',
IMG_ADDRESS:'"http://chat-x.oss-cn-beijing.aliyuncs.com/"'
})
'use strict'
// Template version: 1.2.6
// see http://vuejs-templates.github.io/webpack for documentation.
var path = require('path')
const path = require('path')
module.exports = {
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './',
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
},
dev: {
env: require('./dev.env'),
port: 8099,
autoOpenBrowser: true,
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
......@@ -34,16 +16,81 @@ module.exports = {
// }
'/api': {
pathRewrite: { '^/api': '' },
// target: 'http://imweb.chenzhen.shop',
target: 'http://imdev.chenzhen.shop/',
target: 'http://172.16.22.67',
// target: 'http://imdev.chenzhen.shop/',
changeOrigin: true, //是否跨域
}
},
// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: 8889, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: true,
errorOverlay: true,
notifyOnErrors: false,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-source-map',
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
/**
* You can set by youself according to actual condition
* You will need to set this if you plan to deploy your site under a sub path,
* for example GitHub pages. If you plan to deploy your site to https://foo.github.io/bar/,
* then assetsPublicPath should be set to "/bar/".
* In most cases please use '/' !!!
*/
assetsPublicPath: '/',
/**
* Source Maps
*/
productionSourceMap: false,
// https://webpack.js.org/configuration/devtool/#production
devtool: 'source-map',
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report || false,
// `npm run build:prod --generate_report`
generateAnalyzerReport: process.env.npm_config_generate_report || false
}
}
'use strict'
module.exports = {
NODE_ENV: '"production"',
API_URL:'""',
......
'use strict'
module.exports = {
NODE_ENV: '"test"',
IMG_ADDRESS: '"test"',
BASE_API: '"https://easy-mock.com/mock/5950a2419adc231f356a6636/vue-admin"',
}
d.ico

10.1 KB

File added
favicon.ico

1.12 KB

......@@ -2,8 +2,10 @@
<html>
<head>
<meta charset="utf-8">
<title>wechat</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>客服聊天软件</title>
<link rel="stylesheet" href="static/css/reset.css">
<script src="static/socket.js"></script>
</head>
<body>
<div id="app"></div>
......
This diff is collapsed.
{
"name": "wechat",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "hcn",
"private": true,
"name": "vue-admin-template",
"version": "3.8.0",
"license": "MIT",
"description": "A vue admin template with Element UI & axios & iconfont & permission control & lint",
"author": "Pan <panfree23@gmail.com>",
"scripts": {
"dev": "node build/dev-server.js",
"start": "node build/dev-server.js",
"build": "node build/build.js"
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"build-pro": "node build/build-pro.js",
"build-test": "node build/build-test.js",
"build:report": "npm_config_report=true npm run build",
"lint": "eslint --ext .js,.vue src",
"test": "npm run lint",
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml"
},
"dependencies": {
"ali-oss": "^6.1.1",
"axios": "^0.18.0",
"element-ui": "^2.8.2",
"js-cookie": "^2.2.0",
"axios": "0.18.0",
"element-ui": "2.4.6",
"jquery": "^3.3.1",
"js-cookie": "2.2.0",
"moment": "^2.24.0",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"socket.io-client": "^2.2.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
"vue": "^2.2.6",
"vue-router": "^2.3.1",
"vuex": "^2.3.1"
"stylus-loader": "^3.0.2",
"vue": "2.5.17",
"vue-preview": "^1.1.3",
"vue-router": "3.0.1",
"vue-simple-tree": "^2.3.2",
"vuex": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^6.7.2",
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^1.1.3",
"connect-history-api-fallback": "^1.3.0",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"eventsource-polyfill": "^0.9.6",
"express": "^4.14.1",
"extract-text-webpack-plugin": "^2.0.0",
"file-loader": "^0.11.1",
"friendly-errors-webpack-plugin": "^1.1.3",
"html-webpack-plugin": "^2.28.0",
"http-proxy-middleware": "^0.17.3",
"moment": "^2.24.0",
"opn": "^4.0.2",
"optimize-css-assets-webpack-plugin": "^1.3.0",
"ora": "^1.2.0",
"rimraf": "^2.6.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"url-loader": "^0.5.8",
"vue-loader": "^11.3.4",
"vue-style-loader": "^2.0.5",
"vue-template-compiler": "^2.2.6",
"webpack": "^2.3.3",
"webpack-bundle-analyzer": "^2.2.1",
"webpack-dev-middleware": "^1.10.0",
"webpack-hot-middleware": "^2.18.0",
"webpack-merge": "^4.1.0"
"autoprefixer": "8.5.0",
"babel-core": "6.26.0",
"babel-eslint": "8.2.6",
"babel-helper-vue-jsx-merge-props": "2.0.3",
"babel-loader": "7.1.5",
"babel-plugin-syntax-jsx": "6.18.0",
"babel-plugin-transform-runtime": "6.23.0",
"babel-plugin-transform-vue-jsx": "3.7.0",
"babel-preset-env": "1.7.0",
"babel-preset-stage-2": "6.24.1",
"chalk": "2.4.1",
"copy-webpack-plugin": "4.5.2",
"css-loader": "1.0.0",
"eslint": "4.19.1",
"eslint-friendly-formatter": "4.0.1",
"eslint-loader": "2.0.0",
"eslint-plugin-vue": "4.7.1",
"eventsource-polyfill": "0.9.6",
"file-loader": "1.1.11",
"friendly-errors-webpack-plugin": "1.7.0",
"html-webpack-plugin": "4.0.0-alpha",
"mini-css-extract-plugin": "0.4.1",
"node-notifier": "5.2.1",
"node-sass": "^4.7.2",
"optimize-css-assets-webpack-plugin": "5.0.0",
"ora": "3.0.0",
"path-to-regexp": "2.4.0",
"portfinder": "1.0.16",
"postcss-import": "12.0.0",
"postcss-loader": "2.1.6",
"postcss-url": "7.3.2",
"rimraf": "2.6.2",
"sass-loader": "7.0.3",
"script-ext-html-webpack-plugin": "2.0.1",
"semver": "5.5.0",
"shelljs": "0.8.2",
"svg-sprite-loader": "3.8.0",
"svgo": "1.0.5",
"uglifyjs-webpack-plugin": "1.2.7",
"url-loader": "1.0.1",
"vue-loader": "15.3.0",
"vue-style-loader": "4.1.2",
"vue-template-compiler": "2.5.17",
"webpack": "4.16.5",
"webpack-bundle-analyzer": "2.13.1",
"webpack-cli": "3.1.0",
"webpack-dev-server": "3.1.5",
"webpack-merge": "4.1.4"
},
"engines": {
"node": ">= 4.0.0",
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
......
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# nodeserver
\ No newline at end of file
/*
Navicat MySQL Data Transfer
Source Server : pic
Source Server Version : 50719
Source Host : localhost:3306
Source Database : baogao
Target Server Type : MYSQL
Target Server Version : 50719
File Encoding : 65001
Date: 2017-09-28 23:14:22
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `account_book`
-- ----------------------------
DROP TABLE IF EXISTS `account_book`;
CREATE TABLE `account_book` (
`bid` bigint(20) NOT NULL AUTO_INCREMENT,
`uid` bigint(20) DEFAULT NULL,
`bdate` date DEFAULT NULL,
`baccount` float(7,2) DEFAULT NULL,
`bcategory` int(11) DEFAULT NULL,
`bremark` varchar(100) DEFAULT NULL,
PRIMARY KEY (`bid`)
) ENGINE=InnoDB AUTO_INCREMENT=11116 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of account_book
-- ----------------------------
INSERT INTO `account_book` VALUES ('1', '1', '2017-09-01', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('2', '1', '2017-09-02', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('3', '1', '2017-09-03', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('4', '1', '2017-09-04', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('5', '1', '2017-09-05', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('6', '1', '2017-09-06', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('7', '1', '2017-09-07', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('8', '1', '2017-09-08', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('9', '1', '2017-09-09', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('10', '1', '2017-09-10', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('11', '1', '2017-09-11', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('12', '1', '2017-09-12', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('13', '1', '2017-09-13', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('14', '1', '2017-09-14', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('15', '1', '2017-09-15', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('16', '1', '2017-09-16', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('17', '1', '2017-09-17', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('18', '1', '2017-09-18', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('19', '1', '2017-09-19', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('20', '1', '2017-09-20', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('21', '1', '2017-09-21', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('22', '1', '2017-09-22', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('23', '1', '2017-09-23', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('24', '1', '2017-09-24', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('25', '1', '2017-09-25', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('26', '1', '2017-09-26', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('27', '1', '2017-09-27', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('28', '1', '2017-09-28', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('29', '1', '2017-09-29', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('30', '1', '2017-09-30', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('31', '1', '2017-10-01', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('32', '1', '2017-10-02', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('33', '1', '2017-09-01', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('34', '1', '2017-09-02', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('35', '1', '2017-09-03', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('36', '1', '2017-09-04', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('37', '1', '2017-09-05', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('38', '1', '2017-09-06', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('39', '1', '2017-09-07', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('40', '1', '2017-09-08', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('41', '1', '2017-09-09', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('42', '1', '2017-09-10', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('43', '1', '2017-09-11', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('44', '1', '2017-09-12', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('45', '1', '2017-09-13', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('46', '1', '2017-09-14', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('47', '1', '2017-09-15', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('48', '1', '2017-09-16', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('49', '1', '2017-09-17', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('50', '1', '2017-09-18', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('51', '1', '2017-09-19', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('52', '1', '2017-09-20', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('53', '1', '2017-09-21', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('54', '1', '2017-09-22', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('55', '1', '2017-09-23', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('56', '1', '2017-09-24', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('57', '1', '2017-09-25', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('58', '1', '2017-09-26', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('59', '1', '2017-09-27', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('60', '1', '2017-09-28', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('61', '1', '2017-09-29', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('62', '1', '2017-09-30', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('63', '1', '2017-10-01', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('64', '1', '2017-10-02', '7.00', '3', '鏅氶');
INSERT INTO `account_book` VALUES ('11113', '3', '2017-09-04', '8.00', '2', '\'rrrrr\'');
INSERT INTO `account_book` VALUES ('11114', '3', '2017-09-04', '8.00', '2', '\'rrrrr\'');
INSERT INTO `account_book` VALUES ('11115', '3', '2017-09-04', '8.00', '2', 'rrrrr');
-- ----------------------------
-- Table structure for `account_category`
-- ----------------------------
DROP TABLE IF EXISTS `account_category`;
CREATE TABLE `account_category` (
`cid` bigint(20) NOT NULL AUTO_INCREMENT,
`cname` varchar(20) DEFAULT NULL,
PRIMARY KEY (`cid`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of account_category
-- ----------------------------
INSERT INTO `account_category` VALUES ('1', '灞呭');
INSERT INTO `account_category` VALUES ('2', '椁愰ギ');
INSERT INTO `account_category` VALUES ('3', '璐墿');
-- ----------------------------
-- Table structure for `account_users`
-- ----------------------------
DROP TABLE IF EXISTS `account_users`;
CREATE TABLE `account_users` (
`uid` bigint(20) NOT NULL AUTO_INCREMENT,
`username` varchar(20) DEFAULT NULL,
`password` varchar(20) DEFAULT NULL,
PRIMARY KEY (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of account_users
-- ----------------------------
INSERT INTO `account_users` VALUES ('1', 'Meso', '123456');
INSERT INTO `account_users` VALUES ('2', 'Meso', '123456');
var allControl={}
var userControl=require('./userControl');
var bookControl=require('./bookControl');
var managements=[userControl];
allControl.setAllControl=function(app){
for(m in managements){
for(f in managements[m]){
managements[m][f](app)
}
}
}
module.exports=allControl
\ No newline at end of file
var bookControl={};
var bookDao=require('../dao/bookDao');
var userLang = require('../lang/userLang');
bookControl.getPage=function(app){
app.get('/get-book',function(req,res){
let p1 = bookDao.getPage(req.query)
let p2 = bookDao.getTotalNum()
Promise.all([p1, p2]).then(values => {
res.status(200),
res.json(values)
})
})
}
bookControl.add=function(app){
app.get('/add-book',function(req,res){
bookDao.add(req.query).then(function(data){
res.status(200),
res.json(data)
})
})
}
bookControl.delete=function(app){
app.get('/delete-book',function(req,res){
bookDao.delete(req.query).then(function(data){
res.status(200),
res.json(data)
})
})
}
bookControl.update=function(app){
app.get('/update-book',function(req,res){
bookDao.update(req.query).then(function(data){
res.status(200),
res.json(data)
})
})
}
module.exports=bookControl
\ No newline at end of file
var userControl={};
var userDao=require('../dao/userDao');
var userLang = require('../lang/userLang');
userControl.getUserInfo=function(app){
app.get('/get-alluser',function(req,res){
userDao.getAllUser().then(function(data){
res.status(200),
res.json(data)
})
})
}
// userControl.getTset=function(app){
// app.get('/get-test',function(req,res){
// userDao.test().then(function(value){
// res.status(200),
// res.json(value)
// });
// })
// }
userControl.info = function (app) {
app.get('/user/info',function(req,res){
let data = {name:'张三',id:3232323,avatar:'http://gitlab.ybejia.com:3080/jenkins/static/4ec26488/images/headshot.png',roles:[2,3,4,4,4,45]}
res.status(200),
res.json(data)
// userDao.addUser().then(function(value){
// res.status(200),
// res.json()
// })
})
}
userControl.getEmployees = function (app) {
app.get('/authority/get-employees',function(req,res){
let list =[]
for(let i = 0;i<10;i++){
let obj = {
cl1:'cl1'+i,
cl2:'cl2'+i,
cl3:'cl3'+i,
cl4:'cl4'+i,
cl5:'cl5'+i,
cl6:'cl6'+i,
}
list.push(obj)
}
res.status(200),
res.json({list})
// userDao.addUser().then(function(value){
// res.status(200),
// res.json()
// })
})
}
userControl.login = function (app) {
app.post('/user/login',function(req,res){
let data = {token: Math.floor(Date.now() / 1000)}
res.status(200),
res.json(data)
// userDao.addUser().then(function(value){
// res.status(200),
// res.json()
// })
})
}
module.exports=userControl
\ No newline at end of file
var jdbc = require('../jdbc/connection')
var enCryption = require('../tools/enCryption')
var bookDao={}
bookDao.getPage=function(data){
return new Promise(function(resolve,reject){
var sql = 'SELECT * FROM account_book limit '+data.start+','+data.end;
jdbc.query(sql, function (error, results, fields) {
if (error) {
return jdbc.rollback(function() {
throw error
});
}else{
resolve(results)
}
})
})
}
bookDao.add=function(data){
return new Promise(function(resolve,reject){
var sql = 'INSERT INTO account_book VALUES('+null+','+data.uid+',"'+data.bdate+'",'+data.baccount+','+data.bcategory+
',"'+data.bremark+'")'
console.log(sql)
jdbc.query(sql, function (error, results, fields) {
if (error) {
return jdbc.rollback(function() {
throw error
});
}else{
resolve(results)
}
})
})
}
bookDao.delete=function(data){
return new Promise(function(resolve,reject){
jdbc.query('DELETE FROM account_book WHERE bid = '+data.bid, function (error, results, fields) {
if (error) {
return jdbc.rollback(function() {
throw error
});
}else{
resolve(results)
}
})
})
}
bookDao.update=function(data){
return new Promise(function(resolve,reject){
jdbc.query('UPDATE account_book SET uid = ?, bdate = ?, baccount = ? ,bcategory = ?,bremark=? WHERE bid = ?',
[data.uid, data.bdate, data.baccount,data.bcategory,data.bremark, data.bid], function (error, results, fields) {
if (error) {
return jdbc.rollback(function() {
throw error
});
}else{
resolve(results)
}
})
})
}
bookDao.getTotalNum = function(){
return new Promise(function(resolve,reject){
var sql = 'select count(*) as count from account_book';
jdbc.query(sql, function (error, results, fields) {
if (error) {
return jdbc.rollback(function() {
throw error
});
}else{
resolve(results[0].count)
}
})
})
}
module.exports = bookDao
var jdbc = require('../jdbc/connection')
var enCryption = require('../tools/enCryption')
var userDao={}
userDao.getAllUser=function(){
return new Promise(function(resolve,reject){
let results = [];
for(let i=0;i<100;i++){
let obj = {}
obj.name = '李四${i}'
obj.old = 'yes${i}'
results.push(obj)
}
resolve(results);
})
}
// userDao.getAllUser=function(){
// return new Promise(function(resolve,reject){
// var sql = 'SELECT * FROM account_users ORDER BY ' + jdbc.escapeId('uid');
// jdbc.query(sql, function (error, results, fields) {
// if (error) {
// return jdbc.rollback(function() {
// throw error
// });
// }else{
// resolve(results)
// }
// })
// })
// }
module.exports = userDao
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'root',
database : 'baogao',
});
module.exports = connection
\ No newline at end of file
var userLang = {
REGISTSUCCESS:'注册成功',
VERIFICATION_CODE_ERRO:'验证码无效',
EMAIL_ERRO:'邮箱无效',
PASSWORD_NOTUNIFORM:'确认密码不一致',
PASSWORD_TOO_EASY:'密码强度不够'
}
module.exports=userLang
\ No newline at end of file
// import * as con from '/jdbc/connection.js' // var mysql = require('mysql'); // const connection = mysql.createConnection({ // host : 'localhost', // user : 'root', // password : 'zhang901017,./' // }); // var con = require('./jdbc/connection') // con.connect(function(err) { // if (err) { // console.error('error connecting: ' + err.stack); // return; // } // console.log('connected as id ' + con.threadId); // }); var userDao=require('./dao/userDao') // var user={account:'liufei',password:'123456'} userDao.getAllUser(function(data){ console.log(data) })
\ No newline at end of file
{
"name": "mangpig",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"dev": "node register.js",
"start": "node main.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "zzw",
"license": "ISC",
"dependencies": {
"crypto": "^0.0.3",
"express": "^4.15.3",
"mysql": "^2.14.1",
"pm2": "^2.6.1"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-register": "^6.24.1"
}
}
var express=require('express');
var app =express();
var allControl=require('./controller/allControl');
//设置跨域访问
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By",' 3.2.1');
res.header("Content-Type", "application/json;charset=utf-8");
next();
});
allControl.setAllControl(app);
//配置服务端口
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
})
\ No newline at end of file
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'root'
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
\ No newline at end of file
var userDao=require('../dao/bookDao')
var book = {bid:11111,uid:3,bdate:'2017-09-04',baccount:8,bcategory:2,bremark:'rrrrr'}
userDao.add(book,function(data){
console.log(data)
})
\ No newline at end of file
var crypto = require('crypto');
var enCryption={}
enCryption.do=function(str){
var rsa = crypto.createHash('RSA-SHA');//定义加密方式:md5不可逆,此处的md5可以换成任意hash加密的方法名称;
rsa.update(str);
return rsa.digest('hex'); //加密后的值d
}
module.exports=enCryption
function getArrayItems(arr, num) {
var temp_array = new Array();
for (var index in arr) {
temp_array.push(arr[index]);
}
var return_array = new Array();
for (var i = 0; i<num; i++) {
if (temp_array.length>0) {
var arrIndex = Math.floor(Math.random()*temp_array.length);
return_array[i] = temp_array[arrIndex];
temp_array.splice(arrIndex, 1);
} else {
break;
}
}
return return_array;
}
var ArrList=[['gerg','gqeger'],['rrrr',5454],[5,64,6456,5,6],[6,5,8,7,8,7],[888,88888777]];
function test(key){
let cont=0;
for(let i=0;i<10000;i++){
let res = getArrayItems(ArrList,1);
if(res[0][0]==='gerg'){
cont++;
}
}
console.log(cont)
}
\ No newline at end of file
function getArrayItems(arr, num) {
//新建一个数组,将传入的数组复制过来,用于运算,而不要直接操作传入的数组;
var temp_array = new Array();
for (var index in arr) {
temp_array.push(arr[index]);
}
//取出的数值项,保存在此数组
var return_array = new Array();
for (var i = 0; i<num; i++) {
//判断如果数组还有可以取出的元素,以防下标越界
if (temp_array.length>0) {
//在数组中产生一个随机索引
var arrIndex = Math.floor(Math.random()*temp_array.length);
//将此随机索引的对应的数组元素值复制出来
return_array[i] = temp_array[arrIndex];
//然后删掉此索引的数组元素,这时候temp_array变为新的数组
temp_array.splice(arrIndex, 1);
} else {
//数组中数据项取完后,退出循环,比如数组本来只有10项,但要求取出20项.
break;
}
}
return return_array;
}
//测试
var ArrList=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33];
alert(getArrayItems(ArrList,6));
\ No newline at end of file
<template>
<div id="app">
<router-view></router-view>
<router-view/>
</div>
</template>
<script>
import { mapActions } from 'vuex'
export default {
components: {
},
created () {
this.$store.dispatch('initData')
}
name: 'App',
created() {
// this.$store.dispatch('SetImgToken')
},
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
body .el-table th.gutter{
display: table-cell!important;
}
<style lang="stylus" scoped>
#app
display: flex
margin: 20px auto
width: 1260px
background-color: #fff
.sidebar
width: 60px
height: 800px
background: #2b2c2f
.main
flex: 1
height: 800px
background: #f2f2f2
.tarbar
flex: 2
width:800px;
height: 800px;
</style>
.app-container{
margin:10px 5px;
.container-header{
margin:40px 0;
button{
float:right;
}
}
}
.step-panel{
padding-top:5px;
.step-info{
margin-left:90px;
}
div{
float:left;
}
>div:nth-child(1){
width:100px;
color:#409eff;
}
>div:nth-child(2){
font-size:20px;
font-weight:800;
position:relative;
top:-16px;
width:500px;
button{
margin:10px;
}
}
position: relative;
left: 40px;
height: 150px;
}
.step-main{
position:absolute;
margin-left:190px;
}
.el-form-item.is-error .el-input__inner, .el-form-item.is-error .el-input__inner:focus, .el-form-item.is-error .el-textarea__inner, .el-form-item.is-error .el-textarea__inner:focus, .el-message-box__input input.invalid, .el-message-box__input input.invalid:focus{
border-color: #dcdfe6!important;
}
</style>
\ No newline at end of file
......@@ -6,15 +6,14 @@
</header>
<div class="navbar" @click="clearSearch">
<router-link to="/main/chat" class="icon iconfont icon-msg" ></router-link>
<router-link to="/main/friend" class="icon iconfont icon-friend"></router-link>
<router-link to="/main/my" class="icon iconfont icon-collection"></router-link>
<!-- <router-link to="/main/my" class="icon iconfont icon-collection"></router-link> -->
</div>
<footer>
<i class="icon iconfont icon-more" @click="accountFlag=!accountFlag"></i>
</footer>
<div v-if="accountFlag" style="width: 100%;height: 100%;position: fixed;top: 0;right: 0;" @click="accountFlag=!accountFlag"></div>
<div class="tool-panel" v-if="accountFlag">
<div><span class="sdsd">切换账号</span></div>
<div @click="logout"><span class="sdsd">切换账号</span></div>
<div @click="logout"><span class="sdsd">退出登录</span></div>
</div>
</div>
......@@ -38,7 +37,7 @@ export default {
this.$store.dispatch('search', '')
},
logout(){
this.$confirm('确定要退出ERP系统吗?', '提示', {
this.$confirm('确定要此操作吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
......@@ -47,6 +46,7 @@ export default {
type: 'success',
message: '已退出!'
});
window.location.href="/"
}).catch(() => {
// this.$message({
// type: 'info',
......
......@@ -79,7 +79,7 @@ export default {
warn: false,
showEmoji: false,
dialogVisible:false,
tempList:[],
tempList:null,
value7: ''
};
},
......@@ -167,7 +167,7 @@ export default {
name:'随机转换'
}]
for(let r of obj.customerServiceBos){
if(r.customerSessionBo&&r.customerSessionBo.userState!='40'){
if(r.customerSessionBo&&r.customerSessionBo.online=='Y'&&r.customerSessionBo.userState!='40'){
chis.push({
type:2,
toRoleId:obj.roleBo.roleId,
......
import Vue from 'vue'
import SvgIcon from '@/components/SvgIcon' // svg组件
// register globally
Vue.component('svg-icon', SvgIcon)
const requireAll = requireContext => requireContext.keys().map(requireContext)
const req = require.context('./svg', false, /\.svg$/)
requireAll(req)
<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><path d="M96.258 57.462h31.421C124.794 27.323 100.426 2.956 70.287.07v31.422a32.856 32.856 0 0 1 25.971 25.97zm-38.796-25.97V.07C27.323 2.956 2.956 27.323.07 57.462h31.422a32.856 32.856 0 0 1 25.97-25.97zm12.825 64.766v31.421c30.46-2.885 54.507-27.253 57.713-57.712H96.579c-2.886 13.466-13.146 23.726-26.292 26.291zM31.492 70.287H.07c2.886 30.46 27.253 54.507 57.713 57.713V96.579c-13.466-2.886-23.726-13.146-26.291-26.292z"/></svg>
\ No newline at end of file
<svg width="128" height="64" xmlns="http://www.w3.org/2000/svg"><path d="M127.072 7.994c1.37-2.208.914-5.152-.914-6.87-2.056-1.717-4.797-1.226-6.396.982-.229.245-25.586 32.382-55.74 32.382-29.24 0-55.74-32.382-55.968-32.627-1.6-1.963-4.57-2.208-6.397-.49C-.17 3.086-.399 6.275 1.2 8.238c.457.736 5.94 7.36 14.62 14.72L4.17 35.96c-1.828 1.963-1.6 5.152.228 6.87.457.98 1.6 1.471 2.742 1.471s2.284-.49 3.198-1.472l12.564-13.983c5.94 4.416 13.021 8.587 20.788 11.53l-4.797 17.418c-.685 2.699.686 5.397 3.198 6.133h1.37c2.057 0 3.884-1.472 4.341-3.68L52.6 42.83c3.655.736 7.538 1.227 11.422 1.227 3.883 0 7.767-.49 11.422-1.227l4.797 17.173c.457 2.208 2.513 3.68 4.34 3.68.457 0 .914 0 1.143-.246 2.513-.736 3.883-3.434 3.198-6.133l-4.797-17.172c7.767-2.944 14.848-7.114 20.788-11.53l12.336 13.738c.913.981 2.056 1.472 3.198 1.472s2.284-.49 3.198-1.472c1.828-1.963 1.828-4.906.228-6.87l-11.65-13.001c9.366-7.36 14.849-14.474 14.849-14.474z"/></svg>
\ No newline at end of file
<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><path d="M84.068 23.784c-1.02 0-1.877-.32-2.572-.96a8.588 8.588 0 0 1-1.738-2.237 11.524 11.524 0 0 1-1.042-2.621c-.232-.895-.348-1.641-.348-2.238V0h.278c.834 0 1.622.085 2.363.256.742.17 1.645.575 2.711 1.214 1.066.64 2.363 1.535 3.892 2.686 1.53 1.15 3.453 2.664 5.77 4.54 2.502 2.045 4.494 3.771 5.977 5.178 1.483 1.406 2.618 2.6 3.406 3.58.787.98 1.274 1.812 1.46 2.494.185.682.277 1.278.277 1.79v2.046H84.068zM127.3 84.01c.278.682.464 1.535.556 2.558.093 1.023-.37 2.003-1.39 2.94-.463.427-.88.832-1.25 1.215-.372.384-.696.704-.974.96a6.69 6.69 0 0 1-.973.767l-11.816-10.741a44.331 44.331 0 0 0 1.877-1.535 31.028 31.028 0 0 1 1.737-1.406c1.112-.938 2.317-1.343 3.615-1.215 1.297.128 2.363.405 3.197.83.927.427 1.923 1.173 2.989 2.239 1.065 1.065 1.876 2.195 2.432 3.388zM78.23 95.902c2.038 0 3.752-.511 5.143-1.534l-26.969 25.83H18.037c-1.761 0-3.684-.47-5.77-1.407a24.549 24.549 0 0 1-5.838-3.709 21.373 21.373 0 0 1-4.518-5.306c-1.204-2.003-1.807-4.07-1.807-6.202V16.495c0-1.79.44-3.665 1.32-5.626A18.41 18.41 0 0 1 5.04 5.562a21.798 21.798 0 0 1 5.213-3.964C12.198.533 14.237 0 16.37 0h53.24v15.984c0 1.62.278 3.367.834 5.242a16.704 16.704 0 0 0 2.572 5.179c1.159 1.577 2.665 2.898 4.518 3.964 1.853 1.066 4.078 1.598 6.673 1.598h20.295v42.325L85.458 92.45c1.02-1.364 1.529-2.856 1.529-4.476 0-2.216-.857-4.113-2.572-5.69-1.714-1.577-3.776-2.366-6.186-2.366H26.1c-2.409 0-4.448.789-6.116 2.366-1.668 1.577-2.502 3.474-2.502 5.69 0 2.217.834 4.092 2.502 5.626 1.668 1.535 3.707 2.302 6.117 2.302h52.13zM26.1 47.951c-2.41 0-4.449.789-6.117 2.366-1.668 1.577-2.502 3.473-2.502 5.69 0 2.216.834 4.092 2.502 5.626 1.668 1.534 3.707 2.302 6.117 2.302h52.13c2.409 0 4.47-.768 6.185-2.302 1.715-1.534 2.572-3.41 2.572-5.626 0-2.217-.857-4.113-2.572-5.69-1.714-1.577-3.776-2.366-6.186-2.366H26.1zm52.407 64.063l1.807-1.663 3.476-3.196a479.75 479.75 0 0 0 4.587-4.284 500.757 500.757 0 0 1 5.004-4.667c3.985-3.666 8.48-7.758 13.485-12.276l11.677 10.741-13.485 12.404-5.004 4.603-4.587 4.22a179.46 179.46 0 0 0-3.267 3.068c-.88.853-1.367 1.322-1.46 1.407-.463.341-.973.703-1.529 1.087-.556.383-1.112.703-1.668.959-.556.256-1.413.575-2.572.959a83.5 83.5 0 0 1-3.545 1.087 72.2 72.2 0 0 1-3.475.895c-1.112.256-1.946.426-2.502.511-1.112.17-1.854.043-2.224-.383-.371-.426-.464-1.151-.278-2.174.092-.511.278-1.279.556-2.302.278-1.023.602-2.067.973-3.132l1.042-3.005c.325-.938.58-1.577.765-1.918a10.157 10.157 0 0 1 2.224-2.941z"/></svg>
\ No newline at end of file
<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><g><path d="M115.625 127.937H.063V12.375h57.781v12.374H12.438v90.813h90.813V70.156h12.374z"/><path d="M116.426 2.821l8.753 8.753-56.734 56.734-8.753-8.745z"/><path d="M127.893 37.982h-12.375V12.375H88.706V0h39.187z"/></g></svg>
\ No newline at end of file
<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><path d="M.002 9.2c0 5.044 3.58 9.133 7.998 9.133 4.417 0 7.997-4.089 7.997-9.133 0-5.043-3.58-9.132-7.997-9.132S.002 4.157.002 9.2zM31.997.066h95.981V18.33H31.997V.066zm0 45.669c0 5.044 3.58 9.132 7.998 9.132 4.417 0 7.997-4.088 7.997-9.132 0-3.263-1.524-6.278-3.998-7.91-2.475-1.63-5.524-1.63-7.998 0-2.475 1.632-4 4.647-4 7.91zM63.992 36.6h63.986v18.265H63.992V36.6zm-31.995 82.2c0 5.043 3.58 9.132 7.998 9.132 4.417 0 7.997-4.089 7.997-9.132 0-5.044-3.58-9.133-7.997-9.133s-7.998 4.089-7.998 9.133zm31.995-9.131h63.986v18.265H63.992V109.67zm0-27.404c0 5.044 3.58 9.133 7.998 9.133 4.417 0 7.997-4.089 7.997-9.133 0-3.263-1.524-6.277-3.998-7.909-2.475-1.631-5.524-1.631-7.998 0-2.475 1.632-4 4.646-4 7.91zm31.995-9.13h31.991V91.4H95.987V73.135z"/></svg>
\ No newline at end of file
<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><path d="M108.8 44.322H89.6v-5.36c0-9.04-3.308-24.163-25.6-24.163-23.145 0-25.6 16.881-25.6 24.162v5.361H19.2v-5.36C19.2 15.281 36.798 0 64 0c27.202 0 44.8 15.281 44.8 38.961v5.361zm-32 39.356c0-5.44-5.763-9.832-12.8-9.832-7.037 0-12.8 4.392-12.8 9.832 0 3.682 2.567 6.808 6.407 8.477v11.205c0 2.718 2.875 4.962 6.4 4.962 3.524 0 6.4-2.244 6.4-4.962V92.155c3.833-1.669 6.393-4.795 6.393-8.477zM128 64v49.201c0 8.158-8.645 14.799-19.2 14.799H19.2C8.651 128 0 121.359 0 113.201V64c0-8.153 8.645-14.799 19.2-14.799h89.6c10.555 0 19.2 6.646 19.2 14.799z"/></svg>
\ No newline at end of file
<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><g><path d="M.006.064h127.988v31.104H.006V.064zm0 38.016h38.396v41.472H.006V38.08zm0 48.384h38.396v41.472H.006V86.464zM44.802 38.08h38.396v41.472H44.802V38.08zm0 48.384h38.396v41.472H44.802V86.464zM89.598 38.08h38.396v41.472H89.598zm0 48.384h38.396v41.472H89.598z"/><path d="M.006.064h127.988v31.104H.006V.064zm0 38.016h38.396v41.472H.006V38.08zm0 48.384h38.396v41.472H.006V86.464zM44.802 38.08h38.396v41.472H44.802V38.08zm0 48.384h38.396v41.472H44.802V86.464zM89.598 38.08h38.396v41.472H89.598zm0 48.384h38.396v41.472H89.598z"/></g></svg>
\ No newline at end of file
<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><path d="M126.713 90.023c.858.985 1.287 2.134 1.287 3.447v29.553c0 1.423-.429 2.6-1.287 3.53-.858.93-1.907 1.395-3.146 1.395H97.824c-1.145 0-2.146-.465-3.004-1.395-.858-.93-1.287-2.107-1.287-3.53V93.47c0-.875.19-1.696.572-2.462.382-.766.906-1.368 1.573-1.806a3.84 3.84 0 0 1 2.146-.657h9.725V69.007a3.84 3.84 0 0 0-.43-1.806 3.569 3.569 0 0 0-1.143-1.313 2.714 2.714 0 0 0-1.573-.492h-36.47v23.149h9.725c1.144 0 2.145.492 3.004 1.478.858.985 1.287 2.134 1.287 3.447v29.553c0 .876-.191 1.696-.573 2.463-.38.766-.905 1.368-1.573 1.806a3.84 3.84 0 0 1-2.145.656H51.915a3.84 3.84 0 0 1-2.145-.656c-.668-.438-1.216-1.04-1.645-1.806a4.96 4.96 0 0 1-.644-2.463V93.47c0-1.313.43-2.462 1.288-3.447.858-.986 1.907-1.478 3.146-1.478h9.582v-23.15h-37.9c-.953 0-1.74.356-2.359 1.068-.62.711-.93 1.56-.93 2.544v19.538h9.726c1.239 0 2.264.492 3.074 1.478.81.985 1.216 2.134 1.216 3.447v29.553c0 1.423-.405 2.6-1.216 3.53-.81.93-1.835 1.395-3.074 1.395H4.29c-.476 0-.93-.082-1.358-.246a4.1 4.1 0 0 1-1.144-.657 4.658 4.658 0 0 1-.93-1.067 5.186 5.186 0 0 1-.643-1.395 5.566 5.566 0 0 1-.215-1.56V93.47c0-.437.048-.875.143-1.313a3.95 3.95 0 0 1 .429-1.15c.19-.328.429-.656.715-.984.286-.329.572-.602.858-.821.286-.22.62-.383 1.001-.493.382-.11.763-.164 1.144-.164h9.726V61.619c0-.985.31-1.833.93-2.544.619-.712 1.358-1.068 2.216-1.068h44.335V39.62h-9.582c-1.24 0-2.288-.492-3.146-1.477a5.09 5.09 0 0 1-1.287-3.448V5.14c0-1.423.429-2.627 1.287-3.612.858-.985 1.907-1.477 3.146-1.477h25.743c.763 0 1.478.246 2.145.739a5.17 5.17 0 0 1 1.573 1.888c.382.766.573 1.587.573 2.462v29.553c0 1.313-.43 2.463-1.287 3.448-.859.985-1.86 1.477-3.004 1.477h-9.725v18.389h42.762c.954 0 1.74.355 2.36 1.067.62.711.93 1.56.93 2.545v26.925h9.582c1.239 0 2.288.492 3.146 1.478z"/></svg>
\ No newline at end of file
<svg width="130" height="130" xmlns="http://www.w3.org/2000/svg"><path d="M63.444 64.996c20.633 0 37.359-14.308 37.359-31.953 0-17.649-16.726-31.952-37.359-31.952-20.631 0-37.36 14.303-37.358 31.952 0 17.645 16.727 31.953 37.359 31.953zM80.57 75.65H49.434c-26.652 0-48.26 18.477-48.26 41.27v2.664c0 9.316 21.608 9.325 48.26 9.325H80.57c26.649 0 48.256-.344 48.256-9.325v-2.663c0-22.794-21.605-41.271-48.256-41.271z" stroke="#979797"/></svg>
\ No newline at end of file
# replace default config
# multipass: true
# full: true
plugins:
# - name
#
# or:
# - name: false
# - name: true
#
# or:
# - name:
# param1: 1
# param2: 2
- removeAttrs:
attrs:
- 'fill'
- 'fill-rule'
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
// import 'normalize.css/normalize.css' // A modern alternative to CSS resets
// import ElementUI from 'element-ui'
// import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n
// import '@/styles/index.scss' // global css
import App from './App'
import router from './router'
import store from './store'
// import '@/permission' // permission control
import VuePreview from 'vue-preview'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// defalut install
// Vue.use(VuePreview)
Vue.config.productionTip = false
Vue.config.devtools = true
// with parameters install
Vue.use(VuePreview, {
mainClass: 'pswp--minimal--dark',
barsSize: {top: 0, bottom: 0},
captionEl: false,
fullscreenEl: false,
shareEl: false,
bgOpacity: 0.85,
tapToClose: true,
tapToToggleControls: false
})
Vue.use(ElementUI)
/* eslint-disable no-new */
const vm = new Vue({
Vue.config.productionTip = false
new Vue({
el: '#app',
router,
store,
template: '<App/>',
components: { App }
render: h => h(App)
})
import router from './router'
import store from './store'
import NProgress from 'nprogress' // Progress 进度条
import 'nprogress/nprogress.css'// Progress 进度条样式
import { Message } from 'element-ui'
import { getToken } from '@/utils/auth' // 验权
const whiteList = ['/login'] // 不重定向白名单
router.beforeEach((to, from, next) => {
NProgress.start()
if(to.path.indexOf('mobile')!=-1){
next()
} else {
if (getToken()) {
if (to.path === '/login') {
store.dispatch('SetImgToken')
next({ path: '/' })
NProgress.done() // if current page is dashboard will not trigger afterEach hook, so manually handle it
} else {
if (!store.getters.user) {
store.dispatch('GetInfo').then(res => { // 拉取用户信息
store.dispatch('SetImgToken')
next()
}).catch((err) => {
store.dispatch('FedLogOut').then(() => {
Message.error(err || 'Verification failed, please login again')
next({ path: '/' })
})
})
} else {
next()
}
}
} else {
if (whiteList.indexOf(to.path) !== -1) {
next()
} else {
next(`/login?redirect=${to.path}`) // 否则全部重定向到登录页
NProgress.done()
}
}
}
})
router.afterEach(() => {
NProgress.done() // 结束Progress
})
......@@ -5,23 +5,29 @@ Vue.use(Router)
const router = new Router({
routes: [
{
path: '/',
name:'login',
component: () => import('@/page/login'),
},
{
path: '/login',
component: require('@/page/login')
name:'login',
component: () => import('@/page/login'),
},
{ path: '/main', component: require('@/page/main'),
{ path: '/main', component:()=> import('@/page/main'),
children: [
{
path: 'chat',
component: require('@/page/main/chat/chat.vue')
component:()=> import('@/page/main/chat/chat.vue')
},
{
path: 'friend',
component: require('@/page/main/friend/friend.vue')
component:()=> import('@/page/main/friend/friend.vue')
},
{
path: 'my',
component: require('@/page/main/friend/friend.vue')
component:()=> import('@/page/main/friend/friend.vue')
}
]
}
......
This diff is collapsed.
This diff is collapsed.
import * as service from '@/service'
import io from 'socket.io-client';
// import io from 'socket.io-client';
import apiUrl from '@/service/api.js'
import router from '@/router'
import { compare } from '@/utils/tools'
import { setToken, getToken, emojis } from '@/utils/auth'
import { setToken, getToken, setUserId, getUserId, emojis } from '@/utils/auth'
import { MessageBox, Alert } from 'element-ui'
import { panelStatus } from '@/utils/common'
import Vue from 'vue'
let isSend = false;
......@@ -30,6 +32,7 @@ const user = {
mutations: {
USER_LOGIN(state, value){
setToken(value.token)
setUserId(value.customerId)
state.userInfo = value
},
CHANGE_CONVERSATIONPANEL(state, value){
......@@ -163,8 +166,14 @@ const user = {
}).on('connect_error', () => {
console.log("connect_error")
}).on('disconnect', () => {
// if (Common.wsClient) Common.wsClient = null
console.log("disconnect")
MessageBox('连接被迫断开,重新登录!', '提示', {
confirmButtonText: '确定',
type: 'warning'
}).then(() => {
window.location.href="/"
}).catch(() => {
console.log(2)
});
}).on('reconnect_attempt', () => {
// if (Common.wsClient) Common.wsClient.io.opts.transports = ['polling', 'websocket'];
})
......@@ -199,7 +208,8 @@ const user = {
}
})
.on('conversations/show', (data, callback) => {
let { tempChatlist, userInfo: { customerId } } = state
let customerId = getUserId()
let { tempChatlist } = state
if(data!=null&&data.userBo.primaryBindCustomerId!= customerId){
let temp = null
let isNew = true
......@@ -319,7 +329,8 @@ const user = {
commit('SEND_MESSAGE', [temp])
},
getTranster({ commit, state }, prams){
let { chartings, selectId, userInfo: { customerId } } = state
let customerId = getUserId()
let { chartings, selectId } = state
let customerdeId =null
for(let tob of chartings){
if(tob.id==selectId){
......@@ -342,7 +353,8 @@ const user = {
})
},
toTranster({ commit, state }, prams){
let { chartings, chatlist, selectId, userInfo: { customerId } } = state
let customerId = getUserId()
let { chartings, chatlist, selectId } = state
let tempUserId =null
for(let tob of chartings){
if(tob.id==selectId){
......@@ -370,7 +382,8 @@ const user = {
})
},
closeTake({ commit, state }, prams){
let { chartings, chatlist, selectId, userInfo: { customerId } } = state
let customerId = getUserId()
let { chartings, chatlist, selectId } = state
let customerdeId =null
for(let tob of chartings){
if(tob.id==selectId){
......
//to reset element-ui default css
.el-upload {
input[type="file"] {
display: none !important;
}
}
.el-upload__input {
display: none;
}
//暂时性解决diolag 问题 https://github.com/ElemeFE/element/issues/2461
.el-dialog {
transform: none;
left: 0;
position: relative;
margin: 0 auto;
.dialog-footer{
text-align: right;
}
.el-icon-close{
color:#ffffff;
}
.el-dialog__header{
background-color: #409eff;
.el-dialog__title{
color:#ffffff;
}
}
}
//element ui upload
.upload-container {
.el-upload {
width: 100%;
.el-upload-dragger {
width: 100%;
height: 200px;
}
}
}
@import './variables.scss';
@import './mixin.scss';
@import './transition.scss';
@import './element-ui.scss';
@import './sidebar.scss';
body {
height: 100%;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;
}
label {
font-weight: 700;
}
html {
height: 100%;
box-sizing: border-box;
}
#app{
height: 100%;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
a,
a:focus,
a:hover {
cursor: pointer;
color: inherit;
outline: none;
text-decoration: none;
}
div:focus{
outline: none;
}
a:focus,
a:active {
outline: none;
}
a,
a:focus,
a:hover {
cursor: pointer;
color: inherit;
text-decoration: none;
}
.clearfix {
&:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
}
//main-container全局样式
.app-main{
min-height: 100%
}
.app-container {
padding: 20px;
}
@mixin clearfix {
&:after {
content: "";
display: table;
clear: both;
}
}
@mixin scrollBar {
&::-webkit-scrollbar-track-piece {
background: #d3dce6;
}
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-thumb {
background: #99a9bf;
border-radius: 20px;
}
}
@mixin relative {
position: relative;
width: 100%;
height: 100%;
}
#app {
// 主体区域
.main-container {
min-height: 100%;
transition: margin-left .28s;
margin-left: 180px;
position: relative;
}
// 侧边栏
.sidebar-container {
transition: width 0.28s;
width: 180px !important;
height: 100%;
position: fixed;
font-size: 0px;
top: 0;
bottom: 0;
left: 0;
z-index: 1001;
overflow: hidden;
//reset element-ui css
.horizontal-collapse-transition {
transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out;
}
.el-scrollbar__bar.is-vertical{
right: 0px;
}
.scrollbar-wrapper {
overflow-x: hidden!important;
.el-scrollbar__view {
height: 100%;
}
}
.is-horizontal {
display: none;
}
a {
display: inline-block;
width: 100%;
overflow: hidden;
}
.svg-icon {
margin-right: 16px;
}
.el-menu {
border: none;
height: 100%;
width: 100% !important;
}
.is-active > .el-submenu__title{
color: #f4f4f5!important;
}
}
.hideSidebar {
.sidebar-container {
width: 36px !important;
}
.main-container {
margin-left: 36px;
}
.submenu-title-noDropdown {
padding-left: 10px !important;
position: relative;
.el-tooltip {
padding: 0 10px !important;
}
}
.el-submenu {
overflow: hidden;
&>.el-submenu__title {
padding-left: 10px !important;
.el-submenu__icon-arrow {
display: none;
}
}
}
.el-menu--collapse {
.el-submenu {
&>.el-submenu__title {
&>span {
height: 0;
width: 0;
overflow: hidden;
visibility: hidden;
display: inline-block;
}
}
}
}
}
.sidebar-container .nest-menu .el-submenu>.el-submenu__title,
.sidebar-container .el-submenu .el-menu-item {
min-width: 180px !important;
background-color: $subMenuBg !important;
&:hover {
background-color: $menuHover !important;
}
}
.el-menu--collapse .el-menu .el-submenu {
min-width: 180px !important;
}
//适配移动端
.mobile {
.main-container {
margin-left: 0px;
}
.sidebar-container {
transition: transform .28s;
width: 180px !important;
}
&.hideSidebar {
.sidebar-container {
transition-duration: 0.3s;
transform: translate3d(-180px, 0, 0);
}
}
}
.withoutAnimation {
.main-container,
.sidebar-container {
transition: none;
}
}
}
.el-menu--vertical{
& >.el-menu{
.svg-icon{
margin-right: 16px;
}
}
}
//globl transition css
/*fade*/
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.28s;
}
.fade-enter,
.fade-leave-active {
opacity: 0;
}
/*fade-transform*/
.fade-transform-leave-active,
.fade-transform-enter-active {
transition: all .5s;
}
.fade-transform-enter {
opacity: 0;
transform: translateX(-30px);
}
.fade-transform-leave-to {
opacity: 0;
transform: translateX(30px);
}
/*fade*/
.breadcrumb-enter-active,
.breadcrumb-leave-active {
transition: all .5s;
}
.breadcrumb-enter,
.breadcrumb-leave-active {
opacity: 0;
transform: translateX(20px);
}
.breadcrumb-move {
transition: all .5s;
}
.breadcrumb-leave-active {
position: absolute;
}
//sidebar
$menuBg:#304156;
$subMenuBg:#1f2d3d;
$menuHover:#001528;
import Cookies from 'js-cookie'
const TokenKey = 'token'
const TokenChenzhenKey = 'tokenChenzhen'
const userIdKey = 'userId'
const commercialIdKey = 'commercialId'
......@@ -12,6 +13,14 @@ export function setToken(token) {
return Cookies.set(TokenKey, token)
}
export function getTokenChenzhen() {
return Cookies.get(TokenChenzhenKey)
}
export function setTokenChenzhen(token) {
return Cookies.set(TokenChenzhenKey, token)
}
export function getUserId() {
return Cookies.get(userIdKey)
}
......
This diff is collapsed.
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