首页 / 更多教程 / 关于ComedyTalk项目的配置
关于ComedyTalk项目的配置
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了关于ComedyTalk项目的配置,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4205字,纯文字阅读大概需要7分钟。
内容图文
![关于ComedyTalk项目的配置](/upload/InfoBanner/zyjiaocheng/992/4a4af0afe5a44995ac7c171d46b83c9b.jpg)
宝塔linux + PM2 + Mysql + Redis + nginx + Koa2 + Vue + socket.io
nginx:
location / { try_files $uri $uri/ /index.html; } location /api{ proxy_pass http://127.0.0.1:xxxx; //xxx为指定端口号 proxy_http_version 1.1; proxy_read_timeout 3600s; proxy_set_header Upgrade $http_upgrade; proxy_set_header Host $host; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /socket{ proxy_pass http://127.0.0.1:xxxx; //xxx为指定端口号 proxy_http_version 1.1; proxy_read_timeout 3600s; proxy_set_header Upgrade $http_upgrade; proxy_set_header Host $host; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
node——只展示目录
vue——vue.config.js:
module.exports = { // publicPath: './', //publicPath取代了baseUrl outputDir: 'dist', lintOnSave: true, //eslint-loader在保存的时候进行检查 runtimeCompiler: true, //关键点在这 原来的 Compiler 换成了 runtimeCompiler // 调整内部的 webpack 配置。 chainWebpack: () => {}, configureWebpack: () => {}, // 配置 webpack-dev-server 行为。 devServer: { compress: true, //进行压缩代码 // open: process.platform === 'darwin', // open: true, //运行npm run serve完成后自动打开浏览器 // port: 80, hot: true, proxy: { '/socket.io': { target: 'https://域名/socket', // target: 'http://192.168.31.129:8765', // target: 'http://192.168.0.135:8765', changeOrigin: true, // needed for virtual hosted sites logLevel: 'debug', ws: true }, 'sockjs-node': { target: 'https://域名/socket', // target: 'http://192.168.31.129:8765', // target: 'http://192.168.0.135:8765', ws: false, changeOrigin: true }, '/api': { target: 'https://域名/api', // target: 'http://192.168.31.129:8888', // target: 'http://192.168.0.135:8888', changeOrigin: true, ws: true, pathRewrite: { '^/api': '' } }, } }, }
vue——main.js
import Vue from 'vue' import App from './App.vue' import router from './router/router.js' import axios from 'axios' import Cookies from 'vue-cookies' import store from './store/store.js' Vue.prototype.$axios= axios axios.defaults.withCredentials = true //引入vant import Vant from 'vant'; import 'vant/lib/index.css'; // import { writeHeapSnapshot } from 'v8' Vue.use(Vant).use(Cookies); //引入socketIO import SocketIO from 'socket.io-client'; import VueSocketIO from 'vue-socket.io'; Vue.use(new VueSocketIO({ debug: false, connection: SocketIO('https://域名.com') // connection: SocketIO('http://192.168.31.129:8080') // connection: SocketIO('http://192.168.0.135:8080') })); Vue.config.productionTip = false // 路由判断登录 根据路由配置文件的参数 router.beforeEach((to, from, next) => { if (to.matched.some(record => record.meta.requireAuth)){ // 判断该路由是否需要登录权限 if (Cookies.get('comedy')) { // 判断当前的token是否存在 ; 登录存入的token next(); } else { next({ path: '/login', query: {redirect: to.fullPath} // 将跳转的路由path作为参数,登录成功后跳转到该路由 }) } } else { next(); } }); new Vue({ VueSocketIO, router, store, render: h => h(App), }).$mount('#app')
vue——axios.js
import axios from 'axios' import Vue from 'vue'; import { Toast } from 'vant'; Vue.use(Toast); let loadingInstance = null // const ConfigBaseURL = `https://域名/api` // export const ConfigBaseURL = `http://192.168.31.129:8888` // export const ConfigBaseURL = `https://comedy.ilovenana.com/api` export const ConfigBaseURL = `/api` //使用create方法创建axios实例 const Service = axios.create({ timeout:5000, //设置超时时间 baseURL:ConfigBaseURL, method:'get', hearders:{ 'Content-Type':'application/json;charset=UTF-8' } }) //添加请求拦截器 Service.interceptors.request.use( config=>{ console.log("请求中"); loadingInstance = Toast.loading({ duration:0, message: '加载中...', forbidClick: true, }); return config },error=>{ Promise.reject(error); } ) // 添加响应拦截器 Service.interceptors.response.use( response => { console.log("响应成功"); loadingInstance.close() return response }, error => { console.log( error) console.log("响应失败"); loadingInstance.close() return Promise.reject(error) }) export default Service;
vue——router.js
import Vue from 'vue' import VueRouter from 'vue-router' Vue.use(VueRouter) const routes=[ { path:'/', name:"Home", meta: { requireAuth: true, }, component:()=>import('../views/Index.vue') }, { path:'/login', name:"Login", component:()=>import('../views/Login.vue') }, ... ] const router = new VueRouter({ mode:'history', routes }) export default router
内容总结
以上是互联网集市为您收集整理的关于ComedyTalk项目的配置全部内容,希望文章能够帮你解决关于ComedyTalk项目的配置所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。