PKU-DAIR Frontend is the frontend project for the PKU-DAIR Team Portal Website, built with Vue 3 and Vite.
The portal provides presentation, communication, and management tools for academic teams. It supports team profile display, research project and publication management, news publishing, member profile maintenance, and visual content editing.
| Category | Technology |
|---|---|
| Frontend Framework | Vue 3 |
| Build Tool | Vite 5 |
| Router | Vue Router 4 |
| State Management | Pinia |
| UI Components | @creatorsn/vfluent3 |
| Visual Editor | @creatorsn/powereditor3 |
| HTTP Client | Axios |
| API Generator | axios-swagger-helper |
| Styles | Sass / SCSS |
| Package Manager | Yarn |
| Deployment | Docker + Nginx |
If Vetur is installed, disable it for this Vue 3 project.
# GitHub
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Gitee mirror, usually faster in China
curl -so- https://gitee.com/mirrors/nvm/raw/v0.39.7/install.sh | bash# bash
source ~/.bashrc
# zsh
source ~/.zshrcnvm install 20
nvm use 20
nvm alias default 20Check the installed versions:
node -v
npm -vnode -v should return v20.x.x.
corepack enable
corepack prepare yarn@stable --activate
yarn -vyarnThe frontend reads the backend base URL from VITE_BACKEND_URL.
Development environment:
# .env.development
VITE_BACKEND_URL=http://100.64.0.18:8000/Production environment:
# .env.production
VITE_BACKEND_URL=/apiThe Axios instance is configured in src/api/config.js, and generated backend API methods are placed under src/api.
yarn devVite will start a local development server with hot module replacement.
# Start local development server
yarn dev
# Build production assets and generate gzip files
yarn build
# Preview production build locally
yarn preview
# Lint and auto-fix source files
yarn lint
# Regenerate API client from backend OpenAPI schema
yarn apiyarn buildThe build output is generated in dist/. The current build script runs Vite first and then executes scripts/gzip-dist.mjs to generate compressed static assets.
The api script in package.json fetches the backend OpenAPI schema and generates API files into src/api:
{
"scripts": {
"api": "api-cli get http://100.64.0.18:8000/openapi.json -d ./src/api"
}
}Run:
yarn apisrc/api/config.js creates the shared Axios instance:
import axios from "axios";
const ax = axios.create();
export const apiBaseURL = import.meta.env.VITE_BACKEND_URL;
ax.defaults.baseURL = apiBaseURL;
export default ax;The request interceptor also reads ApiToken and ApiTokenExpiredAt from localStorage, then sends the token through the Api-key header when it is valid.
Options API:
export default {
mounted() {
this.$api.some_module.some_method().then((res) => {
console.log(res);
});
},
};Composition API:
import { getCurrentInstance } from "vue";
const { proxy } = getCurrentInstance();
proxy.$api.some_module.some_method().then((res) => {
console.log(res);
});You can also import the generated API object directly:
import { api } from "@/api";
api.some_module.some_method().then((res) => {
console.log(res);
});Global properties are registered in src/main.js:
| Method | Description |
|---|---|
$api |
Generated backend API methods |
$axios |
Shared Axios instance |
$server |
Backend server URL without trailing slash |
$Go(path) |
Navigate with Vue Router |
$Back() |
Navigate back |
$Jump(url) |
Open a URL in a new browser window |
local(text) |
Localized text helper from the app store |
DAIR_Portal_FE/
+-- docs/ # Documentation assets
+-- nginx/ # Nginx configuration for deployment
+-- public/ # Static public assets
+-- scripts/ # Build helper scripts
+-- src/
| +-- api/ # Axios config and generated backend API client
| | +-- api.js
| | +-- config.js
| | +-- index.js
| | +-- model.js
| +-- assets/ # Local static assets
| +-- components/ # Reusable Vue components
| +-- fonts/ # Font assets
| +-- js/ # Shared JavaScript utilities
| +-- router/ # Vue Router configuration and route modules
| +-- stores/ # Pinia stores
| +-- style/ # Global styles and SCSS variables
| +-- views/ # Page-level Vue components
| +-- App.vue # Root Vue component
| +-- main.js # Vue application entry
+-- .env.development # Development environment variables
+-- .env.production # Production environment variables
+-- Dockerfile # Nginx deployment image
+-- docker-compose.yml # Docker Compose deployment config
+-- index.html # Vite HTML entry
+-- package.json # Scripts and dependencies
+-- vite.config.js # Vite configuration
+-- yarn.lock # Dependency lock file
vite.config.js configures Vue, path aliases, relative production assets, and global SCSS injection:
import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
export default defineConfig({
base: "./",
plugins: [vue()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/style/global.scss" as *;`,
},
},
},
});If the development environment needs a Vite reverse proxy instead of directly using VITE_BACKEND_URL, add a server.proxy section:
export default defineConfig({
server: {
host: "0.0.0.0",
proxy: {
"/api": {
target: "http://100.64.0.18:8000/",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
});Build the frontend first:
yarn buildThen start the Nginx container:
docker compose up -d --buildThe default docker-compose.yml maps container port 80 to host port 60081:
version: "3"
services:
web:
build: .
ports:
- "60081:80"
restart: alwaysyarn buildDeploy the generated dist/ directory to an Nginx static site. The repository provides a reference Nginx config at nginx/nginx.conf.
This project uses @creatorsn/vfluent3 and @creatorsn/powereditor3.
This project is licensed under the Apache License 2.0.






