GithubHelp home page GithubHelp logo

tanbinh123 / ujcms-cp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ujcms/ujcms-cp

1.0 1.0 0.0 574 KB

UJCMS-CP是UJCMS的后台前端项目。使用TypeScript、Vue3、ElementPlus、TailwindCSS开发。

Home Page: https://www.ujcms.com

License: GNU General Public License v2.0

Shell 0.04% JavaScript 10.32% TypeScript 15.11% Handlebars 2.76% HTML 0.08% Vue 71.24% SCSS 0.45%

ujcms-cp's Introduction

UJCMS-CP

UJCMS-CP是UJCMS的后台前端项目。使用 TypeScript、Vite 2、Vue 3、ElementPlus 2、TailwindCSS 3、VueRouter、VueI18n 开发。

需要启动UJCMS主项目才可以使用,不可单独运行(无法访问后端接口)。

如不需要修改UJCMS的后台界面,则不必启动此项目。UJCMS/src/main/webapp/cp目录已包含本项目编译后的代码,直接运行UJCMS主项目即可。

搭建步骤

  • 使用 vscode 开发工具。
  • 安装 node 环境。建议 node 14 版本,最低为 node 12.14 版本。
  • 使用淘宝 npm 镜像。
  • 安装依赖,执行:npm install
  • 启动程序,执行:npm run dev
  • 访问:http://localhost:9520
  • 用户名:admin,密码:password。

编译及部署

  • 执行:npm run build
  • 编译后的程序在/dist目录。
  • /dist目录里的文件拷贝至主项目UJCMS的/src/main/webapp/cp目录下(先将原目录下的文件删除)。

前后端分开部署

通常前端和后端程序部署到同一个应用,即将前端程序复制到主项目UJCMS的/cp目录。以演示站点为例,后端接口地址为https://demo.ujcms.com/api,前端访问地址则为https://demo.ujcms.com/cp/。这样可以避免跨域问题,是最简单的部署方式。

如果需要将前后端部署到不同域名或端口,如后端接口地址为http://www.example.com/api,前端地址为http://www.frontend.com。由于前后端域名不同,前端直接访问后端接口会出现跨域错误。这时需要在前端服务器部署反向代理,解决跨域问题。以nginx为例:

# 代理 api 接口
location /api {
    proxy_pass http://www.example.com;
}
# 代理上传文件
location /uploads {
    proxy_pass http://www.example.com;
}

开发模式启动时,情况也类似,后端接口地址为http://localhost:8080/api,前端地址为http://localhost:9520。前后端端口不同,也属于跨域。但前端开发在状态启动时,会自动开启代理,相关配置在vite.config.ts文件中。类似以下代码:

proxy: {
    '/api': {
        target: env.VITE_PROXY,
        changeOrigin: true,
    },
    '/uploads': {
        target: env.VITE_PROXY,
        changeOrigin: true,
    },
},

ujcms-cp's People

Contributors

ujcms avatar

Stargazers

Tan Binh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.