148 lines
3.0 KiB
Vue
148 lines
3.0 KiB
Vue
<template>
|
|
<div class="article-container">
|
|
<div class="plugin-header">
|
|
<h1>{{ $t('article.title') }}</h1>
|
|
<p>{{ $t('article.description') }}</p>
|
|
</div>
|
|
|
|
<div class="plugin-content">
|
|
<el-card shadow="hover">
|
|
<template #header>
|
|
<div class="card-header">
|
|
<span>{{ $t('article.card_title') }}</span>
|
|
<el-button type="primary" @click="fetchTestData">
|
|
{{ $t('article.refresh_btn') }}
|
|
</el-button>
|
|
</div>
|
|
</template>
|
|
|
|
<div v-loading="loading" class="card-body">
|
|
<div v-if="error" class="error-message">
|
|
<el-alert
|
|
:title="error"
|
|
type="error"
|
|
show-icon
|
|
/>
|
|
</div>
|
|
|
|
<div v-else-if="testData" class="plugin-data">
|
|
<el-descriptions :column="1" border>
|
|
<el-descriptions-item label="测试消息">
|
|
{{ testData.msg }}
|
|
</el-descriptions-item>
|
|
<el-descriptions-item label="数据">
|
|
{{ testData.data }}
|
|
</el-descriptions-item>
|
|
</el-descriptions>
|
|
</div>
|
|
|
|
<div v-else class="empty-state">
|
|
<el-empty description="暂无数据" />
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent, ref } from 'vue';
|
|
import pluginApi from '../../api/index';
|
|
|
|
export default defineComponent({
|
|
name: 'ArticleView',
|
|
setup() {
|
|
const loading = ref(false);
|
|
const error = ref<string | null>(null);
|
|
const testData = ref<{ msg?: string; data?: unknown } | null>(null);
|
|
|
|
const fetchTestData = async () => {
|
|
loading.value = true;
|
|
error.value = null;
|
|
|
|
try {
|
|
const response = await pluginApi.test();
|
|
testData.value = response;
|
|
} catch (err: unknown) {
|
|
error.value = err instanceof Error ? err.message : '网络错误';
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
};
|
|
|
|
// 初始加载数据
|
|
fetchTestData();
|
|
|
|
return {
|
|
loading,
|
|
error,
|
|
testData,
|
|
fetchTestData
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.article-container {
|
|
padding: 20px;
|
|
min-height: 80vh;
|
|
}
|
|
|
|
.plugin-header {
|
|
margin-bottom: 30px;
|
|
text-align: center;
|
|
}
|
|
|
|
.plugin-header h1 {
|
|
font-size: 28px;
|
|
font-weight: 600;
|
|
margin-bottom: 10px;
|
|
color: #303133;
|
|
}
|
|
|
|
.plugin-header p {
|
|
font-size: 16px;
|
|
color: #606266;
|
|
}
|
|
|
|
.plugin-content {
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.card-body {
|
|
padding: 20px 0;
|
|
}
|
|
|
|
.error-message {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.plugin-data {
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.plugin-data pre {
|
|
background-color: #f5f7fa;
|
|
padding: 15px;
|
|
border-radius: 4px;
|
|
overflow-x: auto;
|
|
font-size: 14px;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.empty-state {
|
|
min-height: 300px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
</style>
|