feat(front): render organization homepage on role home pages
Show current organization homepage text on student and teacher home pages and provide fallback guidance when org is not selected. Made-with: Cursor
This commit is contained in:
@@ -3,12 +3,17 @@
|
||||
<div class="header">
|
||||
欢迎回来,{{name}}
|
||||
</div>
|
||||
<div class="org-homepage-card">
|
||||
<div class="org-homepage-title">机构首页:{{ currentOrgName || "未选择机构" }}</div>
|
||||
<pre class="org-homepage-content">{{ homepageContent }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent } from 'vue';
|
||||
import { computed, defineComponent, onMounted, ref } from 'vue';
|
||||
import useUser from "~/store/user";
|
||||
import useOrg from "~/store/org";
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
@@ -16,13 +21,31 @@ export default defineComponent({
|
||||
setup() {
|
||||
|
||||
const usingUser = useUser();
|
||||
const { store: orgStore, getHomepage } = useOrg();
|
||||
const homepageContent = ref("机构暂未配置首页内容。");
|
||||
|
||||
const name = computed(() => usingUser.store.current.real_name)
|
||||
const currentOrgName = computed(() => {
|
||||
const currentOrgId = orgStore.currentOrgId;
|
||||
if (!currentOrgId) return "";
|
||||
return orgStore.orgs.find((org) => org.id === currentOrgId)?.org_name || currentOrgId;
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
if (!orgStore.currentOrgId) {
|
||||
homepageContent.value = "请先在“我的”页选择机构。";
|
||||
return;
|
||||
}
|
||||
const markdownText = await getHomepage(orgStore.currentOrgId);
|
||||
homepageContent.value = (markdownText || "").trim() || "机构暂未配置首页内容。";
|
||||
});
|
||||
|
||||
|
||||
|
||||
return {
|
||||
name
|
||||
name,
|
||||
currentOrgName,
|
||||
homepageContent,
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -41,5 +64,29 @@ export default defineComponent({
|
||||
background: #FFFFFF;
|
||||
}
|
||||
|
||||
.org-homepage-card {
|
||||
margin: 0.24rem 0.24rem 0;
|
||||
padding: 0.24rem;
|
||||
background: #ffffff;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.org-homepage-title {
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.16rem;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.org-homepage-content {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
color: #444;
|
||||
line-height: 1.6;
|
||||
font-family: inherit;
|
||||
font-size: 0.28rem;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,12 +3,17 @@
|
||||
<div class="header">
|
||||
欢迎回来,{{name}}
|
||||
</div>
|
||||
<div class="org-homepage-card">
|
||||
<div class="org-homepage-title">机构首页:{{ currentOrgName || "未选择机构" }}</div>
|
||||
<pre class="org-homepage-content">{{ homepageContent }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent } from 'vue';
|
||||
import { computed, defineComponent, onMounted, ref } from 'vue';
|
||||
import useUser from "~/store/user";
|
||||
import useOrg from "~/store/org";
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
@@ -16,10 +21,29 @@ export default defineComponent({
|
||||
setup() {
|
||||
|
||||
const usingUser = useUser();
|
||||
const { store: orgStore, getHomepage } = useOrg();
|
||||
const homepageContent = ref("机构暂未配置首页内容。");
|
||||
|
||||
const name = computed(() => usingUser.store.current.real_name)
|
||||
const currentOrgName = computed(() => {
|
||||
const currentOrgId = orgStore.currentOrgId;
|
||||
if (!currentOrgId) return "";
|
||||
return orgStore.orgs.find((org) => org.id === currentOrgId)?.org_name || currentOrgId;
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
if (!orgStore.currentOrgId) {
|
||||
homepageContent.value = "请先在“我的”页选择机构。";
|
||||
return;
|
||||
}
|
||||
const markdownText = await getHomepage(orgStore.currentOrgId);
|
||||
homepageContent.value = (markdownText || "").trim() || "机构暂未配置首页内容。";
|
||||
});
|
||||
|
||||
return {
|
||||
name
|
||||
name,
|
||||
currentOrgName,
|
||||
homepageContent,
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -37,5 +61,29 @@ export default defineComponent({
|
||||
padding: 0.2rem 0.32rem;
|
||||
background: #FFFFFF;
|
||||
}
|
||||
|
||||
.org-homepage-card {
|
||||
margin: 0.24rem 0.24rem 0;
|
||||
padding: 0.24rem;
|
||||
background: #ffffff;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.org-homepage-title {
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.16rem;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.org-homepage-content {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
color: #444;
|
||||
line-height: 1.6;
|
||||
font-family: inherit;
|
||||
font-size: 0.28rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user