界面布局
This commit is contained in:
		
							parent
							
								
									b2b08ccdd2
								
							
						
					
					
						commit
						0923122ce8
					
				| 
						 | 
				
			
			@ -26,6 +26,7 @@ type conf struct {
 | 
			
		|||
	StaticResourceVersion string
 | 
			
		||||
	ContextPath           string
 | 
			
		||||
	StaticPath            string
 | 
			
		||||
	MaxProcs              int
 | 
			
		||||
	RuntimeMode           string
 | 
			
		||||
	Repos                 string
 | 
			
		||||
	UserRepos             string
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,6 +7,7 @@
 | 
			
		|||
    "StaticResourceVersion": "",
 | 
			
		||||
    "ContextPath": "",
 | 
			
		||||
    "StaticPath": "",
 | 
			
		||||
    "MaxProcs": 4,
 | 
			
		||||
    "RuntimeMode": "dev",
 | 
			
		||||
    "Repos": "{pwd}/data/workspace/src",
 | 
			
		||||
    "UserRepos": "{pwd}/data/user_workspaces/{user}/src",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,6 @@ package i18n
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"flag"
 | 
			
		||||
	"github.com/golang/glog"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"net/http"
 | 
			
		||||
| 
						 | 
				
			
			@ -18,11 +17,7 @@ type locale struct {
 | 
			
		|||
// 所有的 locales.
 | 
			
		||||
var Locales = map[string]locale{}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	flag.Set("logtostderr", "true")
 | 
			
		||||
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
 | 
			
		||||
func Load() {
 | 
			
		||||
	// TODO: 加载所有语言配置
 | 
			
		||||
	bytes, _ := ioutil.ReadFile("i18n/zh_CN.json")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,14 @@
 | 
			
		|||
{
 | 
			
		||||
    "wide": "Wide"
 | 
			
		||||
 | 
			
		||||
    "wide": "Wide",
 | 
			
		||||
    "file": "文件",
 | 
			
		||||
    "run": "运行",
 | 
			
		||||
    "debug": "调试",
 | 
			
		||||
    "help": "帮助",
 | 
			
		||||
    "create_file": "创建文件",
 | 
			
		||||
    "create_dir": "创建目录",
 | 
			
		||||
    "delete": "删除",
 | 
			
		||||
    "save": "保存",
 | 
			
		||||
    "format": "格式化",
 | 
			
		||||
    "build_n_run": "构建 & 运行",
 | 
			
		||||
    "full_screen": "全屏"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										15
									
								
								main.go
								
								
								
								
							
							
						
						
									
										15
									
								
								main.go
								
								
								
								
							| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"flag"
 | 
			
		||||
	"github.com/b3log/wide/conf"
 | 
			
		||||
	"github.com/b3log/wide/editor"
 | 
			
		||||
	"github.com/b3log/wide/file"
 | 
			
		||||
| 
						 | 
				
			
			@ -12,10 +13,20 @@ import (
 | 
			
		|||
	"html/template"
 | 
			
		||||
	"math/rand"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"strconv"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Wide 中唯一一个 init 函数.
 | 
			
		||||
func init() {
 | 
			
		||||
	flag.Set("logtostderr", "true")
 | 
			
		||||
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func indexHandler(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	i18n.Load()
 | 
			
		||||
 | 
			
		||||
	model := map[string]interface{}{"Wide": conf.Wide, "i18n": i18n.GetLangs(r), "locale": i18n.GetLocale(r)}
 | 
			
		||||
 | 
			
		||||
	session, _ := user.Session.Get(r, "wide-session")
 | 
			
		||||
| 
						 | 
				
			
			@ -49,6 +60,10 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
 | 
			
		|||
func main() {
 | 
			
		||||
	conf.Load()
 | 
			
		||||
 | 
			
		||||
	runtime.GOMAXPROCS(conf.Wide.MaxProcs)
 | 
			
		||||
 | 
			
		||||
	defer glog.Flush()
 | 
			
		||||
 | 
			
		||||
	// 静态资源
 | 
			
		||||
	http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -75,6 +75,12 @@ ul {
 | 
			
		|||
}
 | 
			
		||||
/* end framework */
 | 
			
		||||
 | 
			
		||||
/* start output */
 | 
			
		||||
#output {
 | 
			
		||||
	width: 100%;
 | 
			
		||||
}
 | 
			
		||||
/* end output */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,7 +69,7 @@ var wide = {
 | 
			
		|||
    curNode: undefined,
 | 
			
		||||
    curEditor: undefined,
 | 
			
		||||
    _initLayout: function () {
 | 
			
		||||
        var mainH = $(window).height() - $(".menu").height() - $(".footer").height();
 | 
			
		||||
        var mainH = $(window).height() - $(".menu").height() - $(".footer").height() - 2;
 | 
			
		||||
        $(".content, .ztree").height(mainH);
 | 
			
		||||
        
 | 
			
		||||
        $(".edit-panel").height(mainH - $(".output").height());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,8 +13,16 @@
 | 
			
		|||
        <link rel="stylesheet" href="{{.Wide.StaticServer}}/static/css/base.css">
 | 
			
		||||
    </head>
 | 
			
		||||
    <body>
 | 
			
		||||
        <div class="menu">
 | 
			
		||||
            <a href="/doc/{{.locale}}/index.html" target="_blank">Help</a>
 | 
			
		||||
        <div class="menu fn-clear">
 | 
			
		||||
            <a href="/doc/{{.locale}}/index.html" target="_blank">{{.i18n.file}}</a>
 | 
			
		||||
            <a href="/doc/{{.locale}}/index.html" target="_blank">{{.i18n.run}}</a>
 | 
			
		||||
            <a href="/doc/{{.locale}}/index.html" target="_blank">{{.i18n.debug}}</a>
 | 
			
		||||
            <a href="/doc/{{.locale}}/index.html" target="_blank">{{.i18n.help}}</a>
 | 
			
		||||
            <div class="toolbars fn-right">
 | 
			
		||||
                <button onclick="wide.save()">{{.i18n.save}}</button>
 | 
			
		||||
                <button onclick="wide.fmt()">{{.i18n.format}}</button>
 | 
			
		||||
                <button onclick="wide.run()">{{.i18n.build_n_run}}</button>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
        <div class="content">
 | 
			
		||||
| 
						 | 
				
			
			@ -25,16 +33,16 @@
 | 
			
		|||
                    <!-- 目录右键菜单 -->
 | 
			
		||||
                    <div id="dirRMenu" class="fn-none">
 | 
			
		||||
                        <ul>
 | 
			
		||||
                            <li onclick="tree.newFile();">create file....</li>
 | 
			
		||||
                            <li onclick="tree.newDir();">create dir....</li>
 | 
			
		||||
                            <li onclick="tree.removeIt();">delete it....</li>
 | 
			
		||||
                            <li onclick="tree.newFile();">{{.i18n.create_file}}</li>
 | 
			
		||||
                            <li onclick="tree.newDir();">{{.i18n.create_file}}</li>
 | 
			
		||||
                            <li onclick="tree.removeIt();">{{.i18n.delete}}</li>
 | 
			
		||||
                        </ul>
 | 
			
		||||
                    </div>
 | 
			
		||||
 | 
			
		||||
                    <!-- 文件右键菜单 -->
 | 
			
		||||
                    <div id="fileRMenu" class="fn-none">
 | 
			
		||||
                        <ul>
 | 
			
		||||
                            <li onclick="tree.removeIt();">delete it....</li>
 | 
			
		||||
                            <li onclick="tree.removeIt();">{{.i18n.delete}}</li>
 | 
			
		||||
                        </ul>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
| 
						 | 
				
			
			@ -46,24 +54,19 @@
 | 
			
		|||
                <div class="edit-panel">
 | 
			
		||||
                    <div class="edit-header fn-clear">
 | 
			
		||||
                        <div class="tabs fn-left"></div>
 | 
			
		||||
                        <span class="fn-none fn-right ico-fullscreen" onclick="editors.fullscreen()">全屏</span>
 | 
			
		||||
                        <span class="fn-none fn-right ico-fullscreen" onclick="editors.fullscreen()">{{.i18n.full_screen}}</span>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div class="tabs-panel"></div>
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <div class="output">
 | 
			
		||||
                    <div>
 | 
			
		||||
                        <button onclick="wide.save()">Save</button>
 | 
			
		||||
                        <button onclick="wide.fmt()">Format</button>
 | 
			
		||||
                        <button onclick="wide.run()">Build & Run</button>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <textarea id="output" rows="7"></textarea>
 | 
			
		||||
                    <textarea id="output" rows="8"></textarea>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
        <div class="footer">
 | 
			
		||||
            copyright 88250 & vanessa
 | 
			
		||||
            |
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
        <script type="text/javascript">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue