mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-06 23:00:25 +08:00
使用CodeMirror高亮各处的配置信息
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
Vue.component("download-link", {
|
Vue.component("download-link", {
|
||||||
props: ["v-element", "v-file"],
|
props: ["v-element", "v-file", "v-value"],
|
||||||
created: function () {
|
created: function () {
|
||||||
let that = this
|
let that = this
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@@ -18,15 +18,20 @@ Vue.component("download-link", {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
composeURL: function () {
|
composeURL: function () {
|
||||||
|
let text = ""
|
||||||
|
if (this.vValue != null) {
|
||||||
|
text = this.vValue
|
||||||
|
} else {
|
||||||
let e = document.getElementById(this.vElement)
|
let e = document.getElementById(this.vElement)
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
teaweb.warn("找不到要下载的内容")
|
teaweb.warn("找不到要下载的内容")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let text = e.innerText
|
text = e.innerText
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
text = e.textContent
|
text = e.textContent
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Tea.url("/ui/download", {
|
return Tea.url("/ui/download", {
|
||||||
file: this.file,
|
file: this.file,
|
||||||
text: text
|
text: text
|
||||||
|
|||||||
54
web/public/js/components/common/source-code-box.js
Normal file
54
web/public/js/components/common/source-code-box.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
let sourceCodeBoxIndex = 0
|
||||||
|
|
||||||
|
Vue.component("source-code-box", {
|
||||||
|
props: ["type", "id"],
|
||||||
|
mounted: function () {
|
||||||
|
let box = document.getElementById("source-code-box-" + this.index)
|
||||||
|
let valueBox = document.getElementById(this.valueBoxId)
|
||||||
|
let value = ""
|
||||||
|
if (valueBox.textContent != null) {
|
||||||
|
value = valueBox.textContent
|
||||||
|
} else if (valueBox.innerText != null) {
|
||||||
|
value = valueBox.innerText
|
||||||
|
}
|
||||||
|
let boxEditor = CodeMirror.fromTextArea(box, {
|
||||||
|
theme: "idea",
|
||||||
|
lineNumbers: true,
|
||||||
|
value: "",
|
||||||
|
readOnly: true,
|
||||||
|
showCursorWhenSelecting: true,
|
||||||
|
height: "auto",
|
||||||
|
//scrollbarStyle: null,
|
||||||
|
viewportMargin: Infinity,
|
||||||
|
lineWrapping: true,
|
||||||
|
highlightFormatting: false,
|
||||||
|
indentUnit: 4,
|
||||||
|
indentWithTabs: true
|
||||||
|
})
|
||||||
|
boxEditor.setValue(value)
|
||||||
|
|
||||||
|
let info = CodeMirror.findModeByMIME(this.type)
|
||||||
|
if (info != null) {
|
||||||
|
boxEditor.setOption("mode", info.mode)
|
||||||
|
CodeMirror.modeURL = "/codemirror/mode/%N/%N.js"
|
||||||
|
CodeMirror.autoLoadMode(boxEditor, info.mode)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: function () {
|
||||||
|
let index = sourceCodeBoxIndex++
|
||||||
|
|
||||||
|
let valueBoxId = 'source-code-box-value-' + sourceCodeBoxIndex
|
||||||
|
if (this.id != null) {
|
||||||
|
valueBoxId = this.id
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
index: index,
|
||||||
|
valueBoxId: valueBoxId
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template: `<div class="source-code-box">
|
||||||
|
<div style="display: none" :id="valueBoxId"><slot></slot></div>
|
||||||
|
<textarea :id="'source-code-box-' + index"></textarea>
|
||||||
|
</div>`
|
||||||
|
})
|
||||||
@@ -643,4 +643,15 @@ td .label.small {
|
|||||||
td {
|
td {
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
.source-code-box .CodeMirror {
|
||||||
|
border: 1px solid #eee;
|
||||||
|
height: auto !important;
|
||||||
|
}
|
||||||
|
.source-code-box .CodeMirror-vscrollbar {
|
||||||
|
width: 6px;
|
||||||
|
border-radius: 3px !important;
|
||||||
|
}
|
||||||
|
.source-code-box .CodeMirror-vscrollbar::-webkit-scrollbar-thumb {
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
/*# sourceMappingURL=@layout.css.map */
|
/*# sourceMappingURL=@layout.css.map */
|
||||||
File diff suppressed because one or more lines are too long
@@ -706,3 +706,20 @@ td .label.small {
|
|||||||
td {
|
td {
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// codemirror
|
||||||
|
.source-code-box {
|
||||||
|
.CodeMirror {
|
||||||
|
border: 1px solid #eee;
|
||||||
|
height: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-vscrollbar {
|
||||||
|
width: 6px;
|
||||||
|
border-radius: 3px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-vscrollbar::-webkit-scrollbar-thumb {
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
{$template "menu"}
|
{$template "menu"}
|
||||||
|
{$template "/code_editor"}
|
||||||
|
|
||||||
<h3>安装步骤</h3>
|
<h3>安装步骤</h3>
|
||||||
<ol class="ui list">
|
<ol class="ui list">
|
||||||
@@ -15,8 +16,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="title">configs/api.yaml<em><br/><download-link :v-element="'api-code'" :v-file="'api.yaml'">[下载]</download-link></em></td>
|
<td class="title">configs/api.yaml<em><br/><download-link :v-element="'api-code'" :v-file="'api.yaml'">[下载]</download-link></em></td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="api-code">nodeId: "{{node.uniqueId}}"
|
<source-code-box id="api-code" type="text/yaml">nodeId: "{{node.uniqueId}}"
|
||||||
secret: "{{node.secret}}"</pre>
|
secret: "{{node.secret}}"</source-code-box>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -27,7 +28,7 @@ secret: "{{node.secret}}"</pre>
|
|||||||
<span v-else class="red">无法生成配置内容,错误原因:</span>
|
<span v-else class="red">无法生成配置内容,错误原因:</span>
|
||||||
{{dbConfig.error}}
|
{{dbConfig.error}}
|
||||||
</span>
|
</span>
|
||||||
<pre v-show="dbConfig.config.length > 0" id="db-code">{{dbConfig.config}}</pre>
|
<source-code-box id="db-code" type="text/yaml">{{dbConfig.config}}</source-code-box>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
{$template "menu"}
|
{$template "menu"}
|
||||||
{$template "/left_menu"}
|
{$template "/left_menu"}
|
||||||
|
{$template "/code_editor"}
|
||||||
|
|
||||||
<div class="right-box">
|
<div class="right-box">
|
||||||
<p>在官网下载节点安装包,然后通过修改节点安装包中的<code-label>configs/cluster.yaml</code-label>,启动后会自动注册节点。</p>
|
<p>在官网下载节点安装包,然后通过修改节点安装包中的<code-label>configs/cluster.yaml</code-label>,启动后会自动注册节点。</p>
|
||||||
@@ -10,10 +11,10 @@
|
|||||||
<em><download-link :v-element="'cluster-config-box'" :v-file="'cluster.yaml'">[下载]</download-link></em>
|
<em><download-link :v-element="'cluster-config-box'" :v-file="'cluster.yaml'">[下载]</download-link></em>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="cluster-config-box">rpc:
|
<source-code-box id="cluster-config-box" type="text/yaml">rpc:
|
||||||
endpoints: [ {{cluster.endpoints}} ]
|
endpoints: [ {{cluster.endpoints}} ]
|
||||||
clusterId: "{{cluster.uniqueId}}"
|
clusterId: "{{cluster.uniqueId}}"
|
||||||
secret: "{{cluster.secret}}"</pre>
|
secret: "{{cluster.secret}}"</source-code-box>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
|
{$template "node_menu"}
|
||||||
|
{$template "/code_editor"}
|
||||||
|
|
||||||
{$template "node_menu"}
|
<!-- 已安装 -->
|
||||||
|
<div v-if="node.isInstalled">
|
||||||
<!-- 已安装 -->
|
|
||||||
<div v-if="node.isInstalled">
|
|
||||||
<div class="ui message green">当前节点为已安装状态。</div>
|
<div class="ui message green">当前节点为已安装状态。</div>
|
||||||
<a href="" @click.prevent="updateNodeIsInstalled(false)">[修改为未安装状态]</a>
|
<a href="" @click.prevent="updateNodeIsInstalled(false)">[修改为未安装状态]</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 未安装 -->
|
<!-- 未安装 -->
|
||||||
<div v-if="!node.isInstalled">
|
<div v-if="!node.isInstalled">
|
||||||
<h3>方法1:通过SSH自动安装</h3>
|
<h3>方法1:通过SSH自动安装</h3>
|
||||||
|
|
||||||
<div v-if="installStatus != null && (installStatus.isRunning || installStatus.isFinished)"
|
<div v-if="installStatus != null && (installStatus.isRunning || installStatus.isFinished)"
|
||||||
@@ -33,10 +33,10 @@
|
|||||||
<td>配置文件<em>(configs/api.yaml)</em><br/>
|
<td>配置文件<em>(configs/api.yaml)</em><br/>
|
||||||
<em><download-link :v-element="'rpc-code'" :v-file="'api.yaml'">[下载]</download-link ></em></td>
|
<em><download-link :v-element="'rpc-code'" :v-file="'api.yaml'">[下载]</download-link ></em></td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="rpc-code">rpc:
|
<source-code-box id="rpc-code" type="text/yaml">rpc:
|
||||||
endpoints: [ {{apiEndpoints}} ]
|
endpoints: [ {{apiEndpoints}} ]
|
||||||
nodeId: "{{node.uniqueId}}"
|
nodeId: "{{node.uniqueId}}"
|
||||||
secret: "{{node.secret}}"</pre>
|
secret: "{{node.secret}}"</source-code-box>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -51,4 +51,4 @@ secret: "{{node.secret}}"</pre>
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<a href="" @click.prevent="updateNodeIsInstalled(true)">[修改为已安装状态]</a>
|
<a href="" @click.prevent="updateNodeIsInstalled(true)">[修改为已安装状态]</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
{$template "menu"}
|
{$template "menu"}
|
||||||
|
{$template "/code_editor"}
|
||||||
|
|
||||||
<h3>安装步骤</h3>
|
<h3>安装步骤</h3>
|
||||||
<ol class="ui list">
|
<ol class="ui list">
|
||||||
@@ -14,10 +15,10 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="title">configs/api.yaml<em><br/><download-link :v-element="'api-code'" :v-file="'api.yaml'">[下载]</download-link></em></td>
|
<td class="title">configs/api.yaml<em><br/><download-link :v-element="'api-code'" :v-file="'api.yaml'">[下载]</download-link></em></td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="api-code">rpc:
|
<source-code-box id="api-code" type="text/yaml">rpc:
|
||||||
endpoints: [ {{apiEndpoints}} ]
|
endpoints: [ {{apiEndpoints}} ]
|
||||||
nodeId: "{{node.uniqueId}}"
|
nodeId: "{{node.uniqueId}}"
|
||||||
secret: "{{node.secret}}"</pre>
|
secret: "{{node.secret}}"</source-code-box>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
{$template "menu"}
|
{$template "menu"}
|
||||||
|
{$template "/code_editor"}
|
||||||
|
|
||||||
<h3>安装步骤</h3>
|
<h3>安装步骤</h3>
|
||||||
<ol class="ui list">
|
<ol class="ui list">
|
||||||
@@ -14,10 +15,10 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="title">configs/api.yaml<em><br/><download-link :v-element="'api-code'" :v-file="'api.yaml'">[下载]</download-link></em></td>
|
<td class="title">configs/api.yaml<em><br/><download-link :v-element="'api-code'" :v-file="'api.yaml'">[下载]</download-link></em></td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="api-code">rpc:
|
<source-code-box id="api-code" type="text/yaml">rpc:
|
||||||
endpoints: [ {{apiEndpoints}} ]
|
endpoints: [ {{apiEndpoints}} ]
|
||||||
nodeId: "{{node.uniqueId}}"
|
nodeId: "{{node.uniqueId}}"
|
||||||
secret: "{{node.secret}}"</pre>
|
secret: "{{node.secret}}"</source-code-box>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
{$template "menu"}
|
{$template "menu"}
|
||||||
|
{$template "/code_editor"}
|
||||||
|
|
||||||
<h3>安装步骤</h3>
|
<h3>安装步骤</h3>
|
||||||
<ol class="ui list">
|
<ol class="ui list">
|
||||||
@@ -14,10 +15,10 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="title">configs/api.yaml<em><br/><download-link :v-element="'api-code'" :v-file="'api.yaml'">[下载]</download-link></em></td>
|
<td class="title">configs/api.yaml<em><br/><download-link :v-element="'api-code'" :v-file="'api.yaml'">[下载]</download-link></em></td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="api-code">rpc:
|
<source-code-box id="api-code" type="text/yaml">rpc:
|
||||||
endpoints: [ {{apiEndpoints}} ]
|
endpoints: [ {{apiEndpoints}} ]
|
||||||
nodeId: "{{node.uniqueId}}"
|
nodeId: "{{node.uniqueId}}"
|
||||||
secret: "{{node.secret}}"</pre>
|
secret: "{{node.secret}}"</source-code-box>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user