feat(docs): add interactive cloud services demo components

Add 10 new Vue components for cloud services documentation with interactive demos including:
- Cloud services overview and provider comparison
- Pricing calculator and region latency visualization
- Compute instance configurator and storage type explorer
- API call workflow and deployment process steps
- IAM structure and policy editor demos
This commit is contained in:
sanbuphy
2026-02-11 09:45:45 +08:00
parent a1198630be
commit 99d608d2a0
13 changed files with 2529 additions and 877 deletions
@@ -0,0 +1,224 @@
<template>
<div class="iam-structure">
<div class="structure-layers">
<div
v-for="(layer, index) in layers"
:key="index"
class="layer"
:class="{ active: selectedLayer === index }"
@click="selectLayer(index)"
>
<div class="layer-icon">{{ layer.icon }}</div>
<div class="layer-content">
<div class="layer-name">{{ layer.name }}</div>
<div class="layer-desc">{{ layer.shortDesc }}</div>
</div>
</div>
</div>
<div v-if="selectedLayerData" class="layer-detail">
<div class="detail-header">
<span class="detail-icon">{{ selectedLayerData.icon }}</span>
<span class="detail-name">{{ selectedLayerData.name }}</span>
</div>
<div class="detail-desc">{{ selectedLayerData.description }}</div>
<div class="detail-examples">
<div class="example-title">示例</div>
<ul>
<li v-for="(example, i) in selectedLayerData.examples" :key="i">
{{ example }}
</li>
</ul>
</div>
</div>
</div>
</template>
<script setup>
import { ref, computed } from 'vue'
const selectedLayer = ref(0)
const layers = [
{
icon: '👑',
name: '根账号',
shortDesc: '最高权限',
description: '云账号的所有者,拥有全部资源的完全控制权限。建议仅用于初始设置,日常操作使用子账号。',
examples: [
'创建/删除 IAM 用户',
'管理账单和支付方式',
'关闭账号',
'恢复已删除资源'
]
},
{
icon: '👤',
name: 'IAM 用户',
shortDesc: '个人身份',
description: '为具体人员(如员工)创建的长期凭证,用于日常登录和操作云服务。',
examples: [
'开发人员账号',
'运维人员账号',
'只读审计账号',
'API 调用账号'
]
},
{
icon: '👥',
name: '用户组',
shortDesc: '批量管理',
description: '将多个用户归为一组,统一分配权限,简化管理。',
examples: [
'开发组(开发权限)',
'运维组(运维权限)',
'财务组(账单权限)',
'审计组(只读权限)'
]
},
{
icon: '🎭',
name: '角色',
shortDesc: '临时授权',
description: '一种临时身份,可以被切换或赋予其他账号/服务,具有时效性更安全。',
examples: [
'跨账号访问角色',
'服务角色(如 Lambda',
'临时运维角色',
'第三方登录角色'
]
},
{
icon: '📋',
name: '策略',
shortDesc: '权限规则',
description: '定义"谁可以对什么资源执行什么操作"的规则文档,以 JSON 格式编写。',
examples: [
'允许访问 S3 存储桶',
'禁止删除 EC2 实例',
'只允许查看 RDS',
'允许特定时间段访问'
]
}
]
const selectedLayerData = computed(() => layers[selectedLayer.value])
function selectLayer(index) {
selectedLayer.value = index
}
</script>
<style scoped>
.iam-structure {
border: 1px solid var(--vp-c-divider);
border-radius: 8px;
background-color: var(--vp-c-bg-soft);
padding: 1rem;
margin: 1rem 0;
}
.structure-layers {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.layer {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem;
background: var(--vp-c-bg);
border: 1px solid var(--vp-c-divider);
border-radius: 6px;
cursor: pointer;
transition: all 0.2s;
}
.layer:hover {
border-color: var(--vp-c-brand);
}
.layer.active {
border-color: var(--vp-c-brand);
background: var(--vp-c-brand-soft);
}
.layer-icon {
font-size: 1.25rem;
width: 32px;
text-align: center;
}
.layer-content {
flex: 1;
}
.layer-name {
font-weight: 600;
font-size: 0.9rem;
margin-bottom: 0.15rem;
}
.layer-desc {
font-size: 0.75rem;
color: var(--vp-c-text-2);
}
.layer-detail {
margin-top: 1rem;
padding-top: 1rem;
border-top: 1px solid var(--vp-c-divider);
}
.detail-header {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.75rem;
}
.detail-icon {
font-size: 1.25rem;
}
.detail-name {
font-weight: 600;
font-size: 1rem;
}
.detail-desc {
font-size: 0.85rem;
color: var(--vp-c-text-2);
margin-bottom: 0.75rem;
line-height: 1.5;
}
.detail-examples {
background: var(--vp-c-bg);
padding: 0.75rem;
border-radius: 6px;
}
.example-title {
font-weight: 500;
font-size: 0.85rem;
margin-bottom: 0.5rem;
}
.detail-examples ul {
margin: 0;
padding-left: 1.25rem;
font-size: 0.8rem;
color: var(--vp-c-text-2);
}
.detail-examples li {
margin-bottom: 0.25rem;
}
.detail-examples li:last-child {
margin-bottom: 0;
}
</style>
@@ -0,0 +1,211 @@
<template>
<div class="policy-editor-demo">
<div class="editor-layout">
<div class="editor-panel">
<div class="panel-title">策略编辑器</div>
<div class="action-list">
<div
v-for="action in actions"
:key="action.id"
class="action-item"
>
<label class="checkbox">
<input
type="checkbox"
v-model="selectedActions"
:value="action.id"
>
<span>{{ action.name }}</span>
</label>
<span class="action-desc">{{ action.desc }}</span>
</div>
</div>
</div>
<div class="preview-panel">
<div class="panel-title">生成的策略</div>
<pre><code>{{ generatedPolicy }}</code></pre>
</div>
</div>
<div class="effect-preview">
<div class="effect-title">权限效果预览</div>
<div class="effect-list">
<div
v-for="effect in effectList"
:key="effect.action"
class="effect-item"
:class="effect.allowed ? 'allowed' : 'denied'"
>
<span class="effect-icon">{{ effect.allowed ? '✓' : '✗' }}</span>
<span class="effect-text">{{ effect.name }}</span>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, computed } from 'vue'
const selectedActions = ref(['describe', 'start'])
const actions = [
{ id: 'describe', name: '查看实例', desc: 'DescribeInstances', resource: 'ecs:Describe*' },
{ id: 'start', name: '启动实例', desc: 'StartInstance', resource: 'ecs:StartInstance' },
{ id: 'stop', name: '停止实例', desc: 'StopInstance', resource: 'ecs:StopInstance' },
{ id: 'reboot', name: '重启实例', desc: 'RebootInstance', resource: 'ecs:RebootInstance' },
{ id: 'create', name: '创建实例', desc: 'CreateInstance', resource: 'ecs:CreateInstance' },
{ id: 'delete', name: '删除实例', desc: 'DeleteInstance', resource: 'ecs:DeleteInstance' }
]
const generatedPolicy = computed(() => {
const selected = actions.filter(a => selectedActions.value.includes(a.id))
const actionList = selected.map(a => a.resource)
return JSON.stringify({
Version: "1",
Statement: [
{
Effect: "Allow",
Action: actionList,
Resource: "*"
}
]
}, null, 2)
})
const effectList = computed(() => {
return actions.map(action => ({
name: action.name,
action: action.id,
allowed: selectedActions.value.includes(action.id)
}))
})
</script>
<style scoped>
.policy-editor-demo {
border: 1px solid var(--vp-c-divider);
border-radius: 8px;
background-color: var(--vp-c-bg-soft);
padding: 1rem;
margin: 1rem 0;
}
.editor-layout {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
margin-bottom: 1rem;
}
.editor-panel,
.preview-panel {
background: var(--vp-c-bg);
border-radius: 6px;
padding: 0.75rem;
}
.panel-title {
font-weight: 600;
font-size: 0.85rem;
margin-bottom: 0.75rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--vp-c-divider);
}
.action-list {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.action-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.4rem 0;
}
.checkbox {
display: flex;
align-items: center;
gap: 0.5rem;
cursor: pointer;
font-size: 0.85rem;
}
.checkbox input {
cursor: pointer;
}
.action-desc {
font-size: 0.75rem;
color: var(--vp-c-text-2);
font-family: var(--vp-font-family-mono);
}
.preview-panel pre {
margin: 0;
font-size: 0.75rem;
line-height: 1.5;
overflow-x: auto;
}
.preview-panel code {
font-family: var(--vp-font-family-mono);
color: var(--vp-c-text-1);
}
.effect-preview {
background: var(--vp-c-bg);
border-radius: 6px;
padding: 0.75rem;
}
.effect-title {
font-weight: 600;
font-size: 0.85rem;
margin-bottom: 0.75rem;
}
.effect-list {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.5rem;
}
.effect-item {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.4rem 0.6rem;
border-radius: 4px;
font-size: 0.8rem;
}
.effect-item.allowed {
background: rgba(34, 197, 94, 0.1);
color: #16a34a;
}
.effect-item.denied {
background: rgba(239, 68, 68, 0.1);
color: #dc2626;
}
.effect-icon {
font-weight: 600;
}
@media (max-width: 640px) {
.editor-layout {
grid-template-columns: 1fr;
}
.effect-list {
grid-template-columns: repeat(2, 1fr);
}
}
</style>