Skip to content

Commit

Permalink
change: 部署调整
Browse files Browse the repository at this point in the history
  • Loading branch information
peterq committed Jun 26, 2019
1 parent 5d9ec8b commit cab15ba
Show file tree
Hide file tree
Showing 12 changed files with 479 additions and 145 deletions.
502 changes: 410 additions & 92 deletions demo/demo-online-front/package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions demo/demo-online-front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
},
"dependencies": {
"core-js": "^2.6.5",
"element-ui": "^2.7.2",
"crc32": "^0.2.2",
"deflate-js": "^0.2.3",
"element-ui": "^2.10.0",
"gzip-js": "^0.3.2",
"moment": "^2.24.0",
"vue": "^2.6.6"
"vue": "^2.6.6",
"webpack-obfuscator": "^0.18.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.5.0",
Expand Down
2 changes: 2 additions & 0 deletions demo/demo-online-front/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>pan-light | 在线体验</title>
<base href="https://qiniu-cdn.peterq.cn/pan-light/demo/">
</head>
<body>
<script>
window.debugObj = window.debugObj || {}
window.cdnPrefix = 'https://qiniu-cdn.peterq.cn/pan-light'
</script>
<noscript>
<strong>We're sorry but demo-online-front doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
Expand Down
13 changes: 11 additions & 2 deletions demo/demo-online-front/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ registerProxyChannelResolver(async function (uri) {
})

const connectionRequestMap = {}

console.log(process.env)
if (process.env.NODE_ENV === 'production') {
setInterval(function () {
window.debugObj = {}
}, 3e3)
}

$rt.onRemote("host.candidate.ok", data => {
const id = data.requestId
Expand Down Expand Up @@ -91,6 +96,7 @@ function roomHandleUserTicketTurn(room, data) {

}

let cdnPrefix = process.env.NODE_ENV === 'production' ? window.cdnPrefix : ''
$rt.on('room.new', room => {

async function getSessionInfo(ids) {
Expand All @@ -103,6 +109,8 @@ $rt.on('room.new', room => {
})
let infoMap = await $rt.call('session.public.info', {sessionIds: newOnes})
for (let id in infoMap) {
infoMap[id].avatar = cdnPrefix + infoMap[id].avatar
console.log(infoMap[id])
$state.userSessionInfo[id] = infoMap[id]
}
}
Expand Down Expand Up @@ -178,6 +186,7 @@ $rt.on('room.new', room => {
$rt.onRemote('session.new', async session => {
$state.resetData()
let infoMap = await $rt.call('session.public.info', {sessionIds: [session.id]})
infoMap[session.id].avatar = cdnPrefix + infoMap[session.id].avatar
$state.userSessionInfo.self = {...infoMap[session.id], sessionId: session.id}
$state.connected = true
})
Expand Down Expand Up @@ -420,7 +429,7 @@ async function canStart() {
function fuckDebug() {
console.clear()
document.body.innerHTML = `<h1>偷窥人家可是不好的哦</h1>`
consoleImage(location.origin + whatJpg, 240, 240)
consoleImage((cdnPrefix || location.origin) + '/demo' + whatJpg, 240, 240)
console.log('%c想要演示系统源码? 快去点个star啦, 超过 200 star 开源此在线演示系统 https://github.com/peterq/pan-light', 'font-size:24px;color:#0a0')
console.log('如果你想现在拿到源码, 你可以尝试分析一下: web端和服务端通信规则, 以及远程桌面的实现原理; 把分析结果发送到邮箱 [email protected] , 我会回复源码哦. ps:难度其实不是特别大哦.')
console.log('%c请求各位大佬不要对我的服务器进行压测, 阿里云最低配机器, 穷.', 'font-size:18px;')
Expand Down
4 changes: 4 additions & 0 deletions demo/demo-online-front/src/comp/chat/chat-main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<img :src="$state.userSessionInfo.self.avatar" style="border-radius: 50%;" alt="avatar" width="50"
height="50"/>
<p> {{$state.userSessionInfo.self.nickname}}</p>
<p style="margin: 20px" v-if="$state.ticket">
<i class="el-icon-time"></i>
体验门票号码: {{$state.ticket.order}}
</p>
</div>
<hr>
<el-tabs v-model="activeRoom" style="padding: 5px; flex: 1;">
Expand Down
13 changes: 10 additions & 3 deletions demo/demo-online-front/src/comp/hostList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div style="flex: 1; flex-wrap: wrap;">
<el-button @click="clickGetTicket"
<el-button v-show="hosts.length > 0" @click="clickGetTicket"
type="primary"
:disabled="$state.loading.getTicket" v-if="!$state.ticket"
:loading="$state.loading.getTicket">立即体验
Expand All @@ -20,6 +20,10 @@
</div>
</div>
</div>
<el-alert class="no-host" v-if="$state.connected && hosts.length === 0" style="font-size: 30px"
title="抱歉, 当前没有主机可提供远程演示服务, 请联系管理员至少开启一台主机"
type="warning">
</el-alert>
</div>
</template>

Expand Down Expand Up @@ -48,7 +52,7 @@
async getHosts() {
let hosts = await this.$rt.call('hosts.info')
this.$state.hosts = hosts
return hosts
return hosts || []
},
async clickView(host) {
await openDialog(InstanceList, host.name).getPromise()
Expand All @@ -60,9 +64,12 @@
}
</script>

<style>
<style >
* {
padding: 0;
margin: 0;
}
.no-host .el-alert__title {
font-size: 16px;
}
</style>
4 changes: 4 additions & 0 deletions demo/demo-online-front/src/comp/layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<el-container style="height: 100vh;width: 100vw;">
<el-header>
pan-light 在线体验
<el-button style="margin-left: 10px;" @click="clickReturnHome">返回官网首页</el-button>
</el-header>
<el-container class="down-con">
<el-main style="min-width: 800px">
Expand Down Expand Up @@ -45,6 +46,9 @@
})
},
methods: {
clickReturnHome() {
location.href = location.origin
}
},
watch: {
Expand Down
26 changes: 26 additions & 0 deletions demo/demo-online-front/vue.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// const JavaScriptObfuscator = require('webpack-obfuscator')

module.exports = {
devServer: {
proxy: {
Expand All @@ -8,5 +10,29 @@ module.exports = {
}

}
},
configureWebpack: {
plugins: [
/*new JavaScriptObfuscator({
compact: true,//压缩代码
controlFlowFlattening: true,////是否启用控制流扁平化(降低1.5倍的运行速度)
controlFlowFlatteningThreshold: 0.75,////应用概率;在较大的代码库中,建议降低此值,因为大量的控制流转换可能会增加代码的大小并降低代码的速度。
deadCodeInjection: true,//随机的死代码块(增加了混淆代码的大小)
deadCodeInjectionThreshold: 0.4,//死代码块的影响概率
debugProtection: false,//此选项几乎不可能使用开发者工具的控制台选项卡
debugProtectionInterval: false,//如果选中,则会在“控制台”选项卡上使用间隔强制调试模式,从而更难使用“开发人员工具”的其他功能。
disableConsoleOutput: true,//通过用空函数替换它们来禁用console.log,console.info,console.error和console.warn。这使得调试器的使用更加困难。
identifierNamesGenerator: 'hexadecimal',//标识符的混淆方式 hexadecimal(十六进制) mangled(短标识符)
log: false,
renameGlobals: false,//是否启用全局变量和函数名称的混淆
rotateStringArray: true,//通过固定和随机(在代码混淆时生成)的位置移动数组。这使得将删除的字符串的顺序与其原始位置相匹配变得更加困难。如果原始源代码不小,建议使用此选项,因为辅助函数可以引起注意。
selfDefending: true,//混淆后的代码,不能使用代码美化,同时需要配置 cpmpat:true;
stringArray: true,//删除字符串文字并将它们放在一个特殊的数组中
stringArrayEncoding: 'base64',
stringArrayThreshold: 0.75,
transformObjectKeys: true,
unicodeEscapeSequence: false//允许启用/禁用字符串转换为unicode转义序列。Unicode转义序列大大增加了代码大小,并且可以轻松地将字符串恢复为原始视图。建议仅对小型源代码启用此选项。
}, []),*/
]
}
}
38 changes: 0 additions & 38 deletions demo/demo-online-front/ws.js

This file was deleted.

3 changes: 2 additions & 1 deletion server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
cmd/data
static/
static/
pan-light-server.prod.yaml
5 changes: 4 additions & 1 deletion server/demo/demo-init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package demo

import (
"github.com/kataras/iris"
"github.com/kataras/iris/context"
"github.com/peterq/pan-light/server/demo/rpc"
)

func Init(router iris.Party, conf map[interface{}]interface{}) {
// 静态页
router.StaticWeb("/", "./static/demo")
router.Get("/", func(context context.Context) {
context.Redirect("/demo/init.html")
})
hosts := map[string]string{}
for _, host := range conf["hosts"].([]interface{}) {
hosts[host.(map[interface{}]interface{})["name"].(string)] = host.(map[interface{}]interface{})["password"].(string)
Expand Down
7 changes: 1 addition & 6 deletions server/pan-light-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"github.com/kataras/iris"
"github.com/kataras/iris/context"
"github.com/peterq/pan-light/server/artisan"
"github.com/peterq/pan-light/server/demo"
"github.com/peterq/pan-light/server/pc-api"
Expand All @@ -13,10 +12,6 @@ import (
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
app := artisan.NewApp()
//app.Get("/", func(ctx context.Context) {
// ctx.Write([]byte("Hello pan-light"))
//})
app.Get("/", func(ctx context.Context) {})

cnf, ok := os.LookupEnv("pan_light_server_conf")
if !ok {
Expand All @@ -28,5 +23,5 @@ func main() {
app.Use(artisan.ApiRecover)
app.StaticWeb("/", "./static")
pc_api.Init(app)
app.Run(iris.Addr("127.0.0.1:8081"))
app.Run(iris.Addr(":8081"))
}

0 comments on commit cab15ba

Please sign in to comment.