Merge branch 'pam' of github.com:jumpserver/lina into pam

This commit is contained in:
ibuler
2025-02-10 17:43:36 +08:00

View File

@@ -1,38 +1,35 @@
<template> <template>
<div> <div>
<IBox class="radio-box"> <IBox class="radio-box">
<el-radio-group v-model="currentLanguage" @input="handleInput"> <div class="code-container">
<el-radio label="python">Python</el-radio> <el-tabs v-model="currentLanguage" @tab-click="handleInput">
<el-radio label="go">Go</el-radio> <el-tab-pane v-for="language in languages" :key="language.value" :label="language.label" :name="language.value">
</el-radio-group> <template>
<vue-markdown v-if="readme" class="code-markdown" :source="readme" />
<span v-else>{{ $tc('NoData') }}</span>
</template>
</el-tab-pane>
</el-tabs>
<div class="copy-btn">
<i
class="copy-btn el-icon-copy-document"
@click="copyContent"
/>
</div>
</div>
</IBox> </IBox>
<TwoCol>
<template>
<IBox title="README">
<vue-markdown v-if="readme" :source="readme" />
<span v-else>{{ $tc('NoData') }}</span>
</IBox>
</template>
<template #right>
<QuickActions :actions="quickActions" type="primary" />
</template>
</TwoCol>
</div> </div>
</template> </template>
<script> <script>
import { IBox } from '@/components' import { IBox } from '@/components'
import { download } from '@/utils/common'
import QuickActions from '@/components/QuickActions/index.vue'
import VueMarkdown from 'vue-markdown' import VueMarkdown from 'vue-markdown'
import { highlightBlock } from 'highlight.js' import { highlightBlock } from 'highlight.js'
import TwoCol from '@/layout/components/Page/TwoColPage.vue' import 'highlight.js/styles/github.css'
export default { export default {
name: 'SDKList', name: 'SDKList',
components: { components: {
TwoCol,
QuickActions,
IBox, IBox,
VueMarkdown VueMarkdown
}, },
@@ -40,45 +37,9 @@ export default {
return { return {
currentLanguage: 'python', currentLanguage: 'python',
readme: '', readme: '',
filenameMap: { languages: [
python: 'jms_pam-0.0.1-py3-none-any.whl', { label: 'Python', value: 'python' },
go: 'jms_pam.go' { label: 'Go', value: 'go' }
},
quickFilters: [
{
label: this.$t('Language'),
options: [
{
label: 'Python',
active: false,
filter: {
category: 'python'
}
},
{
label: 'GO',
filter: {
category: 'go'
}
}
]
}
],
quickActions: [
{
title: this.$t('Action'),
attrs: {
type: 'primary',
label: this.$tc('Download'),
model: this.currentLanguage
},
callbacks: {
click: () => {
const filename = this.filenameMap[this.currentLanguage]
download(`/download/public/sdks/${filename}/`)
}
}
}
] ]
} }
}, },
@@ -86,6 +47,14 @@ export default {
this.getSdkInfo() this.getSdkInfo()
}, },
methods: { methods: {
async copyContent() {
try {
await navigator.clipboard.writeText(this.readme)
this.$message.success('复制成功')
} catch (err) {
this.$message.error('复制失败')
}
},
highlightCode() { highlightCode() {
const codeBlocks = this.$el.querySelectorAll('pre code') const codeBlocks = this.$el.querySelectorAll('pre code')
codeBlocks.forEach((block) => { codeBlocks.forEach((block) => {
@@ -109,9 +78,19 @@ export default {
} }
} }
</script> </script>
<style lang="less" scoped>
.code-container {
position: relative;
}
.code-markdown {
min-height: 210px;
border: 1px solid #DCDFE6;
}
<style lang="scss" scoped> .copy-btn {
.radio-box { font-size: 20px;
margin-bottom: 5px; position: absolute;
top: 8px;
right: 5px;
} }
</style> </style>