mirror of
https://github.com/netfun2000/rttys_zhaojh329.git
synced 2026-02-27 09:53:24 +08:00
rename: assets -> html
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"presets": [
|
||||
["env", {
|
||||
"modules": false,
|
||||
"targets": {
|
||||
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
|
||||
}
|
||||
}],
|
||||
"stage-2"
|
||||
],
|
||||
"plugins": ["transform-vue-jsx", "transform-runtime"]
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
@@ -1,14 +0,0 @@
|
||||
.DS_Store
|
||||
node_modules/
|
||||
/dist/
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
@@ -1,10 +0,0 @@
|
||||
// https://github.com/michael-ciniawsky/postcss-load-config
|
||||
|
||||
module.exports = {
|
||||
"plugins": {
|
||||
"postcss-import": {},
|
||||
"postcss-url": {},
|
||||
// to edit target browsers: use "browserslist" field in package.json
|
||||
"autoprefixer": {}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
# rttys
|
||||
|
||||
> assets of rttys
|
||||
|
||||
## Build Setup
|
||||
|
||||
``` bash
|
||||
# install dependencies
|
||||
npm install
|
||||
|
||||
# serve with hot reload at localhost:8080
|
||||
npm run dev
|
||||
|
||||
# build for production with minification
|
||||
npm run build
|
||||
|
||||
# build for production and view the bundle analyzer report
|
||||
npm run build --report
|
||||
```
|
||||
|
||||
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
|
||||
@@ -1,41 +0,0 @@
|
||||
'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, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
|
||||
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'
|
||||
))
|
||||
})
|
||||
})
|
||||
@@ -1,54 +0,0 @@
|
||||
'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()
|
||||
}
|
||||
|
||||
const versionRequirements = [
|
||||
{
|
||||
name: 'node',
|
||||
currentVersion: semver.clean(process.version),
|
||||
versionRequirement: packageConfig.engines.node
|
||||
}
|
||||
]
|
||||
|
||||
if (shell.which('npm')) {
|
||||
versionRequirements.push({
|
||||
name: 'npm',
|
||||
currentVersion: exec('npm --version'),
|
||||
versionRequirement: packageConfig.engines.npm
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (warnings.length) {
|
||||
console.log('')
|
||||
console.log(chalk.yellow('To use this template, you must update following to modules:'))
|
||||
console.log()
|
||||
|
||||
for (let i = 0; i < warnings.length; i++) {
|
||||
const warning = warnings[i]
|
||||
console.log(' ' + warning)
|
||||
}
|
||||
|
||||
console.log()
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.7 KiB |
@@ -1,101 +0,0 @@
|
||||
'use strict'
|
||||
const path = require('path')
|
||||
const config = require('../config')
|
||||
const ExtractTextPlugin = require('extract-text-webpack-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) {
|
||||
options = options || {}
|
||||
|
||||
const cssLoader = {
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
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) {
|
||||
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
|
||||
|
||||
if (loader) {
|
||||
loaders.push({
|
||||
loader: loader + '-loader',
|
||||
options: Object.assign({}, loaderOptions, {
|
||||
sourceMap: options.sourceMap
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
|
||||
return {
|
||||
css: generateLoaders(),
|
||||
postcss: generateLoaders(),
|
||||
less: generateLoaders('less'),
|
||||
sass: generateLoaders('sass', { indentedSyntax: true }),
|
||||
scss: generateLoaders('sass'),
|
||||
stylus: generateLoaders('stylus'),
|
||||
styl: generateLoaders('stylus')
|
||||
}
|
||||
}
|
||||
|
||||
// Generate loaders for standalone style files (outside of .vue)
|
||||
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')
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
'use strict'
|
||||
const utils = require('./utils')
|
||||
const config = require('../config')
|
||||
const isProduction = process.env.NODE_ENV === 'production'
|
||||
const sourceMapEnabled = isProduction
|
||||
? config.build.productionSourceMap
|
||||
: config.dev.cssSourceMap
|
||||
|
||||
module.exports = {
|
||||
loaders: utils.cssLoaders({
|
||||
sourceMap: sourceMapEnabled,
|
||||
extract: isProduction
|
||||
}),
|
||||
cssSourceMap: sourceMapEnabled,
|
||||
cacheBusting: config.dev.cacheBusting,
|
||||
transformToRequire: {
|
||||
video: ['src', 'poster'],
|
||||
source: 'src',
|
||||
img: 'src',
|
||||
image: 'xlink:href'
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
'use strict'
|
||||
const path = require('path')
|
||||
const utils = require('./utils')
|
||||
const config = require('../config')
|
||||
const vueLoaderConfig = require('./vue-loader.conf')
|
||||
|
||||
function resolve (dir) {
|
||||
return path.join(__dirname, '..', dir)
|
||||
}
|
||||
|
||||
|
||||
|
||||
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
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.vue', '.json'],
|
||||
alias: {
|
||||
'vue$': 'vue/dist/vue.esm.js',
|
||||
'@': resolve('src'),
|
||||
}
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.vue$/,
|
||||
loader: 'vue-loader',
|
||||
options: vueLoaderConfig
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
||||
loader: 'url-loader',
|
||||
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',
|
||||
options: {
|
||||
limit: 10000,
|
||||
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.proto$/,
|
||||
loader: "pbf-loader"
|
||||
}
|
||||
]
|
||||
},
|
||||
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'
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
'use strict'
|
||||
const utils = require('./utils')
|
||||
const webpack = require('webpack')
|
||||
const config = require('../config')
|
||||
const merge = require('webpack-merge')
|
||||
const path = require('path')
|
||||
const baseWebpackConfig = require('./webpack.base.conf')
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
|
||||
const portfinder = require('portfinder')
|
||||
|
||||
const HOST = process.env.HOST
|
||||
const PORT = process.env.PORT && Number(process.env.PORT)
|
||||
|
||||
const devWebpackConfig = merge(baseWebpackConfig, {
|
||||
module: {
|
||||
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
|
||||
},
|
||||
// cheap-module-eval-source-map is faster for development
|
||||
devtool: config.dev.devtool,
|
||||
|
||||
// these devServer options should be customized in /config/index.js
|
||||
devServer: {
|
||||
clientLogLevel: 'warning',
|
||||
historyApiFallback: {
|
||||
rewrites: [
|
||||
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
|
||||
],
|
||||
},
|
||||
hot: true,
|
||||
contentBase: false, // since we use CopyWebpackPlugin.
|
||||
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': require('../config/dev.env')
|
||||
}),
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
|
||||
new webpack.NoEmitOnErrorsPlugin(),
|
||||
// https://github.com/ampedandwired/html-webpack-plugin
|
||||
new HtmlWebpackPlugin({
|
||||
filename: 'index.html',
|
||||
template: 'index.html',
|
||||
inject: true
|
||||
}),
|
||||
// copy custom static assets
|
||||
new CopyWebpackPlugin([
|
||||
{
|
||||
from: path.resolve(__dirname, '../static'),
|
||||
to: config.dev.assetsSubDirectory,
|
||||
ignore: ['.*']
|
||||
}
|
||||
])
|
||||
]
|
||||
})
|
||||
|
||||
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)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,145 +0,0 @@
|
||||
'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 ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
|
||||
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
||||
|
||||
const env = require('../config/prod.env')
|
||||
|
||||
const webpackConfig = merge(baseWebpackConfig, {
|
||||
module: {
|
||||
rules: utils.styleLoaders({
|
||||
sourceMap: config.build.productionSourceMap,
|
||||
extract: true,
|
||||
usePostCSS: true
|
||||
})
|
||||
},
|
||||
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')
|
||||
},
|
||||
plugins: [
|
||||
// http://vuejs.github.io/vue-loader/en/workflow/production.html
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': env
|
||||
}),
|
||||
new UglifyJsPlugin({
|
||||
uglifyOptions: {
|
||||
compress: {
|
||||
warnings: false
|
||||
}
|
||||
},
|
||||
sourceMap: config.build.productionSourceMap,
|
||||
parallel: true
|
||||
}),
|
||||
// extract css into its own file
|
||||
new ExtractTextPlugin({
|
||||
filename: utils.assetsPath('css/[name].[contenthash].css'),
|
||||
// Setting the following option to `false` will not extract CSS from codesplit chunks.
|
||||
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
|
||||
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
|
||||
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
|
||||
allChunks: true,
|
||||
}),
|
||||
// Compress extracted CSS. We are using this plugin so that possible
|
||||
// duplicated CSS from different components can be deduped.
|
||||
new OptimizeCSSPlugin({
|
||||
cssProcessorOptions: config.build.productionSourceMap
|
||||
? { safe: true, map: { inline: false } }
|
||||
: { safe: true }
|
||||
}),
|
||||
// generate dist index.html with correct asset hash for caching.
|
||||
// you can customize output by editing /index.html
|
||||
// see https://github.com/ampedandwired/html-webpack-plugin
|
||||
new HtmlWebpackPlugin({
|
||||
filename: config.build.index,
|
||||
template: 'index.html',
|
||||
inject: true,
|
||||
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'
|
||||
}),
|
||||
// keep module.id stable when vendor modules does not change
|
||||
new webpack.HashedModuleIdsPlugin(),
|
||||
// enable scope hoisting
|
||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||
// split vendor js into its own file
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'vendor',
|
||||
minChunks (module) {
|
||||
// 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
|
||||
)
|
||||
}
|
||||
}),
|
||||
// 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',
|
||||
minChunks: Infinity
|
||||
}),
|
||||
// This instance extracts shared chunks from code splitted chunks and bundles them
|
||||
// in a separate chunk, similar to the vendor chunk
|
||||
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'app',
|
||||
async: 'vendor-async',
|
||||
children: true,
|
||||
minChunks: 3
|
||||
}),
|
||||
|
||||
// copy custom static assets
|
||||
new CopyWebpackPlugin([
|
||||
{
|
||||
from: path.resolve(__dirname, '../static'),
|
||||
to: config.build.assetsSubDirectory,
|
||||
ignore: ['.*']
|
||||
}
|
||||
])
|
||||
]
|
||||
})
|
||||
|
||||
if (config.build.productionGzip) {
|
||||
const CompressionWebpackPlugin = require('compression-webpack-plugin')
|
||||
|
||||
webpackConfig.plugins.push(
|
||||
new CompressionWebpackPlugin({
|
||||
asset: '[path].gz[query]',
|
||||
algorithm: 'gzip',
|
||||
test: new RegExp(
|
||||
'\\.(' +
|
||||
config.build.productionGzipExtensions.join('|') +
|
||||
')$'
|
||||
),
|
||||
threshold: 10240,
|
||||
minRatio: 0.8
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
if (config.build.bundleAnalyzerReport) {
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
|
||||
}
|
||||
|
||||
module.exports = webpackConfig
|
||||
@@ -1,7 +0,0 @@
|
||||
'use strict'
|
||||
const merge = require('webpack-merge')
|
||||
const prodEnv = require('./prod.env')
|
||||
|
||||
module.exports = merge(prodEnv, {
|
||||
NODE_ENV: '"development"'
|
||||
})
|
||||
@@ -1,69 +0,0 @@
|
||||
'use strict'
|
||||
// Template version: 1.3.1
|
||||
// see http://vuejs-templates.github.io/webpack for documentation.
|
||||
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
dev: {
|
||||
|
||||
// Paths
|
||||
assetsSubDirectory: 'static',
|
||||
assetsPublicPath: '/',
|
||||
proxyTable: {},
|
||||
|
||||
// Various Dev Server settings
|
||||
host: 'localhost', // can be overwritten by process.env.HOST
|
||||
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
|
||||
autoOpenBrowser: false,
|
||||
errorOverlay: true,
|
||||
notifyOnErrors: true,
|
||||
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
|
||||
|
||||
|
||||
/**
|
||||
* Source Maps
|
||||
*/
|
||||
|
||||
// https://webpack.js.org/configuration/devtool/#development
|
||||
devtool: 'cheap-module-eval-source-map',
|
||||
|
||||
// If you have problems debugging vue-files in devtools,
|
||||
// set this to false - it *may* help
|
||||
// https://vue-loader.vuejs.org/en/options.html#cachebusting
|
||||
cacheBusting: true,
|
||||
|
||||
cssSourceMap: true
|
||||
},
|
||||
|
||||
build: {
|
||||
// Template for index.html
|
||||
index: path.resolve(__dirname, '../dist/index.html'),
|
||||
|
||||
// Paths
|
||||
assetsRoot: path.resolve(__dirname, '../dist'),
|
||||
assetsSubDirectory: 'static',
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
'use strict'
|
||||
module.exports = {
|
||||
NODE_ENV: '"production"'
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<title>RTTY</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,72 +0,0 @@
|
||||
{
|
||||
"name": "rttys",
|
||||
"version": "1.0.0",
|
||||
"description": "assets of rttys",
|
||||
"author": "Jianhui Zhao <jianhuizhao329@gmail.com>",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
|
||||
"start": "npm run dev",
|
||||
"build": "node build/build.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
"iview": "^2.14.1",
|
||||
"pbf": "^3.1.0",
|
||||
"simple-websocket": "^7.0.2",
|
||||
"string-format-easy": "^1.0.1",
|
||||
"vue": "^2.5.13",
|
||||
"vue-axios": "^2.1.1",
|
||||
"vue-contextmenu-easy": "^1.0.1",
|
||||
"vue-i18n": "^7.8.0",
|
||||
"vue-router": "^3.0.1",
|
||||
"xterm": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^7.2.6",
|
||||
"babel-core": "^6.22.1",
|
||||
"babel-helper-vue-jsx-merge-props": "^2.0.3",
|
||||
"babel-loader": "^7.1.3",
|
||||
"babel-plugin-syntax-jsx": "^6.18.0",
|
||||
"babel-plugin-transform-runtime": "^6.22.0",
|
||||
"babel-plugin-transform-vue-jsx": "^3.7.0",
|
||||
"babel-preset-env": "^1.3.2",
|
||||
"babel-preset-stage-2": "^6.22.0",
|
||||
"chalk": "^2.3.2",
|
||||
"copy-webpack-plugin": "^4.5.0",
|
||||
"css-loader": "^0.28.10",
|
||||
"extract-text-webpack-plugin": "^3.0.0",
|
||||
"file-loader": "^1.1.11",
|
||||
"friendly-errors-webpack-plugin": "^1.6.1",
|
||||
"html-webpack-plugin": "^2.30.1",
|
||||
"node-notifier": "^5.1.2",
|
||||
"optimize-css-assets-webpack-plugin": "^3.2.0",
|
||||
"ora": "^1.2.0",
|
||||
"pbf-loader": "^1.1.0",
|
||||
"portfinder": "^1.0.13",
|
||||
"postcss-import": "^11.1.0",
|
||||
"postcss-loader": "^2.1.1",
|
||||
"postcss-url": "^7.3.1",
|
||||
"rimraf": "^2.6.0",
|
||||
"semver": "^5.3.0",
|
||||
"shelljs": "^0.7.6",
|
||||
"uglifyjs-webpack-plugin": "^1.2.2",
|
||||
"url-loader": "^0.5.8",
|
||||
"vue-loader": "^13.3.0",
|
||||
"vue-style-loader": "^3.0.1",
|
||||
"vue-template-compiler": "^2.5.2",
|
||||
"webpack": "^3.11.0",
|
||||
"webpack-bundle-analyzer": "^2.11.1",
|
||||
"webpack-dev-server": "^2.11.2",
|
||||
"webpack-merge": "^4.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0",
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not ie <= 8"
|
||||
]
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<router-view></router-view>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'App'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
html, body, #app {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #555;
|
||||
}
|
||||
</style>
|
||||
@@ -1,95 +0,0 @@
|
||||
<template>
|
||||
<div id="home">
|
||||
<Row type="flex" align="bottom">
|
||||
<Col span="6">
|
||||
<Input v-model="filterString" icon="search" size="large" @on-change="handleSearch" :placeholder="$t('Please enter the filter key...')" style="width: 400px" />
|
||||
</Col>
|
||||
<Col :xs="{span: 5, offset: 13}" :md="{span: 4, offset: 14}" :lg="{span: 3, offset: 15}" class="counter">
|
||||
{{ $t('device-count', {count: devlists.length}) }}
|
||||
</Col>
|
||||
</Row>
|
||||
<Table :loading="loading" :columns="devlistTitle" :data="filtered" style="margin-top: 10px; width: 100%" :no-data-text="$t('No devices connected')"></Table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'Home',
|
||||
data() {
|
||||
return {
|
||||
filterString: '',
|
||||
loading: true,
|
||||
devlists: [],
|
||||
filtered: [],
|
||||
devlistTitle: [
|
||||
{
|
||||
title: 'ID',
|
||||
key: 'id',
|
||||
sortType: 'asc',
|
||||
sortable: true
|
||||
}, {
|
||||
title: this.$t('Uptime'),
|
||||
key: 'uptime',
|
||||
sortable: true,
|
||||
render: (h, params) => {
|
||||
return h('span', '%t'.format(params.row.uptime));
|
||||
}
|
||||
}, {
|
||||
title: this.$t('Description'),
|
||||
key: 'description'
|
||||
}, {
|
||||
width: 150,
|
||||
align: 'center',
|
||||
render: (h, params) => {
|
||||
return h('Button', {
|
||||
props: { type: 'primary' },
|
||||
on: {
|
||||
click: () => {
|
||||
this.$router.push({path: '/rtty', query: {devid: params.row.id}});
|
||||
}
|
||||
}
|
||||
}, this.$t('Connect'));
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSearch() {
|
||||
this.filtered = this.devlists.filter(d => {
|
||||
return d.id.indexOf(this.filterString) > -1 || d.description.indexOf(this.filterString) > -1;
|
||||
});
|
||||
},
|
||||
getDevices() {
|
||||
this.$http.get('/devs').then(res => {
|
||||
this.loading = false;
|
||||
this.devlists = res.data;
|
||||
this.handleSearch();
|
||||
}).catch(err => {
|
||||
this.$router.push('/login');
|
||||
});
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.$root.$data.interval)
|
||||
clearInterval(this.$root.$data.interval);
|
||||
|
||||
this.$root.$data.interval = setInterval(()=> {
|
||||
this.getDevices();
|
||||
}, 3000);
|
||||
|
||||
this.getDevices();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#home {
|
||||
padding:10px;
|
||||
}
|
||||
.counter {
|
||||
color: #3399ff;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,72 +0,0 @@
|
||||
<template>
|
||||
<div @keydown.enter="handleSubmit">
|
||||
<Card class="login-container">
|
||||
<p slot="title">{{ $t('Authorization Required') }}</p>
|
||||
<Form ref="form" :model="form" :rules="ruleValidate">
|
||||
<FormItem prop="username">
|
||||
<Input type="text" v-model="form.username" size="large" auto-complete="off" :placeholder="$t('Enter username...')">
|
||||
<Icon type="ios-person-outline" slot="prepend"></Icon>
|
||||
</Input>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Input type="password" v-model="form.password" size="large" auto-complete="off" :placeholder="$t('Enter password...')">
|
||||
<Icon type="ios-locked-outline" slot="prepend"></Icon>
|
||||
</Input>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Button type="primary" long size="large" icon="log-in" @click="handleSubmit">{{ $t('Login') }}</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Login',
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
username: '',
|
||||
password: ''
|
||||
},
|
||||
ruleValidate: {
|
||||
username: [
|
||||
{required: true, trigger: 'blur', message: this.$t('username is required')}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleSubmit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
|
||||
const params = new URLSearchParams();
|
||||
params.append('username', this.form.username);
|
||||
params.append('password', this.form.password);
|
||||
this.$http.post('/login', params).then(res => {
|
||||
sessionStorage.setItem('rtty-sid', res)
|
||||
this.$router.push('/');
|
||||
}).catch(err => {
|
||||
this.$Message.error(this.$t('Login Fail! username or password wrong.'));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.login-container {
|
||||
width: 400px;
|
||||
height: 240px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
margin-left: -200px;
|
||||
margin-top: -120px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,370 +0,0 @@
|
||||
<template>
|
||||
<div id="rtty">
|
||||
<div ref="terminal" class="terminal" @contextmenu="$vuecontextmenu()"></div>
|
||||
<VueContextMenu :menulists="menulists" @contentmenu-click="contentmenuClick"></VueContextMenu>
|
||||
<Modal v-model="upfile.modal" width="380" :mask-closable="false" @on-cancel="cancelUpfile">
|
||||
<p slot="header"><span>{{ $t('Upload file to device') }}</span></p>
|
||||
<Upload v-if="!upfile.loading" :before-upload="beforeUpload" action="">
|
||||
<Button type="ghost" icon="Upload">{{ $t('Select the file to upload') }}</Button>
|
||||
</Upload>
|
||||
<Progress v-if="upfile.loading" :percent="upfile.percent"></Progress>
|
||||
<div v-if="upfile.file !== null">{{ $t('upfile-info', {name: upfile.file.name}) }}</div>
|
||||
<div slot="footer">
|
||||
<Button type="primary" size="large" long :loading="upfile.loading"
|
||||
@click="doUpload">{{ upfile.loading ? $t('Uploading') : $t('Click to upload') }}</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
<Modal v-model="downfile.modal" width="700" :mask-closable="false" @on-cancel="cancelDownfile">
|
||||
<p slot="header"><span>{{ $t('Download file from device') }}</span></p>
|
||||
<Input v-if="!downfile.downing" v-model="downfile.filter" icon="search"
|
||||
@on-change="handleFilterDownFile" :placeholder="$t('Please enter the filter key...')">
|
||||
<span slot="prepend">{{ downfile.pathname }}</span>
|
||||
</Input>
|
||||
<Table :loading="downfile.loading" v-if="!downfile.downing" :columns="filelistTitle" height="400" :data="downfile.filelistFiltered" @on-row-dblclick="filelistDblclick"></Table>
|
||||
<Progress v-if="downfile.downing" :percent="downfile.percent"></Progress>
|
||||
<div slot="footer"></div>
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import * as Socket from 'simple-websocket';
|
||||
import { Terminal } from 'xterm'
|
||||
import 'xterm/lib/xterm.css'
|
||||
import * as fit from 'xterm/lib/addons/fit/fit';
|
||||
import Utf8ArrayToStr from '@/utf8array_str'
|
||||
|
||||
Terminal.applyAddon(fit);
|
||||
|
||||
const Pbf = require('pbf');
|
||||
const rttyMsg = require('@/rtty.proto').rtty_message;
|
||||
|
||||
function rttyMsgInit(type, msg) {
|
||||
let pbf = new Pbf();
|
||||
|
||||
msg.version = 2;
|
||||
msg.type = rttyMsg.Type[type].value;
|
||||
rttyMsg.write(msg, pbf);
|
||||
|
||||
return pbf.finish();
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'Rtty',
|
||||
data() {
|
||||
return {
|
||||
menulists: [
|
||||
{
|
||||
name: 'upfile',
|
||||
caption: this.$t('Upload file to device')
|
||||
},{
|
||||
name: 'downfile',
|
||||
caption: this.$t('Download file from device')
|
||||
},{
|
||||
name: 'increasefontsize',
|
||||
caption: this.$t('Increase font size')
|
||||
},{
|
||||
name: 'decreasefontsize',
|
||||
caption: this.$t('Decrease font size')
|
||||
}
|
||||
],
|
||||
filelistTitle: [
|
||||
{
|
||||
title: this.$t('Name'),
|
||||
key: 'name',
|
||||
render: (h, params) => {
|
||||
if (params.row.dir)
|
||||
return h('div', [
|
||||
h('Icon', {props: {type: 'folder', color: '#FFE793', size: 20}}),
|
||||
h('strong', ' ' + params.row.name)
|
||||
]);
|
||||
else
|
||||
return h('span', params.row.name);
|
||||
}
|
||||
}, {
|
||||
title: this.$t('Size'),
|
||||
key: 'size',
|
||||
sortable: true,
|
||||
render: (h, params) => {
|
||||
return h('span', params.row.size && '%1024mB'.format(params.row.size));
|
||||
}
|
||||
}, {
|
||||
title: this.$t('modification'),
|
||||
key: 'mtime',
|
||||
sortable: true,
|
||||
render: (h, params) => {
|
||||
if (params.row.mtim)
|
||||
return h('span', new Date(params.row.mtim * 1000).toLocaleString());
|
||||
}
|
||||
}
|
||||
],
|
||||
upfile: {modal: false, file: null, step: 2048, pos: 0, percent: 0, loading: false},
|
||||
downfile: {modal: false, loading: true, pathname: '/', filelist: [], filelistFiltered: [], downing: false, percent: 0, filter: ''},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
logout() {
|
||||
if (this.ws) {
|
||||
this.ws.destroy();
|
||||
delete this.ws;
|
||||
}
|
||||
|
||||
if (this.term) {
|
||||
this.term.destroy();
|
||||
delete this.term;
|
||||
}
|
||||
|
||||
this.$router.push('/');
|
||||
},
|
||||
contentmenuClick(name) {
|
||||
let changeFontSize = 0;
|
||||
|
||||
if (!this.term)
|
||||
return;
|
||||
|
||||
if (name == 'upfile') {
|
||||
this.upfile = {modal: true, file: null, step: 2048, pos: 0, percent: 0, loading: false};
|
||||
} else if (name == 'downfile') {
|
||||
this.downfile = {modal: true, loading: true, path: [], pathname: '/', filelist: [], downing: false, percent: 0, filter: ''};
|
||||
let msg = rttyMsgInit('DOWNFILE', {sid: this.sid});
|
||||
this.ws.send(msg);
|
||||
} else if (name == 'increasefontsize') {
|
||||
changeFontSize = 1;
|
||||
} else if (name == 'decreasefontsize') {
|
||||
changeFontSize = -1;
|
||||
}
|
||||
|
||||
window.setTimeout(() => {
|
||||
let size = this.term.getOption('fontSize');
|
||||
|
||||
this.term.setOption('fontSize', size + changeFontSize);
|
||||
this.term.fit();
|
||||
this.term.focus();
|
||||
this.term.refresh();
|
||||
}, 50);
|
||||
},
|
||||
beforeUpload (file) {
|
||||
this.upfile.file = file;
|
||||
this.upfile.lf = true;
|
||||
return false;
|
||||
},
|
||||
readFile(fr) {
|
||||
var blob = this.upfile.file.slice(this.upfile.pos, this.upfile.pos + this.upfile.step);
|
||||
fr.readAsArrayBuffer(blob);
|
||||
},
|
||||
cancelUpfile() {
|
||||
if (!this.upfile.loading)
|
||||
return;
|
||||
this.upfile.canceled = true;
|
||||
this.$Message.info(this.$t('Upload canceled'));
|
||||
|
||||
let msg = rttyMsgInit('UPFILE', {sid: this.sid, code: rttyMsg.FileCode.CANCELED.value});
|
||||
this.ws.send(msg);
|
||||
},
|
||||
doUpload () {
|
||||
if (!this.upfile.file) {
|
||||
this.$Message.error(this.$t('Select the file to upload'));
|
||||
return;
|
||||
}
|
||||
|
||||
this.upfile.loading = true;
|
||||
|
||||
var fr = new FileReader();
|
||||
fr.onload = (e) => {
|
||||
if (this.upfile.canceled)
|
||||
return;
|
||||
|
||||
let msg = rttyMsgInit('UPFILE', {sid: this.sid, code: rttyMsg.FileCode.FILEDATA.value, data: Buffer.from(fr.result)});
|
||||
this.ws.send(msg);
|
||||
|
||||
this.upfile.pos += e.loaded;
|
||||
this.upfile.percent = Math.round(this.upfile.pos / this.upfile.file.size * 100);
|
||||
|
||||
if (this.upfile.pos < this.upfile.file.size) {
|
||||
/* Control the client read speed based on the current buffer and server */
|
||||
if (this.ws.bufferedAmount > this.upfile.pos * 10 || this.upfile.ratelimit) {
|
||||
this.upfile.ratelimit = false;
|
||||
|
||||
setTimeout(() => {
|
||||
this.readFile(fr);
|
||||
}, 100);
|
||||
} else {
|
||||
this.readFile(fr);
|
||||
}
|
||||
} else {
|
||||
this.upfile.modal = false;
|
||||
this.$Message.info(this.$t('Upload success'));
|
||||
}
|
||||
};
|
||||
|
||||
let msg = rttyMsgInit('UPFILE', {sid: this.sid, name: this.upfile.file.name, size: this.upfile.file.size, code: rttyMsg.FileCode.START.value});
|
||||
this.ws.send(msg);
|
||||
|
||||
this.readFile(fr);
|
||||
},
|
||||
cancelDownfile() {
|
||||
if (this.downfile.downing) {
|
||||
let msg = rttyMsgInit('DOWNFILE', {sid: this.sid, code: rttyMsg.FileCode.CANCELED.value});
|
||||
this.ws.send(msg);
|
||||
|
||||
this.$Message.info(this.$t('Download canceled'));
|
||||
}
|
||||
},
|
||||
handleFilterDownFile() {
|
||||
this.downfile.filelistFiltered = this.downfile.filelist.filter(d => {
|
||||
return d.name.indexOf(this.downfile.filter) > -1;
|
||||
});
|
||||
},
|
||||
filelistDblclick(row, index) {
|
||||
let attr = {sid: this.sid};
|
||||
|
||||
this.downfile.filter = '';
|
||||
|
||||
if (row.name == '..') {
|
||||
if (this.downfile.path.length < 1)
|
||||
return;
|
||||
this.downfile.path.pop();
|
||||
} else {
|
||||
this.downfile.path.push(row.name);
|
||||
}
|
||||
|
||||
this.downfile.pathname = '/' + this.downfile.path.join('/');
|
||||
|
||||
if (row.dir) {
|
||||
this.downfile.loading = true;
|
||||
if (!this.downfile.pathname.endsWith('/'))
|
||||
this.downfile.pathname = this.downfile.pathname + '/';
|
||||
} else {
|
||||
this.downfile.received = 0;
|
||||
this.downfile.size = row.size;
|
||||
this.downfile.downing = true;
|
||||
}
|
||||
|
||||
attr.name = this.downfile.pathname;
|
||||
|
||||
let msg = rttyMsgInit('DOWNFILE', attr);
|
||||
this.ws.send(msg);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
let devid = this.$route.query.devid;
|
||||
let protocol = 'ws://';
|
||||
|
||||
this.username = this.$route.query.username;
|
||||
this.password = this.$route.query.password;
|
||||
|
||||
if (location.protocol == 'https:')
|
||||
protocol = 'wss://';
|
||||
|
||||
let ws = new Socket(protocol + location.host + '/ws?devid=' + devid);
|
||||
this.ws = ws;
|
||||
|
||||
ws.on('connect', () => {
|
||||
let term = new Terminal({
|
||||
cursorBlink: true,
|
||||
fontSize: 16
|
||||
});
|
||||
|
||||
term.open(this.$refs['terminal']);
|
||||
term.fit();
|
||||
term.focus();
|
||||
|
||||
this.term = term;
|
||||
|
||||
ws.on('data', (data) => {
|
||||
let pbf = new Pbf(data);
|
||||
let msg = rttyMsg.read(pbf);
|
||||
|
||||
if (msg.type == rttyMsg.Type.LOGINACK.value) {
|
||||
if (msg.code == rttyMsg.LoginCode.OFFLINE.value) {
|
||||
this.$Message.error(this.$t('Device offline'));
|
||||
this.logout();
|
||||
return;
|
||||
}
|
||||
|
||||
this.sid = msg.sid;
|
||||
|
||||
term.on('data', (data) => {
|
||||
let msg = rttyMsgInit('TTY', {sid: this.sid, data: Buffer.from(data)});
|
||||
ws.send(msg);
|
||||
});
|
||||
} else if (msg.type == rttyMsg.Type.TTY.value) {
|
||||
let data = Utf8ArrayToStr(msg.data);
|
||||
|
||||
if (!this.recvTTYCnt)
|
||||
this.recvTTYCnt = 0;
|
||||
this.recvTTYCnt++;
|
||||
|
||||
if (this.recvTTYCnt < 4) {
|
||||
if (data.match('login:') && this.username && this.username != '') {
|
||||
let msg = rttyMsgInit('TTY', {sid: this.sid, data: Buffer.from(this.username + '\n')});
|
||||
ws.send(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.match('Password:') && this.password && this.password != '') {
|
||||
let msg = rttyMsgInit('TTY', {sid: this.sid, data: Buffer.from(this.password + '\n')});
|
||||
ws.send(msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
term.write(data);
|
||||
} else if (msg.type == rttyMsg.Type.UPFILE.value) {
|
||||
if (msg.code == rttyMsg.FileCode.RATELIMIT.value) {
|
||||
/* Need reduce the sending rate */
|
||||
this.upfile.ratelimit = true;
|
||||
}
|
||||
} else if (msg.type == rttyMsg.Type.DOWNFILE.value) {
|
||||
let code = msg.code;
|
||||
if (code == rttyMsg.FileCode.START.value) {
|
||||
this.downfile.loading = false;
|
||||
this.downfile.filelist = msg.filelist;
|
||||
this.handleFilterDownFile();
|
||||
}
|
||||
else if (code == rttyMsg.FileCode.FILEDATA.value) {
|
||||
if (!this.downfile.data)
|
||||
this.downfile.data = new Blob([msg.data]);
|
||||
else
|
||||
this.downfile.data = new Blob([this.downfile.data, msg.data]);
|
||||
this.downfile.received += msg.data.byteLength;
|
||||
this.downfile.percent = Math.round(this.downfile.received / this.downfile.size * 100);
|
||||
} else if (code == rttyMsg.FileCode.END.value) {
|
||||
let url = URL.createObjectURL(this.downfile.data);
|
||||
let a = document.createElement('a');
|
||||
a.download = this.downfile.pathname;
|
||||
a.href = url;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
this.downfile.modal = false;
|
||||
this.downfile.downing = false;
|
||||
this.$Message.info(this.$t('Download Finish'));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ws.on('error', () => {
|
||||
this.$Message.error(this.$t('Connect failed'));
|
||||
this.logout();
|
||||
});
|
||||
|
||||
ws.on('close', () => {
|
||||
this.logout();
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#rtty {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.terminal {
|
||||
height: 100%;
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,67 +0,0 @@
|
||||
// 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 App from './App'
|
||||
import iView from 'iview'
|
||||
import 'iview/dist/styles/iview.css'
|
||||
import VueI18n from 'vue-i18n'
|
||||
import zhLocale from 'iview/dist/locale/zh-CN'
|
||||
import enLocale from 'iview/dist/locale/en-US'
|
||||
import 'string-format-easy'
|
||||
import VueContextMenu from 'vue-contextmenu-easy'
|
||||
import RttyI18n from './rtty-i18n'
|
||||
import router from './router'
|
||||
import axios from 'axios'
|
||||
import VueAxios from 'vue-axios'
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
Vue.use(VueI18n);
|
||||
Vue.use(iView);
|
||||
|
||||
Vue.use(VueContextMenu);
|
||||
|
||||
Vue.use(VueAxios, axios)
|
||||
|
||||
const messages = {
|
||||
'zh-CN': Object.assign(zhLocale, RttyI18n['zh-CN']),
|
||||
'en-US': Object.assign(enLocale, RttyI18n['en-US'])
|
||||
};
|
||||
|
||||
let language = navigator.language;
|
||||
|
||||
if (!messages[language])
|
||||
language = 'en-US';
|
||||
|
||||
const i18n = new VueI18n({
|
||||
locale: language,
|
||||
messages: messages
|
||||
});
|
||||
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.path == '/rtty' && to.query.devid) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
if (to.path == '/' && to.query.id) {
|
||||
router.push({path: '/rtty', query: {devid: to.query.id, username: to.query.username, password: to.query.password}});
|
||||
return;
|
||||
}
|
||||
|
||||
if (to.path != '/login' && !sessionStorage.getItem('rtty-sid')) {
|
||||
router.push('/login');
|
||||
return;
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
/* eslint-disable no-new */
|
||||
new Vue({
|
||||
i18n: i18n,
|
||||
el: '#app',
|
||||
router,
|
||||
render: (h)=>h(App)
|
||||
});
|
||||
@@ -1,27 +0,0 @@
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
import Login from '@/components/Login'
|
||||
import Home from '@/components/Home'
|
||||
import Rtty from '@/components/Rtty'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
export default new Router({
|
||||
routes: [
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
component: Login
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
name: 'Home',
|
||||
component: Home
|
||||
},
|
||||
{
|
||||
path: '/rtty',
|
||||
name: 'Rtty',
|
||||
component: Rtty
|
||||
}
|
||||
]
|
||||
})
|
||||
@@ -1,39 +0,0 @@
|
||||
const RttyI18n = {
|
||||
'en-US': {
|
||||
'upfile-info': 'The file "{name}" will be saved in the "/tmp/" directory of your device.',
|
||||
'device-count': 'Online Device: {count}'
|
||||
},
|
||||
'zh-CN': {
|
||||
'Description': '描述',
|
||||
'Uptime': '在线时长',
|
||||
'Connect': '连接',
|
||||
'Please enter the filter key...': '请输入关键字进行过滤……',
|
||||
'No devices connected': '没有设备连接',
|
||||
'Upload file to device': '上传文件到设备',
|
||||
'Download file from device': '从设备下载文件',
|
||||
'Increase font size': '增大字体',
|
||||
'Decrease font size': '减小字体',
|
||||
'Select the file to upload': '选择您要上传的文件',
|
||||
'Uploading': '正在上传',
|
||||
'Click to upload': '上传',
|
||||
'Upload success': '上传成功',
|
||||
'Download Finish': '下载成功',
|
||||
'Upload canceled': '上传终止',
|
||||
'Download canceled': '下载终止',
|
||||
'Device offline': '设备离线',
|
||||
'modification': '修改时间',
|
||||
'upfile-info': '文件"{name}"将会保存到你的设备的"/tmp"目录',
|
||||
'Name': '名称',
|
||||
'Size': '大小',
|
||||
'Authorization Required': '需要授权',
|
||||
'Enter username...': '请输入用户名...',
|
||||
'Enter password...': '请输入密码...',
|
||||
'Login': '登录',
|
||||
'username is required': '用户名为必填',
|
||||
'Login Fail! username or password wrong.': '登录失败,用户名或密码错误',
|
||||
'Connect failed': '连接失败',
|
||||
'device-count': '在线设备数:{count}',
|
||||
}
|
||||
}
|
||||
|
||||
export default RttyI18n
|
||||
@@ -1,64 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
|
||||
message rtty_message {
|
||||
enum Type {
|
||||
UNKNOWN = 0;
|
||||
LOGIN = 1;
|
||||
LOGINACK = 2;
|
||||
LOGOUT = 3;
|
||||
TTY = 4;
|
||||
UPFILE = 5;
|
||||
DOWNFILE = 6;
|
||||
COMMAND = 7;
|
||||
}
|
||||
|
||||
enum LoginCode {
|
||||
OK = 0;
|
||||
OFFLINE = 1;
|
||||
}
|
||||
|
||||
enum FileCode {
|
||||
START = 0;
|
||||
RATELIMIT = 1;
|
||||
FILEDATA = 2;
|
||||
CANCELED = 3;
|
||||
END = 4;
|
||||
}
|
||||
|
||||
enum CommandErr {
|
||||
NONE = 0;
|
||||
TIMEOUT = 1;
|
||||
NOTFOUND = 2;
|
||||
READ = 3;
|
||||
PERMISSION = 4;
|
||||
SYSCALL = 5;
|
||||
DEV_OFFLINE = 6;
|
||||
CMD_REQUIRED = 7;
|
||||
DEVID_REQUIRED = 8;
|
||||
}
|
||||
|
||||
message File {
|
||||
string name = 1;
|
||||
bool dir = 2;
|
||||
uint64 mtime = 3;
|
||||
uint64 size = 4;
|
||||
}
|
||||
|
||||
uint32 version = 1;
|
||||
Type type = 2;
|
||||
string sid = 3;
|
||||
int32 code = 4;
|
||||
bytes data = 5;
|
||||
string name = 6;
|
||||
uint32 size = 7;
|
||||
uint32 id = 8;
|
||||
int32 err = 9;
|
||||
string username = 10;
|
||||
string password = 11;
|
||||
string std_out = 12;
|
||||
string std_err = 13;
|
||||
repeated string params = 14;
|
||||
map<string, string> env = 15;
|
||||
repeated File filelist = 16;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
|
||||
/* utf.js - UTF-8 <=> UTF-16 convertion
|
||||
*
|
||||
* Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp>
|
||||
* Version: 1.0
|
||||
* LastModified: Dec 25 1999
|
||||
* This library is free. You can redistribute it and/or modify it.
|
||||
*/
|
||||
|
||||
function Utf8ArrayToStr(array) {
|
||||
var out, i, len, c;
|
||||
var char2, char3;
|
||||
|
||||
out = "";
|
||||
len = array.length;
|
||||
i = 0;
|
||||
while(i < len) {
|
||||
c = array[i++];
|
||||
switch(c >> 4) {
|
||||
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
|
||||
// 0xxxxxxx
|
||||
out += String.fromCharCode(c);
|
||||
break;
|
||||
case 12: case 13:
|
||||
// 110x xxxx 10xx xxxx
|
||||
char2 = array[i++];
|
||||
out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
|
||||
break;
|
||||
case 14:
|
||||
// 1110 xxxx 10xx xxxx 10xx xxxx
|
||||
char2 = array[i++];
|
||||
char3 = array[i++];
|
||||
out += String.fromCharCode(((c & 0x0F) << 12) |
|
||||
((char2 & 0x3F) << 6) |
|
||||
((char3 & 0x3F) << 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
export default Utf8ArrayToStr
|
||||
Reference in New Issue
Block a user