canvas-color-disc 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.babelrc ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "presets": [
3
+ ["env", {
4
+ "modules": false,
5
+ "targets": {
6
+ "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7
+ }
8
+ }],
9
+ "stage-2"
10
+ ],
11
+ "plugins": ["transform-vue-jsx", "transform-runtime"],
12
+ "env": {
13
+ "test": {
14
+ "presets": ["env", "stage-2"],
15
+ "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]
16
+ }
17
+ }
18
+ }
package/.editorconfig ADDED
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 4
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
package/.eslintignore ADDED
@@ -0,0 +1,5 @@
1
+ /build/
2
+ /config/
3
+ /dist/
4
+ /*.js
5
+ /test/unit/coverage/
package/.eslintrc.js ADDED
@@ -0,0 +1,61 @@
1
+ // https://eslint.org/docs/user-guide/configuring
2
+
3
+ module.exports = {
4
+ root: true,
5
+ parserOptions: {
6
+ parser: 'babel-eslint'
7
+ },
8
+ env: {
9
+ browser: true,
10
+ },
11
+ extends: [
12
+ // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
13
+ // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
14
+ 'plugin:vue/essential',
15
+ // https://github.com/standard/standard/blob/master/docs/RULES-en.md
16
+ // 'standard'
17
+ ],
18
+ // required to lint *.vue files
19
+ plugins: [
20
+ 'vue'
21
+ ],
22
+ // add your custom rules here
23
+ rules: {
24
+ // allow async-await
25
+ // allow debugger during development
26
+ "vue/html-indent": ["error", 4, {
27
+ "attribute": 1,
28
+ "baseIndent": 1,
29
+ "closeBracket": 0,
30
+ "alignAttributesVertically": true,
31
+ "ignores": []
32
+ }],
33
+ "vue/max-attributes-per-line": ["error", {
34
+ "singleline": 3,
35
+ "multiline": {
36
+ "max": 5,
37
+ "allowFirstLine": false
38
+ }
39
+ }],
40
+ 'indent': [2, 4], // 缩进4
41
+ 'comma-dangle': 0, // 对象字面量项尾不能有逗号
42
+ 'new-cap': 0, // 函数名首行大写必须使用new方式调用,首行小写必须用不带new方式调用
43
+ 'no-console': 0,// 禁止使用console
44
+ 'no-extra-semi': 0, // 禁止多余的冒号
45
+ 'no-new': 0, // 禁止在使用new构造一个实例后不赋值
46
+ 'no-undef': 0, // 不能有未定义的变量
47
+ 'quote-props': 0, // 属性名不限制
48
+ "quotes": [0, "double"],
49
+ 'space-before-function-paren': [2, 'never'], // 函数定义时括号前面要不要有空格
50
+ 'semi': [2, 'never'], // 语句强制分号结尾
51
+ 'no-unused-expressions': 'off', // 禁止无用的表达式
52
+ 'generator-star-spacing': 'off', // 生成器函数*的前后空格
53
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', // 禁止使用debugger
54
+ "vue/html-quotes": ["error", "double"], // html内使用双引号
55
+ "vue/eqeqeq": 2,
56
+ "no-empty": 2, // 禁止出现空语句块
57
+ "no-alert": 0,//禁止使用alert confirm prompt
58
+ "no-array-constructor": 2,//禁止使用数组构造器
59
+ "no-eq-null": 2,//禁止对null使用==或!=运算符
60
+ }
61
+ }
package/.postcssrc.js ADDED
@@ -0,0 +1,10 @@
1
+ // https://github.com/michael-ciniawsky/postcss-load-config
2
+
3
+ module.exports = {
4
+ "plugins": {
5
+ "postcss-import": {},
6
+ "postcss-url": {},
7
+ // to edit target browsers: use "browserslist" field in package.json
8
+ "autoprefixer": {}
9
+ }
10
+ }
package/build/build.js ADDED
@@ -0,0 +1,40 @@
1
+ 'use strict'
2
+ require('./check-versions')()
3
+
4
+ process.env.NODE_ENV = 'production'
5
+
6
+ const ora = require('ora')
7
+ const rm = require('rimraf')
8
+ const path = require('path')
9
+ const chalk = require('chalk')
10
+ const webpack = require('webpack')
11
+ const config = require('../config')
12
+ const webpackConfig = require('./webpack.prod.conf')
13
+ const spinner = ora('building for production...')
14
+ spinner.start()
15
+
16
+ rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
17
+ if (err) throw err
18
+ webpack(webpackConfig, (err, stats) => {
19
+ spinner.stop()
20
+ if (err) throw err
21
+ process.stdout.write(stats.toString({
22
+ colors: true,
23
+ modules: false,
24
+ children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
25
+ chunks: false,
26
+ chunkModules: false
27
+ }) + '\n\n')
28
+
29
+ if (stats.hasErrors()) {
30
+ console.log(chalk.red(' Build failed with errors.\n'))
31
+ process.exit(1)
32
+ }
33
+
34
+ console.log(chalk.cyan(' Build complete.\n'))
35
+ console.log(chalk.yellow(
36
+ ' Tip: built files are meant to be served over an HTTP server.\n' +
37
+ ' Opening index.html over file:// won\'t work.\n'
38
+ ))
39
+ })
40
+ })
@@ -0,0 +1,54 @@
1
+ 'use strict'
2
+ const chalk = require('chalk')
3
+ const semver = require('semver')
4
+ const packageConfig = require('../package.json')
5
+ const shell = require('shelljs')
6
+
7
+ function exec (cmd) {
8
+ return require('child_process').execSync(cmd).toString().trim()
9
+ }
10
+
11
+ const versionRequirements = [
12
+ {
13
+ name: 'node',
14
+ currentVersion: semver.clean(process.version),
15
+ versionRequirement: packageConfig.engines.node
16
+ }
17
+ ]
18
+
19
+ if (shell.which('npm')) {
20
+ versionRequirements.push({
21
+ name: 'npm',
22
+ currentVersion: exec('npm --version'),
23
+ versionRequirement: packageConfig.engines.npm
24
+ })
25
+ }
26
+
27
+ module.exports = function () {
28
+ const warnings = []
29
+
30
+ for (let i = 0; i < versionRequirements.length; i++) {
31
+ const mod = versionRequirements[i]
32
+
33
+ if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
34
+ warnings.push(mod.name + ': ' +
35
+ chalk.red(mod.currentVersion) + ' should be ' +
36
+ chalk.green(mod.versionRequirement)
37
+ )
38
+ }
39
+ }
40
+
41
+ if (warnings.length) {
42
+ console.log('')
43
+ console.log(chalk.yellow('To use this template, you must update following to modules:'))
44
+ console.log()
45
+
46
+ for (let i = 0; i < warnings.length; i++) {
47
+ const warning = warnings[i]
48
+ console.log(' ' + warning)
49
+ }
50
+
51
+ console.log()
52
+ process.exit(1)
53
+ }
54
+ }
package/build/logo.png ADDED
Binary file
package/build/utils.js ADDED
@@ -0,0 +1,102 @@
1
+ 'use strict'
2
+ const path = require('path')
3
+ const config = require('../config')
4
+ const ExtractTextPlugin = require('extract-text-webpack-plugin')
5
+ const packageConfig = require('../package.json')
6
+
7
+ exports.assetsPath = function (_path) {
8
+ const assetsSubDirectory = process.env.NODE_ENV === 'production'
9
+ ? config.build.assetsSubDirectory
10
+ : config.dev.assetsSubDirectory
11
+
12
+ return path.posix.join(assetsSubDirectory, _path)
13
+ }
14
+
15
+ exports.cssLoaders = function (options) {
16
+ options = options || {}
17
+
18
+ const cssLoader = {
19
+ loader: 'css-loader',
20
+ options: {
21
+ sourceMap: options.sourceMap
22
+ }
23
+ }
24
+
25
+ const postcssLoader = {
26
+ loader: 'postcss-loader',
27
+ options: {
28
+ sourceMap: options.sourceMap
29
+ }
30
+ }
31
+
32
+ // generate loader string to be used with extract text plugin
33
+ function generateLoaders (loader, loaderOptions) {
34
+ const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
35
+
36
+ if (loader) {
37
+ loaders.push({
38
+ loader: loader + '-loader',
39
+ options: Object.assign({}, loaderOptions, {
40
+ sourceMap: options.sourceMap
41
+ })
42
+ })
43
+ }
44
+
45
+ // Extract CSS when that option is specified
46
+ // (which is the case during production build)
47
+ if (options.extract) {
48
+ return ExtractTextPlugin.extract({
49
+ use: loaders,
50
+ fallback: 'vue-style-loader',
51
+ publicPath: '../../'
52
+ })
53
+ } else {
54
+ return ['vue-style-loader'].concat(loaders)
55
+ }
56
+ }
57
+
58
+ // https://vue-loader.vuejs.org/en/configurations/extract-css.html
59
+ return {
60
+ css: generateLoaders(),
61
+ postcss: generateLoaders(),
62
+ less: generateLoaders('less'),
63
+ sass: generateLoaders('sass', { indentedSyntax: true }),
64
+ scss: generateLoaders('sass'),
65
+ stylus: generateLoaders('stylus'),
66
+ styl: generateLoaders('stylus')
67
+ }
68
+ }
69
+
70
+ // Generate loaders for standalone style files (outside of .vue)
71
+ exports.styleLoaders = function (options) {
72
+ const output = []
73
+ const loaders = exports.cssLoaders(options)
74
+
75
+ for (const extension in loaders) {
76
+ const loader = loaders[extension]
77
+ output.push({
78
+ test: new RegExp('\\.' + extension + '$'),
79
+ use: loader
80
+ })
81
+ }
82
+
83
+ return output
84
+ }
85
+
86
+ exports.createNotifierCallback = () => {
87
+ const notifier = require('node-notifier')
88
+
89
+ return (severity, errors) => {
90
+ if (severity !== 'error') return
91
+
92
+ const error = errors[0]
93
+ const filename = error.file && error.file.split('!').pop()
94
+
95
+ notifier.notify({
96
+ title: packageConfig.name,
97
+ message: severity + ': ' + error.name,
98
+ subtitle: filename || '',
99
+ icon: path.join(__dirname, 'logo.png')
100
+ })
101
+ }
102
+ }
@@ -0,0 +1,22 @@
1
+ 'use strict'
2
+ const utils = require('./utils')
3
+ const config = require('../config')
4
+ const isProduction = process.env.NODE_ENV === 'production'
5
+ const sourceMapEnabled = isProduction
6
+ ? config.build.productionSourceMap
7
+ : config.dev.cssSourceMap
8
+
9
+ module.exports = {
10
+ loaders: utils.cssLoaders({
11
+ sourceMap: sourceMapEnabled,
12
+ extract: isProduction
13
+ }),
14
+ cssSourceMap: sourceMapEnabled,
15
+ cacheBusting: config.dev.cacheBusting,
16
+ transformToRequire: {
17
+ video: ['src', 'poster'],
18
+ source: 'src',
19
+ img: 'src',
20
+ image: 'xlink:href'
21
+ }
22
+ }
@@ -0,0 +1,104 @@
1
+ /*
2
+ * @Descripttion:
3
+ * @version:
4
+ * @Author: chengzan
5
+ * @Date: 2021-10-16 10:19:46
6
+ * @LastEditors: Please set LastEditors
7
+ * @LastEditTime: 2021-10-16 15:14:47
8
+ */
9
+ 'use strict'
10
+ const path = require('path')
11
+ const utils = require('./utils')
12
+ const config = require('../config')
13
+ const vueLoaderConfig = require('./vue-loader.conf')
14
+ // 执行环境
15
+ const NODE_ENV = process.env.NODE_ENV;
16
+ console.log("-----NODE_ENV===",NODE_ENV);
17
+
18
+ function resolve (dir) {
19
+ return path.join(__dirname, '..', dir)
20
+ }
21
+
22
+ const createLintingRule = () => ({
23
+ test: /\.(js|vue)$/,
24
+ loader: 'eslint-loader',
25
+ enforce: 'pre',
26
+ include: [resolve('src'), resolve('test')],
27
+ options: {
28
+ formatter: require('eslint-friendly-formatter'),
29
+ emitWarning: !config.dev.showEslintErrorsInOverlay
30
+ }
31
+ })
32
+
33
+ module.exports = {
34
+ context: path.resolve(__dirname, '../'),
35
+ entry: NODE_ENV == 'production' ? './src/index.js' : './src/main.js',
36
+ output: {
37
+ path: config.build.assetsRoot,
38
+ filename: 'canvas-color-disc.js',
39
+ library: 'canvas-color-disc',
40
+ libraryTarget: 'umd', // 指定输出格式
41
+ umdNamedDefine: true, // 会对 UMD 的构建过程中的 AMD 模块进行命名。否则就使用匿名的 define
42
+ publicPath: process.env.NODE_ENV === 'production'
43
+ ? config.build.assetsPublicPath
44
+ : config.dev.assetsPublicPath
45
+ },
46
+ resolve: {
47
+ extensions: ['.js', '.vue', '.json'],
48
+ alias: {
49
+ 'vue$': 'vue/dist/vue.esm.js',
50
+ '@': resolve('src'),
51
+ }
52
+ },
53
+ module: {
54
+ rules: [
55
+ ...(config.dev.useEslint ? [createLintingRule()] : []),
56
+ {
57
+ test: /\.vue$/,
58
+ loader: 'vue-loader',
59
+ options: vueLoaderConfig
60
+ },
61
+ {
62
+ test: /\.js$/,
63
+ loader: 'babel-loader',
64
+ include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
65
+ },
66
+ {
67
+ test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
68
+ loader: 'url-loader',
69
+ options: {
70
+ limit: 10000,
71
+ name: utils.assetsPath('img/[name].[hash:7].[ext]')
72
+ }
73
+ },
74
+ {
75
+ test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
76
+ loader: 'url-loader',
77
+ options: {
78
+ limit: 10000,
79
+ name: utils.assetsPath('media/[name].[hash:7].[ext]')
80
+ }
81
+ },
82
+ {
83
+ test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
84
+ loader: 'url-loader',
85
+ options: {
86
+ limit: 10000,
87
+ name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
88
+ }
89
+ }
90
+ ]
91
+ },
92
+ node: {
93
+ // prevent webpack from injecting useless setImmediate polyfill because Vue
94
+ // source contains it (although only uses it if it's native).
95
+ setImmediate: false,
96
+ // prevent webpack from injecting mocks to Node native modules
97
+ // that does not make sense for the client
98
+ dgram: 'empty',
99
+ fs: 'empty',
100
+ net: 'empty',
101
+ tls: 'empty',
102
+ child_process: 'empty'
103
+ }
104
+ }
@@ -0,0 +1,110 @@
1
+ 'use strict'
2
+ const utils = require('./utils')
3
+ const webpack = require('webpack')
4
+ const config = require('../config')
5
+ const merge = require('webpack-merge')
6
+ const path = require('path')
7
+ const baseWebpackConfig = require('./webpack.base.conf')
8
+ const CopyWebpackPlugin = require('copy-webpack-plugin')
9
+ const HtmlWebpackPlugin = require('html-webpack-plugin')
10
+ const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
11
+ const portfinder = require('portfinder')
12
+
13
+ const HOST = process.env.HOST
14
+ const PORT = process.env.PORT && Number(process.env.PORT)
15
+ const devWebpackConfig = merge(baseWebpackConfig, {
16
+ module: {
17
+ rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
18
+ },
19
+ // cheap-module-eval-source-map is faster for development
20
+ devtool: config.dev.devtool,
21
+
22
+ // these devServer options should be customized in /config/index.js
23
+ devServer: {
24
+ proxy: {
25
+ '/api': {
26
+ target: 'http://dev2.unisiot.com:53804',// 要跨域的域名
27
+ // target: 'http://192.168.33.58:53339',// 要跨域的域名
28
+ changeOrigin: true, // 是否开启跨域
29
+ pathRewrite:{
30
+ '^/api':'/'
31
+ }
32
+ },
33
+ '/file': {
34
+ target: 'https://dev2filecenter.unisiot.com/putFile',// 要跨域的域名
35
+ changeOrigin: true, // 是否开启跨域
36
+ pathRewrite:{
37
+ '^/file':'/'
38
+ }
39
+ }
40
+ },
41
+ clientLogLevel: 'warning',
42
+ historyApiFallback: {
43
+ rewrites: [
44
+ { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
45
+ ],
46
+ },
47
+ hot: true,
48
+ contentBase: false, // since we use CopyWebpackPlugin.
49
+ compress: true,
50
+ host: HOST || config.dev.host,
51
+ port: PORT || config.dev.port,
52
+ open: config.dev.autoOpenBrowser,
53
+ overlay: config.dev.errorOverlay
54
+ ? { warnings: false, errors: true }
55
+ : false,
56
+ publicPath: config.dev.assetsPublicPath,
57
+ quiet: true, // necessary for FriendlyErrorsPlugin
58
+ watchOptions: {
59
+ poll: config.dev.poll,
60
+ }
61
+ },
62
+ plugins: [
63
+ new webpack.DefinePlugin({
64
+ 'process.env': require('../config/dev.env')
65
+ }),
66
+ new webpack.HotModuleReplacementPlugin(),
67
+ new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
68
+ new webpack.NoEmitOnErrorsPlugin(),
69
+ // https://github.com/ampedandwired/html-webpack-plugin
70
+ new HtmlWebpackPlugin({
71
+ filename: 'index.html',
72
+ template: 'index.html',
73
+ inject: true
74
+ }),
75
+ // copy custom static assets
76
+ new CopyWebpackPlugin([
77
+ {
78
+ from: path.resolve(__dirname, '../dist'),
79
+ to: config.dev.assetsSubDirectory,
80
+ ignore: ['.*']
81
+ }
82
+ ])
83
+ ]
84
+ })
85
+
86
+ module.exports = new Promise((resolve, reject) => {
87
+ portfinder.basePort = process.env.PORT || config.dev.port
88
+ portfinder.getPort((err, port) => {
89
+ if (err) {
90
+ reject(err)
91
+ } else {
92
+ // publish the new Port, necessary for e2e tests
93
+ process.env.PORT = port
94
+ // add port to devServer config
95
+ devWebpackConfig.devServer.port = port
96
+
97
+ // Add FriendlyErrorsPlugin
98
+ devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
99
+ compilationSuccessInfo: {
100
+ messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
101
+ },
102
+ onErrors: config.dev.notifyOnErrors
103
+ ? utils.createNotifierCallback()
104
+ : undefined
105
+ }))
106
+
107
+ resolve(devWebpackConfig)
108
+ }
109
+ })
110
+ })