hrms-edm/Services/client/README.md
2023-12-06 09:51:24 +07:00

103 lines
4.7 KiB
Markdown

# EDM Frontend
Enterprise Document Management (EDM) ส่วน frontend
# ส่วนประกอบ
- Vue.js (TypeScript) ใช้ Quasar Framework เป็น UI Framework หลักสำหรับการพัฒนา
- pnpm เป็น package manager
- Library Document ใช้ typedoc, typedoc-plugin-vue
```
pnpm i -D typedoc typedoc-plugin-vue
```
สำหรับ User
## โครงสร้างโฟลเดอร์
ภายใต้ src จะประกอบด้วยโฟลเดอร์ที่จำเป็นดังนี้
1. **assets** : สำหรับเก็บไฟล์ภาพกราฟิก + css
2. **components** : สำหรับเก็บ Component ส่วนกลางที่สามารถเรียกใช้จากระบบใดก็ได้
3. **helpers** : สำหรับเก็บ filter, composable ที่เรียกใช้จากระบบใดก็ได้
4. **modules** : สำหรับเก็บไฟล์โค้ดหลัก ภายในจะแบ่งเป็นโฟลเดอร์ย่อยของระบบต่าง ๆ ทั้ง 17 ระบบ 17 โฟลเดอร์ ภายใต้โฟลเดอร์ย่อยของระบบจะเป็นโครงสร้างแบบเดียวกับ vue template เช่น ภายใต้โฟลเดอร์ 01_metadata (ระบบข้อมูลหลัก) ประกอบด้วยโฟลเดอร์
- **components** : โฟลเดอร์เก็บ Component ที่ใช้เฉพาะระบบข้อมูลหลัก
- **views** : โฟลเดอร์เก็บ View/Layout ที่ใช้เฉพาะระบบข้อมูลหลัก
## รูปแบบ SFC ที่แนะนำให้ใช้ใน Vue 3
ลำดับการวางโค้ดใน Vue 3 จะย้ายแท็ก script ขึ้นก่อนแท็ก template ส่วนแท็ก style จะอยู่ลำดับล่างสุดเหมือนเดิม
- แท็ก script ควรมี setup และ lang="ts" บอกเสมอ
- แท็ก style ควรกำหนด lang และ scoped ด้วย
ตัวอย่างด้านล่าง
```
<script setup lang="ts">
</script>
<template>
</template>
<style lang="scss" scoped>
</style>
```
## การอ้างอิง Path
Vue Template ได้สร้าง shortcut ไว้ให้แล้วด้วยการใส่เครื่องหมาย '@' นำหน้า ซึ่ง @ แทน src ดังนั้นพาธใด ๆ ก็ต้องจะอยู่ภายใน @ ทั้งหมด เช่น ต้องการเรียก src/components ให้ใส่ว่า "@/components" ถ้าเป็นไปได้ไม่ควรใช้ relative path
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Type Support for `.vue` Imports in TS
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
1. Disable the built-in TypeScript Extension
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Type-Check, Compile and Minify for Production
```sh
npm run build
```
### Run Unit Tests with [Vitest](https://vitest.dev/)
```sh
npm run test:unit
```
```sh
npm run build
```
### Lint with [ESLint](https://eslint.org/)
```sh
npm run lint
```