feat: troubleshooting page
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s

This commit is contained in:
Methapon2001 2025-04-25 15:15:37 +07:00
parent 8c9e9abc18
commit 21699b14c5
8 changed files with 97 additions and 24 deletions

View file

@ -31,7 +31,7 @@ export default defineConfig((ctx) => {
devServer: { devServer: {
host: '0.0.0.0', host: '0.0.0.0',
open: false, open: false,
port: 5173, port: 5174,
}, },
framework: { framework: {
config: {}, config: {},

View file

@ -254,7 +254,8 @@ export default {
manual: { manual: {
title: 'Manual', title: 'Manual',
usage: 'การใช้งาน', usage: 'Usage',
troubleshooting: 'Troubleshooting',
}, },
}, },

View file

@ -255,6 +255,7 @@ export default {
manual: { manual: {
title: 'คู่มือ', title: 'คู่มือ',
usage: 'การใช้งาน', usage: 'การใช้งาน',
troubleshooting: 'การแก้ปัญหา',
}, },
}, },

View file

@ -215,6 +215,10 @@ function initMenu() {
label: 'usage', label: 'usage',
route: '/manual', route: '/manual',
}, },
{
label: 'troubleshooting',
route: '/troubleshooting',
},
], ],
}, },
]; ];

View file

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
// NOTE: Library // NOTE: Library
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { onMounted } from 'vue'; import { onMounted, watch } from 'vue';
// NOTE: Components // NOTE: Components
@ -10,22 +10,33 @@ import { onMounted } from 'vue';
import { useManualStore } from 'src/stores/manual'; import { useManualStore } from 'src/stores/manual';
import { useNavigator } from 'src/stores/navigator'; import { useNavigator } from 'src/stores/navigator';
import { Icon } from '@iconify/vue/dist/iconify.js'; import { Icon } from '@iconify/vue/dist/iconify.js';
import { useRoute } from 'vue-router';
// NOTE: Variable // NOTE: Variable
const route = useRoute();
const manualStore = useManualStore(); const manualStore = useManualStore();
const navigatorStore = useNavigator(); const navigatorStore = useNavigator();
const { dataManual } = storeToRefs(manualStore); const { dataManual, dataTroubleshooting } = storeToRefs(manualStore);
async function fetchManual() {
const res = await manualStore.getManual();
dataManual.value = res ? res : [];
}
onMounted(async () => { onMounted(async () => {
navigatorStore.current.title = 'menu.manual.title'; navigatorStore.current.title = 'menu.manual.title';
navigatorStore.current.path = [{ text: '' }]; navigatorStore.current.path = [{ text: '' }];
await fetchManual();
}); });
watch(
() => route.name,
async () => {
if (route.name === 'Manual') {
const res = await manualStore.getManual();
dataManual.value = res ? res : [];
}
if (route.name === 'Troubleshooting') {
const res = await manualStore.getTroubleshooting();
dataTroubleshooting.value = res ? res : [];
}
},
{ immediate: true },
);
</script> </script>
<template> <template>
@ -34,7 +45,7 @@ onMounted(async () => {
> >
<section class="scroll q-gutter-y-sm"> <section class="scroll q-gutter-y-sm">
<q-expansion-item <q-expansion-item
v-for="v in dataManual" v-for="v in $route.name === 'Manual' ? dataManual : dataTroubleshooting"
:key="v.labelEN" :key="v.labelEN"
:content-inset-level="0.5" :content-inset-level="0.5"
class="rounded overflow-hidden bordered" class="rounded overflow-hidden bordered"
@ -58,7 +69,11 @@ onMounted(async () => {
clickable clickable
dense dense
class="dot items-center rounded q-my-xs" class="dot items-center rounded q-my-xs"
:to="`/manual/${v.category}/${x.name}`" :to="
$route.name === 'Manual'
? `/manual/${v.category}/${x.name}`
: `/troubleshooting/${v.category}/${x.name}`
"
> >
<Icon <Icon
v-if="!!x.icon" v-if="!!x.icon"

View file

@ -56,14 +56,28 @@ onUnmounted(() => {
async function getContent() { async function getContent() {
if (!category.value || !page.value) return; if (!category.value || !page.value) return;
const res = await manualStore.getManualByPage({
category: category.value, if (ROUTE.name === 'ManualView') {
pageName: page.value, const res = await manualStore.getManualByPage({
}); category: category.value,
if (res && res.ok) { pageName: page.value,
const text = await res.text(); });
content.value = text; if (res && res.ok) {
contentParsed.value = md.parse(text, {}); const text = await res.text();
content.value = text;
contentParsed.value = md.parse(text, {});
}
}
if (ROUTE.name === 'TroubleshootingView') {
const res = await manualStore.getTroubleshootingByPage({
category: category.value,
pageName: page.value,
});
if (res && res.ok) {
const text = await res.text();
content.value = text;
contentParsed.value = md.parse(text, {});
}
} }
} }
@ -184,7 +198,9 @@ async function scrollTo(id: string) {
md.render( md.render(
content.replaceAll( content.replaceAll(
'assets/', 'assets/',
`${baseUrl}/manual/${category}/assets/`, $route.name === 'ManualView'
? `${baseUrl}/manual/${category}/assets/`
: `${baseUrl}/troubleshooting/${category}/assets/`,
), ),
) )
" "

View file

@ -155,6 +155,16 @@ const routes: RouteRecordRaw[] = [
name: 'ManualView', name: 'ManualView',
component: () => import('pages/00_manual/ViewPage.vue'), component: () => import('pages/00_manual/ViewPage.vue'),
}, },
{
path: '/troubleshooting',
name: 'Troubleshooting',
component: () => import('pages/00_manual/MainPage.vue'),
},
{
path: '/troubleshooting/:category/:page',
name: 'TroubleshootingView',
component: () => import('pages/00_manual/ViewPage.vue'),
},
], ],
}, },

View file

@ -5,10 +5,11 @@ import { getToken } from 'src/services/keycloak';
import { Manual } from './types'; import { Manual } from './types';
import { baseUrl } from '../utils'; import { baseUrl } from '../utils';
const ENDPOINT = 'manual'; const MANUAL_ENDPOINT = 'manual';
const TROUBLESHOOTING_ENDPOINT = 'troubleshooting';
export async function getManual() { export async function getManual() {
const res = await api.get<Manual[]>(`/${ENDPOINT}`); const res = await api.get<Manual[]>(`/${MANUAL_ENDPOINT}`);
if (res.status < 400) { if (res.status < 400) {
return res.data; return res.data;
} }
@ -20,7 +21,28 @@ export async function getManualByPage(opt: {
pageName: string; pageName: string;
}) { }) {
const res = await fetch( const res = await fetch(
`${baseUrl}/${ENDPOINT}/${opt.category}/page/${opt.pageName}`, `${baseUrl}/${MANUAL_ENDPOINT}/${opt.category}/page/${opt.pageName}`,
);
if (res.status < 400) {
return res;
}
return null;
}
export async function getTroubleshooting() {
const res = await api.get<Manual[]>(`/${TROUBLESHOOTING_ENDPOINT}`);
if (res.status < 400) {
return res.data;
}
return null;
}
export async function getTroubleshootingByPage(opt: {
category: string;
pageName: string;
}) {
const res = await fetch(
`${baseUrl}/${TROUBLESHOOTING_ENDPOINT}/${opt.category}/page/${opt.pageName}`,
); );
if (res.status < 400) { if (res.status < 400) {
return res; return res;
@ -30,11 +52,15 @@ export async function getManualByPage(opt: {
export const useManualStore = defineStore('manual-store', () => { export const useManualStore = defineStore('manual-store', () => {
const dataManual = ref<Manual[]>([]); const dataManual = ref<Manual[]>([]);
const dataTroubleshooting = ref<Manual[]>([]);
return { return {
getManual, getManual,
getManualByPage, getManualByPage,
getTroubleshooting,
getTroubleshootingByPage,
dataManual, dataManual,
dataTroubleshooting,
}; };
}); });