增加品牌方案管理
This commit is contained in:
Generated
+23
-56
@@ -145,8 +145,7 @@
|
||||
"integrity": "sha512-sBXGT13cpmPR5BMgHE6UEEfEaShh5Ror6rfN3yEK5si7QVrtZg8LEPQb0VVhiLRUslD2yLnXtnRzG035J/mZXQ==",
|
||||
"dev": true,
|
||||
"license": "(Apache-2.0 AND BSD-3-Clause)",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@csstools/color-helpers": {
|
||||
"version": "6.0.2",
|
||||
@@ -236,6 +235,7 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=20.19.0"
|
||||
},
|
||||
@@ -276,6 +276,7 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=20.19.0"
|
||||
}
|
||||
@@ -1116,7 +1117,6 @@
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"detect-libc": "^2.0.3",
|
||||
"is-glob": "^4.0.3",
|
||||
@@ -1159,7 +1159,6 @@
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1181,7 +1180,6 @@
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1203,7 +1201,6 @@
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1225,7 +1222,6 @@
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1247,7 +1243,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1269,7 +1264,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1291,7 +1285,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1313,7 +1306,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1335,7 +1327,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1357,7 +1348,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1379,7 +1369,6 @@
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1401,7 +1390,6 @@
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1423,7 +1411,6 @@
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
@@ -1439,7 +1426,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -1906,6 +1892,7 @@
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz",
|
||||
"integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@types/lodash": "*"
|
||||
}
|
||||
@@ -1916,6 +1903,7 @@
|
||||
"integrity": "sha512-8kzdPJ3FsNsVIurqBs7oodNnCEVbni9yUEkaHbgptDACOPW04jimGagZ51E6+lXUwJjgnBw+hyko/lkFWCldqw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
@@ -1975,6 +1963,7 @@
|
||||
"integrity": "sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "6.21.0",
|
||||
"@typescript-eslint/types": "6.21.0",
|
||||
@@ -2606,6 +2595,7 @@
|
||||
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
@@ -2865,7 +2855,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"readdirp": "^4.0.1"
|
||||
},
|
||||
@@ -2902,8 +2891,7 @@
|
||||
"integrity": "sha512-twmVoizEW7ylZSN32OgKdXRmo1qg+wT5/6C3xu5b9QsWzSFAhHLn2xd8ro0diCsKfCj1RdaTP/nrcW+vAoQPIw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
@@ -3125,7 +3113,6 @@
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
@@ -3364,6 +3351,7 @@
|
||||
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.2.0",
|
||||
"@eslint-community/regexpp": "^4.6.1",
|
||||
@@ -4055,8 +4043,7 @@
|
||||
"integrity": "sha512-t7xcm2siw+hlUM68I+UEOK+z84RzmN59as9DZ7P1l0994DKUWV7UXBMQZVxaoMSRQ+PBZbHCOoBt7a2wxOMt+A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/import-fresh": {
|
||||
"version": "3.3.1",
|
||||
@@ -4421,13 +4408,15 @@
|
||||
"version": "4.17.23",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
|
||||
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/lodash-es": {
|
||||
"version": "4.17.23",
|
||||
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.23.tgz",
|
||||
"integrity": "sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/lodash-unified": {
|
||||
"version": "1.0.3",
|
||||
@@ -4648,8 +4637,7 @@
|
||||
"integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/nopt": {
|
||||
"version": "7.2.1",
|
||||
@@ -5065,7 +5053,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 14.18.0"
|
||||
},
|
||||
@@ -5250,7 +5237,6 @@
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.1.0"
|
||||
}
|
||||
@@ -5262,7 +5248,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"chokidar": "^4.0.0",
|
||||
"immutable": "^5.1.5",
|
||||
@@ -5285,7 +5270,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^2.5.0",
|
||||
"colorjs.io": "^0.5.0",
|
||||
@@ -5335,7 +5319,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"sass": "1.98.0"
|
||||
}
|
||||
@@ -5353,7 +5336,6 @@
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5371,7 +5353,6 @@
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5389,7 +5370,6 @@
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5407,7 +5387,6 @@
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5425,7 +5404,6 @@
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5443,7 +5421,6 @@
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5461,7 +5438,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5479,7 +5455,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5497,7 +5472,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5515,7 +5489,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5533,7 +5506,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5551,7 +5523,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5569,7 +5540,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5587,7 +5557,6 @@
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5605,7 +5574,6 @@
|
||||
"!linux",
|
||||
"!win32"
|
||||
],
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"sass": "1.98.0"
|
||||
}
|
||||
@@ -5623,7 +5591,6 @@
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5641,7 +5608,6 @@
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
@@ -5653,7 +5619,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
@@ -5960,7 +5925,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"sync-message-port": "^1.0.0"
|
||||
},
|
||||
@@ -5975,7 +5939,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
}
|
||||
@@ -6071,6 +6034,7 @@
|
||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -6176,8 +6140,7 @@
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"dev": true,
|
||||
"license": "0BSD",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/type-check": {
|
||||
"version": "0.4.0",
|
||||
@@ -6211,6 +6174,7 @@
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"devOptional": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
@@ -6249,8 +6213,7 @@
|
||||
"integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "7.3.1",
|
||||
@@ -6258,6 +6221,7 @@
|
||||
"integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"esbuild": "^0.27.0",
|
||||
"fdir": "^6.5.0",
|
||||
@@ -6366,6 +6330,7 @@
|
||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -6379,6 +6344,7 @@
|
||||
"integrity": "sha512-yF+o4POL41rpAzj5KVILUxm1GCjKnELvaqmU9TLLUbMfDzuN0UpUR9uaDs+mCtjPe+uYPksXDRLQGGPvj1cTmA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@vitest/expect": "4.1.1",
|
||||
"@vitest/mocker": "4.1.1",
|
||||
@@ -6480,6 +6446,7 @@
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.30.tgz",
|
||||
"integrity": "sha512-hTHLc6VNZyzzEH/l7PFGjpcTvUgiaPK5mdLkbjrTeWSRcEfxFrv56g/XckIYlE9ckuobsdwqd5mk2g1sBkMewg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@vue/compiler-dom": "3.5.30",
|
||||
"@vue/compiler-sfc": "3.5.30",
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,211 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { createRouter, createMemoryHistory } from 'vue-router'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import BrandManagement from '@/views/brand/BrandManagement.vue'
|
||||
|
||||
// ===== Mock Element Plus =====
|
||||
vi.mock('element-plus', () => ({
|
||||
ElMessage: { success: vi.fn(), error: vi.fn(), warning: vi.fn() },
|
||||
ElMessageBox: { confirm: vi.fn() },
|
||||
}))
|
||||
|
||||
// ===== Mock @element-plus/icons-vue =====
|
||||
vi.mock('@element-plus/icons-vue', () => ({
|
||||
Plus: { template: '<svg/>' },
|
||||
Edit: { template: '<svg/>' },
|
||||
Delete: { template: '<svg/>' },
|
||||
UploadFilled: { template: '<svg/>' },
|
||||
}))
|
||||
|
||||
// ===== Mock brand.api =====
|
||||
vi.mock('@/api/brand.api', () => ({
|
||||
brandApi: {
|
||||
getConfig: vi.fn().mockResolvedValue({
|
||||
id: 1,
|
||||
tenantId: 'default',
|
||||
logoUrl: 'https://example.com/logo.png',
|
||||
backgroundImageUrl: '',
|
||||
primaryColor: '#00E676',
|
||||
secondaryColor: '#1A1A1A',
|
||||
fontFamily: 'default',
|
||||
}),
|
||||
uploadLogo: vi.fn().mockResolvedValue({
|
||||
id: 1,
|
||||
tenantId: 'default',
|
||||
logoUrl: 'https://example.com/new-logo.png',
|
||||
}),
|
||||
uploadBackground: vi.fn().mockResolvedValue({
|
||||
id: 1,
|
||||
tenantId: 'default',
|
||||
backgroundImageUrl: 'https://example.com/bg.png',
|
||||
}),
|
||||
removeLogo: vi.fn().mockResolvedValue({}),
|
||||
removeBackground: vi.fn().mockResolvedValue({}),
|
||||
updateColor: vi.fn().mockResolvedValue({
|
||||
id: 1,
|
||||
tenantId: 'default',
|
||||
primaryColor: '#FF0000',
|
||||
secondaryColor: '#0000FF',
|
||||
}),
|
||||
},
|
||||
}))
|
||||
|
||||
// ===== Mock request =====
|
||||
vi.mock('@/utils/request', () => {
|
||||
const mockRequest = {
|
||||
get: vi.fn().mockResolvedValue({}),
|
||||
post: vi.fn().mockResolvedValue({}),
|
||||
put: vi.fn().mockResolvedValue({}),
|
||||
delete: vi.fn().mockResolvedValue({}),
|
||||
}
|
||||
return { default: mockRequest }
|
||||
})
|
||||
|
||||
// ===== Mock WebSocket =====
|
||||
class MockWebSocket {
|
||||
url: string
|
||||
readyState = 1
|
||||
onopen: (() => void) | null = null
|
||||
onmessage: ((e: any) => void) | null = null
|
||||
onerror: (() => void) | null = null
|
||||
onclose: (() => void) | null = null
|
||||
|
||||
constructor(url: string) {
|
||||
this.url = url
|
||||
setTimeout(() => this.onopen?.(), 0)
|
||||
}
|
||||
|
||||
send = vi.fn()
|
||||
close = vi.fn()
|
||||
}
|
||||
// @ts-ignore
|
||||
globalThis.WebSocket = MockWebSocket
|
||||
|
||||
// ===== Mock URL.createObjectURL =====
|
||||
if (!globalThis.URL.createObjectURL) {
|
||||
// @ts-ignore
|
||||
globalThis.URL.createObjectURL = vi.fn(() => `blob:mock-${Math.random()}`)
|
||||
// @ts-ignore
|
||||
globalThis.URL.revokeObjectURL = vi.fn()
|
||||
}
|
||||
|
||||
describe('BrandManagement Component', () => {
|
||||
let router: any
|
||||
let wrapper: any
|
||||
|
||||
const defaultStubs = {
|
||||
'el-button': { template: '<button @click="$emit(\'click\')"><slot/></button>' },
|
||||
'el-card': { template: '<div class="el-card"><slot/><slot name="header"/></div>' },
|
||||
'el-col': { template: '<div><slot/></div>' },
|
||||
'el-row': { template: '<div><slot/></div>' },
|
||||
'el-icon': { template: '<svg/>' },
|
||||
'el-upload': { template: '<div class="el-upload-stub"><slot/></div>', props: ['http-request', 'show-file-list', 'before-upload', 'accept'] },
|
||||
'el-form': { template: '<form><slot/></form>', props: ['model', 'rules', 'label-width', 'ref'] },
|
||||
'el-form-item': { template: '<div class="el-form-item"><slot/></div>', props: ['label', 'prop'] },
|
||||
'el-input': { template: '<input/>', props: ['modelValue'], emits: ['update:modelValue'] },
|
||||
'el-input-number': true,
|
||||
'el-color-picker': true,
|
||||
'el-switch': true,
|
||||
'el-tag': { template: '<span class="el-tag"><slot/></span>', props: ['type', 'effect', 'size'] },
|
||||
'el-tooltip': { template: '<div><slot/></div>' },
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
const pinia = createPinia()
|
||||
setActivePinia(pinia)
|
||||
|
||||
router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [{ path: '/', component: { template: '<div/>' } }],
|
||||
})
|
||||
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
if (wrapper) wrapper.unmount()
|
||||
})
|
||||
|
||||
// ==================== 组件初始化 ====================
|
||||
|
||||
it('应该渲染品牌管理容器', () => {
|
||||
wrapper = mount(BrandManagement, {
|
||||
global: { plugins: [router], stubs: defaultStubs },
|
||||
})
|
||||
|
||||
expect(wrapper.find('.brand-management').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('应该渲染页面标题', () => {
|
||||
wrapper = mount(BrandManagement, {
|
||||
global: { plugins: [router], stubs: defaultStubs },
|
||||
})
|
||||
|
||||
expect(wrapper.html()).toContain('品牌定制')
|
||||
})
|
||||
|
||||
// ==================== 预览区域 ====================
|
||||
|
||||
it('应该渲染模拟小程序预览框', () => {
|
||||
wrapper = mount(BrandManagement, {
|
||||
global: { plugins: [router], stubs: defaultStubs },
|
||||
})
|
||||
|
||||
expect(wrapper.find('.preview-container').exists()).toBe(true)
|
||||
expect(wrapper.find('.mock-miniapp').exists()).toBe(true)
|
||||
expect(wrapper.html()).toContain('实时预览')
|
||||
})
|
||||
|
||||
it('应该渲染问候卡片', () => {
|
||||
wrapper = mount(BrandManagement, {
|
||||
global: { plugins: [router], stubs: defaultStubs },
|
||||
})
|
||||
|
||||
expect(wrapper.find('.mock-greeting-card').exists()).toBe(true)
|
||||
expect(wrapper.html()).toContain('你好,会员用户')
|
||||
})
|
||||
|
||||
// ==================== 配置表单 ====================
|
||||
|
||||
it('应该渲染上传区域', () => {
|
||||
wrapper = mount(BrandManagement, {
|
||||
global: { plugins: [router], stubs: defaultStubs },
|
||||
})
|
||||
|
||||
expect(wrapper.html()).toContain('Logo 设置')
|
||||
expect(wrapper.html()).toContain('背景图设置')
|
||||
})
|
||||
|
||||
// ==================== 颜色配置 ====================
|
||||
|
||||
it('应该渲染颜色配置卡片', () => {
|
||||
wrapper = mount(BrandManagement, {
|
||||
global: { plugins: [router], stubs: defaultStubs },
|
||||
})
|
||||
|
||||
expect(wrapper.html()).toContain('品牌配色')
|
||||
// 颜色选择器存在
|
||||
expect(wrapper.find('.color-row').exists()).toBe(true)
|
||||
})
|
||||
|
||||
// ==================== 操作按钮 ====================
|
||||
|
||||
it('应该渲染保存配色按钮', () => {
|
||||
wrapper = mount(BrandManagement, {
|
||||
global: { plugins: [router], stubs: defaultStubs },
|
||||
})
|
||||
|
||||
expect(wrapper.html()).toContain('保存配色')
|
||||
})
|
||||
|
||||
// ==================== 颜色 HEX 格式验证 ====================
|
||||
|
||||
it('应该能正常挂载并接收初始配置', () => {
|
||||
wrapper = mount(BrandManagement, {
|
||||
global: { plugins: [router], stubs: defaultStubs },
|
||||
})
|
||||
|
||||
expect(wrapper.vm).toBeDefined()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,51 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export interface BrandConfig {
|
||||
id?: number
|
||||
tenantId: string
|
||||
logoUrl?: string
|
||||
backgroundImageUrl?: string
|
||||
primaryColor?: string
|
||||
primaryColorRgb?: string
|
||||
secondaryColor?: string
|
||||
secondaryColorRgb?: string
|
||||
fontFamily?: string
|
||||
brandName?: string
|
||||
slogan?: string
|
||||
createdAt?: string
|
||||
updatedAt?: string
|
||||
}
|
||||
|
||||
export const brandApi = {
|
||||
/** 获取品牌配置(tenantId 由后端从 JWT 提取) */
|
||||
getConfig: () =>
|
||||
request.get<BrandConfig>('/brand'),
|
||||
|
||||
/** 上传 Logo */
|
||||
uploadLogo: (formData: FormData) =>
|
||||
request.post<BrandConfig>('/brand/logo', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
}),
|
||||
|
||||
/** 删除 Logo */
|
||||
removeLogo: () =>
|
||||
request.delete<BrandConfig>('/brand/logo'),
|
||||
|
||||
/** 上传背景图 */
|
||||
uploadBackground: (formData: FormData) =>
|
||||
request.post<BrandConfig>('/brand/background', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
}),
|
||||
|
||||
/** 删除背景图 */
|
||||
removeBackground: () =>
|
||||
request.delete<BrandConfig>('/brand/background'),
|
||||
|
||||
/** 更新品牌配色 */
|
||||
updateColor: (data: Partial<BrandConfig>) =>
|
||||
request.put<BrandConfig>('/brand/color', data),
|
||||
|
||||
/** 更新品牌信息(名称、口号) */
|
||||
updateBrandInfo: (data: Partial<BrandConfig>) =>
|
||||
request.put<BrandConfig>('/brand/info', data),
|
||||
}
|
||||
@@ -88,6 +88,12 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('@/views/banner/BannerManagement.vue'),
|
||||
meta: { title: '轮播图管理' }
|
||||
},
|
||||
{
|
||||
path: 'brand',
|
||||
name: 'BrandManagement',
|
||||
component: () => import('@/views/brand/BrandManagement.vue'),
|
||||
meta: { title: '品牌定制' }
|
||||
},
|
||||
{
|
||||
path: 'loginlog',
|
||||
name: 'LoginLog',
|
||||
|
||||
@@ -47,6 +47,7 @@ function transformMenuData(backendMenus: BackendMenuItem[]): MenuItem[] {
|
||||
'member/card/index': '/member-cards',
|
||||
'statistics/dashboard/index': '/statistics',
|
||||
'banner/index': '/banners',
|
||||
'brand/index': '/brand',
|
||||
}
|
||||
|
||||
const filteredMenus = backendMenus.filter(menu => menu.menuType !== 'F')
|
||||
@@ -111,6 +112,7 @@ function getMenuIcon(menuName: string): string {
|
||||
'会员卡管理': 'CreditCard',
|
||||
'数据统计': 'DataAnalysis',
|
||||
'轮播图管理': 'Picture',
|
||||
'品牌定制': 'Brush',
|
||||
}
|
||||
return iconMap[menuName] || 'Document'
|
||||
}
|
||||
|
||||
@@ -32,6 +32,10 @@ const permissionMapping: PermissionMapping = {
|
||||
'GET /files': 'system:file:list',
|
||||
'POST /files': 'system:file:upload',
|
||||
'DELETE /files': 'system:file:delete',
|
||||
'GET /brand': 'brand:config:list',
|
||||
'POST /brand': 'brand:config:list',
|
||||
'PUT /brand': 'brand:config:list',
|
||||
'DELETE /brand': 'brand:config:list',
|
||||
}
|
||||
|
||||
export function checkApiPermission(method: string, url: string): boolean {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,9 +15,15 @@ export default defineConfig({
|
||||
strictPort: true,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: process.env.VITE_API_TARGET || 'http://localhost:8080',
|
||||
target: process.env.VITE_API_TARGET || 'http://localhost:8084',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
'/ws': {
|
||||
target: process.env.VITE_API_TARGET || 'http://localhost:8084',
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
secure: false
|
||||
}
|
||||
},
|
||||
hmr: {
|
||||
|
||||
Reference in New Issue
Block a user