This commit is contained in:
xiaojibeier
2026-07-13 16:45:11 +08:00
parent a4a9f2e36c
commit 0e21232b38
21 changed files with 4603 additions and 1 deletions
+2
View File
@@ -0,0 +1,2 @@
# 所有环境都会加载的配置
VITE_APP_TITLE=威海知识库
+3
View File
@@ -0,0 +1,3 @@
# 开发环境配置
NODE_ENV=development
VITE_APP_ENV=development
+6
View File
@@ -0,0 +1,6 @@
# 复制为 .env 后填写
VITE_APP_TITLE=威海知识库
# 开发代理目标(可选,默认见 vite.config.js)
# VITE_DEV_API_TARGET=https://your-api-gateway.example.com
+3
View File
@@ -0,0 +1,3 @@
# 生产环境配置
VITE_APP_ENV=production
VITE_APP_BASE_URL=/api
+58
View File
@@ -0,0 +1,58 @@
# ── 依赖 ──────────────────────────────────────────
node_modules/
# ── 构建产物 ──────────────────────────────────────
dist/
dist-ssr/
build/
*.tsbuildinfo
# ── 环境变量 ───────────────────────────────────────
.env.local
.env*.local
# ── 日志 ──────────────────────────────────────────
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
# ── 测试 / 覆盖率 ─────────────────────────────────
coverage/
/cypress/videos/
/cypress/screenshots/
# ── 系统文件 ──────────────────────────────────────
.DS_Store
Thumbs.db
Desktop.ini
# ── 编辑器 / IDE ──────────────────────────────────
.vscode/*
!.vscode/extensions.json
.idea/
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# ── Cursor / AI 本地缓存 ───────────────────────────
.cursor/
# ── 密钥与证书 ────────────────────────────────────
*.pem
*.p12
*.key
*.keystore
credentials.json
secrets.json
# ── 临时文件 ──────────────────────────────────────
*.local
*.tmp
*.temp
.cache/
+21 -1
View File
@@ -1,3 +1,23 @@
# weihai_kb
知识库
威海知识库(Knowledge Base)
## 技术栈
Vue 3 + Vite + Element Plus + Pinia + Vue Router(与 weihai_erp 同栈)
## 开发
```bash
npm install
npm run dev
```
默认端口 `3001`(避免与 ERP 的 3000 冲突)
## 构建
```bash
npm run build
npm run preview
```
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>威海知识库</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
+29
View File
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"target": "es2020",
"module": "esnext",
"moduleResolution": "bundler",
"jsx": "preserve",
"strict": true,
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"ignoreDeprecations": "6.0",
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
"include": [
"src/**/*.js",
"src/**/*.vue",
"src/**/*.json"
],
"exclude": [
"node_modules",
"dist"
]
}
+4152
View File
File diff suppressed because it is too large Load Diff
+34
View File
@@ -0,0 +1,34 @@
{
"name": "weihai_kb",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"prebuild": "node scripts/bump-build-id.mjs",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.1",
"@vueuse/core": "^12.7.0",
"axios": "^1.7.9",
"dayjs": "^1.11.13",
"element-plus": "^2.9.4",
"normalize.css": "^8.0.1",
"nprogress": "^0.2.0",
"pinia": "^2.3.1",
"postcss": "^8.5.2",
"qs": "^6.14.0",
"vue": "^3.5.13",
"vue-router": "^4.5.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.1",
"autoprefixer": "^10.4.21",
"cross-env": "^10.0.0",
"sass": "^1.85.0",
"vite": "^6.0.11",
"vite-plugin-vue-devtools": "^7.7.1"
}
}
+5
View File
@@ -0,0 +1,5 @@
export default {
plugins: {
autoprefixer: {},
},
}
+4
View File
@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="none">
<rect width="32" height="32" rx="8" fill="#409EFF"/>
<path d="M8 10h16v2H8V10zm0 5h12v2H8v-2zm0 5h14v2H8v-2z" fill="#fff"/>
</svg>

After

Width:  |  Height:  |  Size: 208 B

