7 changed files with 310 additions and 71 deletions
-
40main.go
-
18package-lock.json
-
2package.json
-
2src/App.vue
-
203src/components/HelloWorld.vue
-
89src/components/preview/previewCodeDialg.vue
-
21src/tmp.js
@ -0,0 +1,89 @@ |
|||||
|
<template> |
||||
|
<div class="previewCode"> |
||||
|
<el-tabs v-model="activeName"> |
||||
|
<el-tab-pane |
||||
|
v-for="(item, key) in previewCode" |
||||
|
:key="key" |
||||
|
:label="key" |
||||
|
:name="key" |
||||
|
> |
||||
|
<div :id="key" class="tab-info" /> |
||||
|
</el-tab-pane> |
||||
|
</el-tabs> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import marked from "marked"; |
||||
|
import hljs from "highlight.js"; |
||||
|
import "highlight.js/styles/atelier-plateau-light.css"; |
||||
|
|
||||
|
export default { |
||||
|
name: "PreviewCode", |
||||
|
props: { |
||||
|
previewCode: { |
||||
|
type: Object, |
||||
|
default: {}, |
||||
|
}, |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
activeName: "", |
||||
|
}; |
||||
|
}, |
||||
|
mounted() { |
||||
|
marked.setOptions({ |
||||
|
renderer: new marked.Renderer(), |
||||
|
highlight: function (code) { |
||||
|
return hljs.highlightAuto(code).value; |
||||
|
}, |
||||
|
pedantic: false, |
||||
|
gfm: true, |
||||
|
tables: true, |
||||
|
breaks: false, |
||||
|
sanitize: false, |
||||
|
smartLists: true, |
||||
|
smartypants: false, |
||||
|
xhtml: false, |
||||
|
}); |
||||
|
for (const key in this.previewCode) { |
||||
|
if (this.activeName === "") { |
||||
|
this.activeName = key; |
||||
|
} |
||||
|
document.getElementById(key).innerHTML = marked(props.previewCode[key]); |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
selectText() { |
||||
|
const element = document.getElementById(this.activeName); |
||||
|
if (document.body.createTextRange) { |
||||
|
const range = document.body.createTextRange(); |
||||
|
range.moveToElementText(element); |
||||
|
range.select(); |
||||
|
} else if (window.getSelection) { |
||||
|
const selection = window.getSelection(); |
||||
|
const range = document.createRange(); |
||||
|
range.selectNodeContents(element); |
||||
|
selection.removeAllRanges(); |
||||
|
selection.addRange(range); |
||||
|
} else { |
||||
|
alert("none"); |
||||
|
} |
||||
|
}, |
||||
|
copy() { |
||||
|
this.$emit("OnCopy", this.activeName); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss"> |
||||
|
.previewCode { |
||||
|
.tab-info { |
||||
|
height: 50vh; |
||||
|
background: #fff; |
||||
|
padding: 0 20px; |
||||
|
overflow-y: scroll; |
||||
|
} |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,21 @@ |
|||||
|
func (a *$1Service) Get$2List(ctx context.Context, req *model.Gb$2ReqParams) (interface{}, error) { |
||||
|
var l []*model.Gb$2 |
||||
|
cnt, err := a.$2.Q().Filter(req).List(ctx, &l) |
||||
|
if err != nil { |
||||
|
return nil, errors.WithStack(err) |
||||
|
} |
||||
|
|
||||
|
if req.Export { |
||||
|
rst, _ := excelize.Excelize(l, |
||||
|
excelize.ColumnFilter(\"create_time\ excelize.FilterTimestamp), |
||||
|
) |
||||
|
return rst, nil |
||||
|
} |
||||
|
pagination := &schema.PaginationResult{ |
||||
|
Count: cnt, |
||||
|
List: l, |
||||
|
PageNum: req.PageNum, |
||||
|
PageSize: req.PageSize, |
||||
|
} |
||||
|
return pagination, nil |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue