Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
feat(demo): proxy
Browse files Browse the repository at this point in the history
1.Add proxy to support both static data and collaborative editing mode 2.Add resources
  • Loading branch information
mengshukeji committed Nov 27, 2020
1 parent e027ac2 commit bc64807
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 1,837 deletions.
7 changes: 6 additions & 1 deletion docs/guide/resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ If you have written or found an excellent tutorial and want to recommend it to u
- [Basic usage of Luckysheet, use `loadUrl` to load server data](https://blog.csdn.net/DCDC2020/article/details/108486525)
- [Luckysheet import and export implementation-Java background processing](https://blog.csdn.net/u014632228/article/details/109738221)

## Back-end
## Front-end case

### Community Case
- [luckysheet-vue-importAndExport](https://github.com/oy-paddy/luckysheet-vue-importAndExport/tree/master/)

## Back-end case

### Official case
- [Java backend Luckysheet Server](https://github.com/mengshukeji/LuckysheetServer)
Expand Down
7 changes: 6 additions & 1 deletion docs/zh/guide/resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
- [Luckysheet基础用法,使用loadUrl加载服务端数据](https://blog.csdn.net/DCDC2020/article/details/108486525)
- [Luckysheet 导入与导出实现 - Java后台处理](https://blog.csdn.net/u014632228/article/details/109738221)

## 后台
## 前端案例

### 社区案例
- [luckysheet-vue-importAndExport](https://github.com/oy-paddy/luckysheet-vue-importAndExport/tree/master/)

## 后端案例

### 官方案例
- [Java 后台 Luckysheet Server](https://github.com/mengshukeji/LuckysheetServer)
Expand Down
12 changes: 11 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const del = require('delete');
// Refresh the browser in real time
const browserSync = require('browser-sync').create();
const reload = browserSync.reload;
// proxy
const { createProxyMiddleware } = require('http-proxy-middleware');
// According to html reference, files are merged
// const useref = require('gulp-useref');
// File merge
Expand Down Expand Up @@ -117,11 +119,19 @@ function clean() {
return del([paths.dist]);
}

// proxy middleware
const apiProxy = createProxyMiddleware('/luckysheet/', {
target: 'http://luckysheet.lashuju.com/',
changeOrigin: true, // for vhosted sites
ws: true, // proxy websockets
});

// Static server
function serve(done) {
browserSync.init({
server: {
baseDir: paths.dist
baseDir: paths.dist,
middleware: [apiProxy],//proxy
},
ghostMode: false, //默认true,滚动和表单在任何设备上输入将被镜像到所有设备里,会影响本地的协同编辑消息,故关闭
}, done)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"gulp-if": "^3.0.0",
"gulp-uglify": "^3.0.2",
"gulp-useref": "^4.0.1",
"http-proxy-middleware": "^1.0.6",
"rollup": "^2.32.1",
"rollup-plugin-terser": "^6.1.0",
"standard-version": "^8.0.2",
Expand Down
18 changes: 6 additions & 12 deletions src/demoData/demoFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,12 @@
* Get url parameters
*/
function getRequest() {
  var url = window.location.search; //获取url中"?"符后的字串
  var theRequest = new Object();
  if (url.indexOf("?") != -1) {
    var str = url.substr(1);
    strs = str.split("&");
    for(var i = 0; i < strs.length; i ++) {

      theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);

    }
  }
  return theRequest;
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
function(m,key,value) {
vars[key] = value;
});
return vars;
}

window.luckysheetDemoUtil = {
Expand Down
Loading

0 comments on commit bc64807

Please sign in to comment.