+56
View File
@@ -0,0 +1,56 @@
/**
* 生产 11 位构建号:YYYYMMDD(8)+ 当日第几次构建(3 位 001~999)
*/
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const root = path.resolve(__dirname, '..')
const statePath = path.join(root, 'build', 'build-sequence.json')
const outPath = path.join(root, 'src', 'config', 'buildId.json')
const now = new Date()
const y = now.getFullYear()
const m = String(now.getMonth() + 1).padStart(2, '0')
const d = String(now.getDate()).padStart(2, '0')
const ymd8 = `${y}${m}${d}`
const todayKey = `${y}-${m}-${d}`
let state = { date: todayKey, daySeq: 0 }
if (fs.existsSync(statePath)) {
try {
const prev = JSON.parse(fs.readFileSync(statePath, 'utf8'))
if (prev && typeof prev === 'object') {
state.date = prev.date || todayKey
state.daySeq = Number.isFinite(prev.daySeq) ? prev.daySeq : 0
}
} catch { /* 忽略损坏文件 */ }
}
if (state.date === todayKey) {
state.daySeq = (state.daySeq || 0) + 1
} else {
state.date = todayKey
state.daySeq = 1
}
if (state.daySeq > 999) {
console.warn('[bump-build-id] 当日构建已超过 999 次,已钳位为 999')
state.daySeq = 999
}
const buildId = `${ymd8}${String(state.daySeq).padStart(3, '0')}`
fs.mkdirSync(path.dirname(statePath), { recursive: true })
fs.writeFileSync(statePath, JSON.stringify(state, null, 2), 'utf8')
fs.mkdirSync(path.dirname(outPath), { recursive: true })
fs.writeFileSync(
outPath,
JSON.stringify(
{ buildId, generatedAt: new Date().toISOString() },
null,
2,
),
'utf8',
)
console.log(`[bump-build-id] buildId=${buildId}`)
+22
View File
@@ -0,0 +1,22 @@
<script setup>
</script>
<template>
<router-view />
</template>
<style>
#app {
background-color: #f0f2f5;
margin: 0;
padding: 0;
width: 100%;
min-height: 100vh;
}
html,
body {
margin: 0;
padding: 0;
}
</style>
+4
View File
@@ -0,0 +1,4 @@
:root {
--nav-height: 50px;
--page-bg: #f0f2f5;
}
+4
View File
@@ -0,0 +1,4 @@
{
"buildId": "20260713001",
"generatedAt": "2026-07-13T08:42:37.534Z"
}
+17
View File
@@ -0,0 +1,17 @@
import 'normalize.css'
import './assets/styles/variables.css'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import { createApp } from 'vue'
import { setupStore } from '@/store'
import App from './App.vue'
import router from './router'
const app = createApp(App)
app.use(ElementPlus, {
zIndex: 10000,
})
setupStore(app)
app.use(router)
app.mount('#app')
+35
View File
@@ -0,0 +1,35 @@
import { createRouter, createWebHistory } from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
NProgress.configure({ showSpinner: false })
export const constantRoutes = [
{
path: '/',
name: 'Home',
component: () => import('@/views/Home.vue'),
meta: {
title: '首页',
},
},
]
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: constantRoutes,
scrollBehavior: () => ({ top: 0 }),
})
router.beforeEach((to, _from, next) => {
NProgress.start()
const title = to.meta?.title
document.title = title ? `${title} - ${import.meta.env.VITE_APP_TITLE}` : import.meta.env.VITE_APP_TITLE
next()
})
router.afterEach(() => {
NProgress.done()
})
export default router
+9
View File
@@ -0,0 +1,9 @@
import { createPinia } from 'pinia'
export function setupStore(app) {
app.use(pinia)
}
const pinia = createPinia()
export default pinia
+59
View File
@@ -0,0 +1,59 @@
<script setup>
import { Collection } from '@element-plus/icons-vue'
</script>
<template>
<div class="home-page">
<el-card class="welcome-card" shadow="never">
<div class="welcome-inner">
<el-icon class="welcome-icon" :size="48">
<Collection />
</el-icon>
<h1>威海知识库</h1>
<p>Vue 3 + Vite + Element Plus 项目已就绪,页面待规划。</p>
</div>
</el-card>
</div>
</template>
<style scoped>
.home-page {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
padding: 24px;
box-sizing: border-box;
}
.welcome-card {
width: min(560px, 100%);
}
.welcome-inner {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
gap: 12px;
padding: 24px 8px;
}
.welcome-icon {
color: var(--el-color-primary);
}
h1 {
margin: 0;
font-size: 28px;
font-weight: 600;
color: #303133;
}
p {
margin: 0;
font-size: 14px;
color: #909399;
line-height: 1.6;
}
</style>
+67
View File
@@ -0,0 +1,67 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
const isDev = mode === 'development'
const apiTarget = env.VITE_DEV_API_TARGET || 'https://gateway.oegame.com/shixin'
const apiProxyCommon = {
target: apiTarget,
changeOrigin: true,
secure: apiTarget.startsWith('https'),
rewrite: (path) => path.replace(/^\/api/, ''),
timeout: 120000,
proxyTimeout: 120000,
}
return {
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'/@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
host: '0.0.0.0',
port: 3001,
open: true,
proxy: {
'/api': apiProxyCommon,
},
},
base: '/',
esbuild: {
drop: isDev ? [] : ['console', 'debugger'],
},
build: {
outDir: 'dist',
assetsDir: 'assets',
sourcemap: isDev,
chunkSizeWarningLimit: 2000,
rollupOptions: {
output: {
entryFileNames: 'assets/[name]-[hash].js',
chunkFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash].[ext]',
manualChunks: {
'vendor-vue': ['vue', 'vue-router', 'pinia'],
'vendor-element': ['element-plus'],
},
},
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: '',
},
},
},
optimizeDeps: {
include: ['vue', 'vue-router', 'pinia'],
},
}
})