Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,554 changes: 2,413 additions & 141 deletions admin/package-lock.json

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
"preview": "vite preview",
"test": "vitest",
"test:run": "vitest run"
},
"dependencies": {
"@iconify/vue": "^4.1.2",
Expand All @@ -20,7 +22,10 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.1.4",
"@vue/test-utils": "^2.4.6",
"jsdom": "^27.2.0",
"sass": "^1.83.0",
"vite": "^5.4.2"
"vite": "^5.4.2",
"vitest": "^4.0.15"
}
}
41 changes: 41 additions & 0 deletions admin/src/setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// src/setupTests.js
import { describe, expect, it, vi, beforeEach } from 'vitest'
import { createApp } from 'vue'

// 全局测试设置
globalThis.describe = describe
globalThis.it = it
globalThis.expect = expect
globalThis.vi = vi
globalThis.beforeEach = beforeEach

// 模拟常用的全局函数或对象
vi.mock('axios', () => ({
default: {
get: vi.fn(() => Promise.resolve({ data: {} })),
post: vi.fn(() => Promise.resolve({ data: {} })),
put: vi.fn(() => Promise.resolve({ data: {} })),
delete: vi.fn(() => Promise.resolve({ data: {} }))
}
}))

// 模拟Vue Router
vi.mock('vue-router', () => ({
useRouter: vi.fn(() => ({
push: vi.fn(),
replace: vi.fn()
})),
useRoute: vi.fn(() => ({
params: {},
query: {}
}))
}))

// 模拟Pinia
vi.mock('pinia', () => ({
defineStore: vi.fn(() => ({
state: vi.fn(() => ({})),
getters: {},
actions: {}
}))
}))
29 changes: 29 additions & 0 deletions admin/src/utils/__tests__/request.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// src/utils/__tests__/request.test.js
import { describe, it, expect, vi } from 'vitest'
import request from '../request'

describe('request 工具函数', () => {
it('应该存在', () => {
expect(request).toBeDefined()
})

it('应该有 get 方法', () => {
expect(request.get).toBeDefined()
expect(typeof request.get).toBe('function')
})

it('应该有 post 方法', () => {
expect(request.post).toBeDefined()
expect(typeof request.post).toBe('function')
})

it('应该有 put 方法', () => {
expect(request.put).toBeDefined()
expect(typeof request.put).toBe('function')
})

it('应该有 delete 方法', () => {
expect(request.delete).toBeDefined()
expect(typeof request.delete).toBe('function')
})
})
10 changes: 9 additions & 1 deletion admin/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path' // 👈 添加这一行
import { resolve } from 'path'

export default defineConfig({
plugins: [
Expand Down Expand Up @@ -31,5 +31,13 @@ export default defineConfig({
changeOrigin: true
}
}
},
test: {
environment: 'jsdom',
include: ['src/**/*.spec.js', 'src/**/*.test.js'],
setupFiles: ['src/setupTests.js'],
coverage: {
reporter: ['text', 'json', 'html']
}
}
})
81 changes: 50 additions & 31 deletions miniprogram/project.config.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,52 @@
{
"miniprogramRoot": "unpackage/dist/dev/mp-weixin/",
"projectname": "CampusGuide",
"description": "校园导览小程序",
"appid": "wxe6084d4844b6b9cc",
"setting": {
"urlCheck": false,
"es6": true,
"enhance": true,
"postcss": true,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
"miniprogramRoot": "unpackage/dist/dev/mp-weixin/",
"projectname": "CampusGuide",
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"appid": "touristappid",
"setting": {
"urlCheck": false,
"es6": true,
"enhance": true,
"postcss": true,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"lazyloadPlaceholderEnable": false,
"preloadBackgroundData": false,
"uglifyFileName": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"useStaticServer": true,
"showES6CompileOption": false,
"disableUseStrict": false,
"useCompilerPlugins": false
},
"compileType": "miniprogram",
"libVersion": "3.7.7",
"condition": {},
"srcMiniprogramRoot": "unpackage/dist/dev/mp-weixin/",
"packOptions": {
"ignore": [],
"include": []
},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 4
}
},
"compileType": "miniprogram",
"libVersion": "3.9.3",
"condition": {}
}
}
7 changes: 7 additions & 0 deletions miniprogram/project.private.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"projectname": "miniprogram",
"setting": {
"compileHotReLoad": true
},
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@
<version>1.18.30</version>
</path>
</annotationProcessorPaths>
<parameters>true</parameters>
</configuration>
</plugin>
<plugin>
Expand Down
Loading