# 安装nodejs

nodejs官网 (opens new window) 下载对应操作系统的稳定版本并安装

提示

建议安装v14.16.1及以上的稳定版本

运行命令查看安装的版本

node --version
1

# 安装npm

由于新版的nodejs已经集成了npm,所以之前npm也一并安装好了。同样可以通过输入 "npm -v" 来测试是否成功安装。命令如下,出现版本提示表示安装成功:

npm -v
1

# 设置npm的淘宝源

由于网速等原因,为了加快访问速度,建议设置npm的源为淘宝源

# 如果是npm
npm config set registry https://registry.npmmirror.com
# 如果是yarn
yarn config set registry https://registry.npmmirror.com
1
2
3
4

提示

注意安装过程中由于目录权限等原因,安装失败,如果是mac或linx等系统,可在命令前面加sudo前缀或设置该目录为可读写即可。

# 注册平台仓库权限

项目需注册平台仓库权限,否则无法下载,命令如下:

# 针对重邮校园网
npm login --registry=http://202.202.43.5:82/repository/sei-npm-group/

# 针对外网
npm login --registry=http://nexus.sczlcq.com/repository/sei-npm-group/

1
2
3
4
5
6

提示

用户名密码可咨询重庆邮电大学应用软件技术重点实验室或者数创智联(重庆)信息技术有限公司。

# 创建项目

# 下载模块方式

平台提供了一个完整项目的模板,你可以用它们快速地搭建一个基于 SEI-UI 的项目。
下载完成后后,进入项目,更改项目的名称等。

点击下载demo模板项目

提示

建议采用下载模板方式创建项目。

# 手动创建方式

采用vue官方提供的vue-cli命令方式创建。
1.安装vue-cli

npm install vue-cli -g
1

2.创建项目,例如创建test项目

vue create test
1

3.添加平台组件

# 针对重邮校园网
npm install  @sei/sei-ui@6.0.0 --registry=http://202.202.43.5:82/repository/sei-npm-group/  --save

# 针对外网
npm install  @sei/sei-ui@6.0.0 --registry=http://nexus.sczlcq.com/repository/sei-npm-group/  --save
1
2
3
4
5

提示

需要注册平台仓库权限,否则无法下载。
用户名密码可咨询重庆邮电大学应用软件技术重点实验室或者数创智联(重庆)信息技术有限公司。

# 配置项目

# 配置package.json

配置项目package.json,内容大概如下:

点击查看package.json内容
{
    "name": "sei-ui-demo",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "serve": "vue-cli-service serve",
        "build": "vue-cli-service build",
        "lint": "vue-cli-service lint",
        "clear": "npm cache clean -f",
        "reInstall_linux": "rm -rf package-lock.json && rm -rf yarn.lock && rm -rf node_modules && yarn cache clean && npm cache clean --force && yarn install --force",
        "reInstall_win": "rd /s /q node_modules 2>nul && del /Q package-lock.json 2>nul && del /Q yarn.lock 2>nul && yarn cache clean && npm cache clean --force && yarn install --force"
    },
    "dependencies": {
        "@sei/sei-ui": "6.0.0"
    },
    "devDependencies": {
        "@babel/core": "~7.26.0",
        "@babel/eslint-parser": "~7.25.9",
        "@vue/cli-plugin-babel": "~5.0.8",
        "@vue/cli-plugin-eslint": "~5.0.8",
        "@vue/cli-service": "~5.0.8",
        "babel-plugin-component": "~1.1.1",
        "babel-plugin-import": "~1.13.8",
        "eslint": "^7.32.0",
        "eslint-plugin-vue": "^8.0.3",
        "mini-css-extract-plugin": "~2.9.1",
        "sass": "~1.80.6",
        "sass-loader": "~16.0.3",
        "webpack": "~5.96.1",
        "webpack-cli": "~5.1.4"
    }
}
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

# 配置vue.config.js

配置项目vue.config.js,内容大概如下:

点击查看vue.config.js内容
let monacoWebpackPlugin = require('monaco-editor-esm-webpack-plugin')
module.exports = {
    chainWebpack: config => {
        config.plugin('monaco-editor').use(monacoWebpackPlugin, [{languages: ['html', 'css', 'javascript', 'typescript', 'json', 'mysql']}]);
        config.resolve.symlinks(true);
        config.plugin('mini-css-extract-plugin').use(require('mini-css-extract-plugin'));
        config.plugin('node-polyfill-webpack-plugin').use(require('node-polyfill-webpack-plugin'));
    },
    configureWebpack: (config) => {
        config.entry.app = './src/main.js';
        config.resolve.fallback = {fs: false}
        config.module.rules.push({
            test: /\.js/,
            enforce: 'pre',
            include: /node_modules[\\\/]monaco-editor[\\\/]esm/,
            use: monacoWebpackPlugin.loader
        });
    },
    runtimeCompiler: true,
    outputDir: 'dist', /* 输出文件目录 */
    publicPath: './',
    productionSourceMap: false,
    css: {
        extract: true, /* 是否使用css分离插件 ExtractTextPlugin */
        sourceMap: false, /* 不开启 CSS source maps */
        loaderOptions: {}, /* css预设器配置项 */
        // modules: false /* 启用 CSS modules for all css / pre-processor files */
    },
    transpileDependencies: ['@sei/sei-base', '@sei/sei-ui'],
    devServer: {
        hot: true, /* 开启热点 */
        open: false,
        compress: false,
        proxy: {
            '/api': {
                target: 'http://127.0.0.1:8081/',
                ws: true,
                changeOrigin: true
            }
        }
    }
};
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
34
35
36
37
38
39
40
41
42

# 配置babel.config.js

配置项目babel.config.js,内容大概如下:

module.exports = {
    presets: [
        '@vue/cli-plugin-babel/preset'
    ],
    plugins: [
        ['import', {libraryName: '@sei/sei-ui', libraryDirectory: 'src/components'}, '@sei/sei-ui'],
        ['import', {libraryName: "@sei/sei-base", libraryDirectory: 'src/components'}, "@sei/sei-base"],
        ['component', {libraryName: 'element-ui', styleLibraryName: 'theme-chalk'}, 'element-ui']
    ]
};
1
2
3
4
5
6
7
8
9
10

# 配置postcss.config.js

配置项目postcss.config.js,内容大概如下:

module.exports = {
    plugins: {
        autoprefixer: {} /* 自动补全css前缀 */
    }
};
1
2
3
4
5