3月28日更新
This commit is contained in:
parent
b183c7fcb0
commit
6b2c2f9f16
37
deploy.sh
Normal file
37
deploy.sh
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
# --- 配置 ---
|
||||
USER="webdev"
|
||||
IP="112.124.21.102" # 服务器 IP
|
||||
BASE_PATH="/www/wwwroot/web" # 请修改为您的项目在服务器上的存放路径
|
||||
RELEASE_NAME="v$(date +'%Y%m%d_%H%M%S')" # 生成版本号:如 v20260328_1445
|
||||
LOCAL_DIST="./dist"
|
||||
|
||||
# SSH 密钥提示:请确保本地已将 id_ed25519.pub 添加到服务器的 ~/.ssh/authorized_keys
|
||||
# 密钥内容:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICJtwa+MFLQEgkEbcGQ6dkQOiFydRvjVeidJ/7uBsF2e 3313488199@qq.com
|
||||
|
||||
echo "🚀 开始发布版本: $RELEASE_NAME"
|
||||
|
||||
# 1. 本地打包
|
||||
npm run build
|
||||
|
||||
# 2. 压缩并上传
|
||||
tar -czf dist.tar.gz -C $LOCAL_DIST .
|
||||
ssh $USER@$IP "mkdir -p $BASE_PATH/releases/$RELEASE_NAME"
|
||||
scp dist.tar.gz $USER@$IP:$BASE_PATH/releases/$RELEASE_NAME
|
||||
|
||||
# 3. 远程解压、更新软链接、清理旧版本
|
||||
ssh $USER@$IP << EOF
|
||||
cd $BASE_PATH/releases/$RELEASE_NAME
|
||||
tar -xzf dist.tar.gz
|
||||
rm dist.tar.gz
|
||||
|
||||
# 原子化更新软链接:先创建临时链接再重命名(防止切换瞬间服务中断)
|
||||
ln -sfn $BASE_PATH/releases/$RELEASE_NAME $BASE_PATH/current_new
|
||||
mv -Tf $BASE_PATH/current_new $BASE_PATH/current
|
||||
|
||||
# 只保留最近 5 个版本,删除更旧的
|
||||
cd $BASE_PATH/releases && ls -t | tail -n +6 | xargs rm -rf
|
||||
EOF
|
||||
|
||||
echo "✨ 发布成功!当前版本: $RELEASE_NAME"
|
||||
BIN
dist.tar.gz
Normal file
BIN
dist.tar.gz
Normal file
Binary file not shown.
66
package-lock.json
generated
66
package-lock.json
generated
@ -36,6 +36,7 @@
|
||||
"@types/node": "^24.11.0",
|
||||
"@types/path-browserify": "^1.0.3",
|
||||
"@types/spark-md5": "^3.0.5",
|
||||
"@types/three": "^0.183.1",
|
||||
"@vitejs/plugin-vue": "^6.0.4",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
"eslint-plugin-vue": "^10.8.0",
|
||||
@ -516,6 +517,13 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@dimforge/rapier3d-compat": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@dimforge/rapier3d-compat/-/rapier3d-compat-0.12.0.tgz",
|
||||
"integrity": "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@element-plus/icons-vue": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@element-plus/icons-vue/-/icons-vue-2.3.2.tgz",
|
||||
@ -1980,6 +1988,13 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@tweenjs/tween.js": {
|
||||
"version": "23.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz",
|
||||
"integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/esrecurse": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz",
|
||||
@ -2060,6 +2075,13 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/stats.js": {
|
||||
"version": "0.17.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/stats.js/-/stats.js-0.17.4.tgz",
|
||||
"integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/svgo": {
|
||||
"version": "2.6.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/svgo/-/svgo-2.6.4.tgz",
|
||||
@ -2070,12 +2092,35 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/three": {
|
||||
"version": "0.183.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/three/-/three-0.183.1.tgz",
|
||||
"integrity": "sha512-f2Pu5Hrepfgavttdye3PsH5RWyY/AvdZQwIVhrc4uNtvF7nOWJacQKcoVJn0S4f0yYbmAE6AR+ve7xDcuYtMGw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@dimforge/rapier3d-compat": "~0.12.0",
|
||||
"@tweenjs/tween.js": "~23.1.3",
|
||||
"@types/stats.js": "*",
|
||||
"@types/webxr": ">=0.5.17",
|
||||
"@webgpu/types": "*",
|
||||
"fflate": "~0.8.2",
|
||||
"meshoptimizer": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/web-bluetooth": {
|
||||
"version": "0.0.21",
|
||||
"resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.21.tgz",
|
||||
"integrity": "sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/webxr": {
|
||||
"version": "0.5.24",
|
||||
"resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz",
|
||||
"integrity": "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@vitejs/plugin-vue": {
|
||||
"version": "6.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-6.0.4.tgz",
|
||||
@ -2449,6 +2494,13 @@
|
||||
"vue": "^3.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@webgpu/types": {
|
||||
"version": "0.1.69",
|
||||
"resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.69.tgz",
|
||||
"integrity": "sha512-RPmm6kgRbI8e98zSD3RVACvnuktIja5+yLgDAkTmxLr90BEwdTXRQWNLF3ETTTyH/8mKhznZuN5AveXYFEsMGQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.16.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
|
||||
@ -4507,6 +4559,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/fflate": {
|
||||
"version": "0.8.2",
|
||||
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz",
|
||||
"integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/file-entry-cache": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
|
||||
@ -6054,6 +6113,13 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/meshoptimizer": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.0.1.tgz",
|
||||
"integrity": "sha512-Vix+QlA1YYT3FwmBBZ+49cE5y/b+pRrcXKqGpS5ouh33d3lSp2PoTpCw19E0cKDFWalembrHnIaZetf27a+W2g==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/micromatch": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
||||
|
||||
@ -8,7 +8,9 @@
|
||||
"build": "run-p type-check \"build-only {@}\" --",
|
||||
"preview": "vite preview",
|
||||
"build-only": "vite build",
|
||||
"type-check": "vue-tsc --build"
|
||||
"type-check": "vue-tsc --build",
|
||||
"deploy": "sh deploy.sh",
|
||||
"rollback": "sh rollback.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.2",
|
||||
@ -39,6 +41,7 @@
|
||||
"@types/node": "^24.11.0",
|
||||
"@types/path-browserify": "^1.0.3",
|
||||
"@types/spark-md5": "^3.0.5",
|
||||
"@types/three": "^0.183.1",
|
||||
"@vitejs/plugin-vue": "^6.0.4",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
"eslint-plugin-vue": "^10.8.0",
|
||||
|
||||
22
rollback.sh
Normal file
22
rollback.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
USER="root"
|
||||
IP="1.2.3.4" # 请修改为您的服务器实际 IP
|
||||
BASE_PATH="/www/wwwroot/my-project" # 请修改为您的项目在服务器上的存放路径
|
||||
|
||||
# SSH 密钥提示:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICJtwa+MFLQEgkEbcGQ6dkQOiFydRvjVeidJ/7uBsF2e 3313488199@qq.com
|
||||
|
||||
echo "⏪ 正在回滚到上一个版本..."
|
||||
|
||||
ssh $USER@$IP << EOF
|
||||
# 获取 releases 目录下按时间排序的倒数第二个版本
|
||||
PREVIOUS_VERSION=$(ls -dt $BASE_PATH/releases/*/ | sed -n '2p')
|
||||
|
||||
if [ -z "$PREVIOUS_VERSION" ]; then
|
||||
echo "❌ 找不到可回滚的历史版本"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ln -sfn $PREVIOUS_VERSION $BASE_PATH/current
|
||||
echo "✅ 已回滚至: $PREVIOUS_VERSION"
|
||||
EOF
|
||||
@ -65,6 +65,21 @@ export function changeRole(data: Record<string, any>) {
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as SystemApiRequestConfig<Record<string, any>>);
|
||||
}
|
||||
|
||||
export function getLoginWechatCode(params?: { clientCode?: string }) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'user.getLoginWechatCode',
|
||||
v: '1.0',
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: params || {},
|
||||
timeout: params?.clientCode ? 75000 : undefined,
|
||||
isSystemApi: true,
|
||||
} as SystemApiRequestConfig)
|
||||
}
|
||||
|
||||
export function logout(data?: Record<string, any>) {
|
||||
|
||||
@ -75,7 +75,19 @@ export default {
|
||||
"registerSuccess": "Registration successful",
|
||||
"toLogin": "Back to Login",
|
||||
"noAccount": "Don't have an account?",
|
||||
"hasAccount": "Already have an account?"
|
||||
"hasAccount": "Already have an account?",
|
||||
"email": "Email",
|
||||
"emailPlaceholder": "Please enter email",
|
||||
"realNamePlaceholder": "Please enter real name (optional)",
|
||||
"accountLogin": "Account Login",
|
||||
"qrcodeLogin": "QR Code Login",
|
||||
"wechatQrcode": "WeChat QR Code Login",
|
||||
"qrcodeDesc": "Open WeChat and scan the QR code to login",
|
||||
"qrcodeExpired": "QR code expired",
|
||||
"qrcodeRefresh": "Click to refresh",
|
||||
"qrcodeWaiting": "Waiting for scan...",
|
||||
"qrcodeScanned": "Scanned, please confirm on your phone",
|
||||
"qrcodeLoading": "Loading..."
|
||||
},
|
||||
"dashboard": {
|
||||
"expressDistribution": "Express Distribution",
|
||||
|
||||
@ -75,7 +75,19 @@ export default {
|
||||
"registerSuccess": "注册成功",
|
||||
"toLogin": "返回登录",
|
||||
"noAccount": "还没有账号?",
|
||||
"hasAccount": "已有账号?"
|
||||
"hasAccount": "已有账号?",
|
||||
"email": "邮箱",
|
||||
"emailPlaceholder": "请输入邮箱",
|
||||
"realNamePlaceholder": "请输入真实姓名(选填)",
|
||||
"accountLogin": "账号登录",
|
||||
"qrcodeLogin": "扫码登录",
|
||||
"wechatQrcode": "微信扫码登录",
|
||||
"qrcodeDesc": "打开微信,扫描二维码登录",
|
||||
"qrcodeExpired": "二维码已过期",
|
||||
"qrcodeRefresh": "点击刷新",
|
||||
"qrcodeWaiting": "等待扫码...",
|
||||
"qrcodeScanned": "扫码成功,请在手机上确认",
|
||||
"qrcodeLoading": "加载中..."
|
||||
},
|
||||
"dashboard": {
|
||||
"expressDistribution": "快递分布",
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<div :class="{ 'fixed-header': fixedHeader, 'fixed-header-top': layoutMode === 'top-bottom' }" :style="{ minHeight: shortcutExpanded ? '134px' : '97px' }">
|
||||
<task-view />
|
||||
</div>
|
||||
<div v-if="fixedHeader" :style="{ height: shortcutExpanded ? '134px' : '97px', minHeight: shortcutExpanded ? '134px' : '97px' }"></div>
|
||||
<div v-if="fixedHeader" :style="{ height: shortcutExpanded ? '134px' : '84px', minHeight: shortcutExpanded ? '134px' : '84px' }"></div>
|
||||
<div class="main-box">
|
||||
<app-main />
|
||||
<transition name="ai-slide">
|
||||
|
||||
@ -1,405 +0,0 @@
|
||||
//src/utils/overlookControls.ts
|
||||
|
||||
import * as THREE from 'three'
|
||||
|
||||
// 辅助函数:厘米转Three.js单位(1单位=1cm)
|
||||
const cm = (value: number) => value // Three.js中直接使用厘米为单位
|
||||
|
||||
type AreaBoundary = {
|
||||
boundary: THREE.Object3D
|
||||
areaId: any
|
||||
areaName?: string
|
||||
areaType?: any
|
||||
}
|
||||
|
||||
export class OverlookControls {
|
||||
camera: THREE.Camera
|
||||
domElement: HTMLElement
|
||||
scene: THREE.Scene
|
||||
enabled: boolean
|
||||
|
||||
cameraAngle: number
|
||||
cameraPitch: number
|
||||
targetHeight: number
|
||||
|
||||
cameraHeight: number
|
||||
minHeight: number
|
||||
maxHeight: number
|
||||
|
||||
target: THREE.Vector3
|
||||
|
||||
boundaryMinX: number
|
||||
boundaryMaxX: number
|
||||
boundaryMinZ: number
|
||||
boundaryMaxZ: number
|
||||
|
||||
moveSpeed: { keyboard: number; drag: number }
|
||||
|
||||
isDragging: boolean
|
||||
dragStart: THREE.Vector2
|
||||
dragCurrent: THREE.Vector2
|
||||
lastDragPos: THREE.Vector2
|
||||
|
||||
raycaster: THREE.Raycaster
|
||||
mouse: THREE.Vector2
|
||||
groundObjects: THREE.Object3D[]
|
||||
|
||||
keys: { w: boolean; a: boolean; s: boolean; d: boolean; up: boolean; left: boolean; down: boolean; right: boolean }
|
||||
|
||||
areaBoundaries: AreaBoundary[]
|
||||
onAreaClick: ((areaId: any, areaName?: string, areaType?: any) => void) | null
|
||||
|
||||
eventHandlers: any
|
||||
handleClick: ((e: MouseEvent) => void) | null
|
||||
clickMarker: THREE.Object3D | null
|
||||
|
||||
constructor(camera: THREE.Camera, domElement: HTMLElement, scene: THREE.Scene, config: Record<string, any> = {}) {
|
||||
this.camera = camera
|
||||
this.domElement = domElement
|
||||
this.scene = scene
|
||||
this.enabled = true
|
||||
|
||||
// 2.5D视角固定参数
|
||||
this.cameraAngle = Math.PI / 4 // 45度固定角度
|
||||
this.cameraPitch = 70 // 70度俯仰角(LOL风格)
|
||||
this.targetHeight = cm(0) // 目标在地面
|
||||
|
||||
// 相机高度(缩放)
|
||||
this.cameraHeight = cm(8000) // 初始高度80米
|
||||
this.minHeight = cm(4000) // 最小高度40米
|
||||
this.maxHeight = cm(20000) // 最大高度200米
|
||||
|
||||
// 目标位置(镜头中心点)
|
||||
this.target = new THREE.Vector3(0, 0, 0)
|
||||
|
||||
// 视野边界参数(类似LOL地图边界)
|
||||
this.boundaryMinX = config.boundaryMinX || cm(-30000)
|
||||
this.boundaryMaxX = config.boundaryMaxX || cm(30000)
|
||||
this.boundaryMinZ = config.boundaryMinZ || cm(-30000)
|
||||
this.boundaryMaxZ = config.boundaryMaxZ || cm(30000)
|
||||
|
||||
// 移动速度(厘米/秒)- 键盘速度加速2倍
|
||||
this.moveSpeed = {
|
||||
keyboard: cm(1600), // 键盘移动速度(原800 * 2)
|
||||
drag: cm(0.5) // 拖拽灵敏度系数
|
||||
}
|
||||
|
||||
// 鼠标拖拽控制
|
||||
this.isDragging = false
|
||||
this.dragStart = new THREE.Vector2()
|
||||
this.dragCurrent = new THREE.Vector2()
|
||||
this.lastDragPos = new THREE.Vector2()
|
||||
|
||||
// 点击地面检测
|
||||
this.raycaster = new THREE.Raycaster()
|
||||
this.mouse = new THREE.Vector2()
|
||||
this.groundObjects = []
|
||||
|
||||
// 键盘控制状态
|
||||
this.keys = { w: false, a: false, s: false, d: false, up: false, left: false, down: false, right: false }
|
||||
|
||||
// 区域边界检测
|
||||
this.areaBoundaries = []
|
||||
this.onAreaClick = null
|
||||
|
||||
this.eventHandlers = null
|
||||
this.handleClick = null
|
||||
this.clickMarker = null
|
||||
|
||||
// 初始化
|
||||
this.initControls()
|
||||
this.updateCameraPosition()
|
||||
}
|
||||
|
||||
initControls() {
|
||||
const canvas = this.domElement
|
||||
|
||||
// 鼠标按下开始拖拽
|
||||
const onMouseDown = (e: MouseEvent) => {
|
||||
if (!this.enabled || e.button !== 0) return // 只响应左键
|
||||
|
||||
e.preventDefault()
|
||||
this.isDragging = true
|
||||
this.dragStart.set((e as MouseEvent).clientX, (e as MouseEvent).clientY)
|
||||
this.lastDragPos.set((e as MouseEvent).clientX, (e as MouseEvent).clientY)
|
||||
canvas.style.cursor = 'grabbing'
|
||||
}
|
||||
|
||||
// 鼠标移动处理拖拽
|
||||
const onMouseMove = (e: MouseEvent) => {
|
||||
if (!this.enabled) return
|
||||
|
||||
this.dragCurrent.set(e.clientX, e.clientY)
|
||||
|
||||
if (this.isDragging) {
|
||||
const deltaX = this.dragCurrent.x - this.lastDragPos.x
|
||||
const deltaY = this.dragCurrent.y - this.lastDragPos.y
|
||||
|
||||
// 根据拖拽距离移动视角
|
||||
const moveX = -deltaX * this.moveSpeed.drag
|
||||
const moveZ = -deltaY * this.moveSpeed.drag
|
||||
|
||||
// 根据固定45度角度旋转移动方向
|
||||
const angle = -this.cameraAngle
|
||||
const cos = Math.cos(angle)
|
||||
const sin = Math.sin(angle)
|
||||
|
||||
const worldMoveX = (moveX * cos - moveZ * sin)
|
||||
const worldMoveZ = (moveX * sin + moveZ * cos)
|
||||
|
||||
this.setTargetPosition(this.target.x + worldMoveX, this.target.z + worldMoveZ)
|
||||
|
||||
this.lastDragPos.set(e.clientX, e.clientY)
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标释放停止拖拽
|
||||
const onMouseUp = (e: MouseEvent) => {
|
||||
if (!this.enabled || e.button !== 0) return
|
||||
|
||||
this.isDragging = false
|
||||
canvas.style.cursor = 'grab'
|
||||
|
||||
// 检查是否是点击(移动距离很小)
|
||||
const dx = this.dragCurrent.x - this.dragStart.x
|
||||
const dy = this.dragCurrent.y - this.dragStart.y
|
||||
const dragDistance = Math.sqrt(dx * dx + dy * dy)
|
||||
|
||||
if (dragDistance < 5) {
|
||||
this.handleClick && this.handleClick(e as MouseEvent)
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标滚轮缩放
|
||||
const onWheel = (e: WheelEvent) => {
|
||||
if (!this.enabled) return
|
||||
|
||||
e.preventDefault()
|
||||
const delta = e.deltaY > 0 ? 1.2 : 0.8
|
||||
const newHeight = this.cameraHeight * delta
|
||||
this.cameraHeight = THREE.MathUtils.clamp(newHeight, this.minHeight, this.maxHeight)
|
||||
this.updateCameraPosition()
|
||||
}
|
||||
|
||||
// 点击检测
|
||||
const handleClick = (e: MouseEvent) => {
|
||||
const rect = canvas.getBoundingClientRect()
|
||||
this.mouse.x = ((e.clientX - rect.left) / rect.width) * 2 - 1
|
||||
this.mouse.y = -((e.clientY - rect.top) / rect.height) * 2 + 1
|
||||
|
||||
this.raycaster.setFromCamera(this.mouse, this.camera)
|
||||
|
||||
// 1. 先检测是否点击了区域边界
|
||||
let areaClicked = false
|
||||
for (const area of this.areaBoundaries) {
|
||||
const intersects = this.raycaster.intersectObject(area.boundary)
|
||||
if (intersects.length > 0) {
|
||||
if (this.onAreaClick) {
|
||||
this.onAreaClick(area.areaId, area.areaName, area.areaType)
|
||||
}
|
||||
areaClicked = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 如果没有点击区域,检测地面(仅显示标记,不移动)
|
||||
if (!areaClicked) {
|
||||
const intersects = this.raycaster.intersectObjects(this.groundObjects)
|
||||
if (intersects.length > 0) {
|
||||
const point = intersects[0].point
|
||||
this.showClickMarker(point)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 键盘事件
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if (!this.enabled) return
|
||||
|
||||
switch (e.key.toLowerCase()) {
|
||||
case 'w': case 'arrowup': this.keys.w = this.keys.up = true; break
|
||||
case 'a': case 'arrowleft': this.keys.a = this.keys.left = true; break
|
||||
case 's': case 'arrowdown': this.keys.s = this.keys.down = true; break
|
||||
case 'd': case 'arrowright': this.keys.d = this.keys.right = true; break
|
||||
}
|
||||
}
|
||||
|
||||
const onKeyUp = (e: KeyboardEvent) => {
|
||||
switch (e.key.toLowerCase()) {
|
||||
case 'w': case 'arrowup': this.keys.w = this.keys.up = false; break
|
||||
case 'a': case 'arrowleft': this.keys.a = this.keys.left = false; break
|
||||
case 's': case 'arrowdown': this.keys.s = this.keys.down = false; break
|
||||
case 'd': case 'arrowright': this.keys.d = this.keys.right = false; break
|
||||
}
|
||||
}
|
||||
|
||||
// 添加事件监听器
|
||||
canvas.addEventListener('mousedown', onMouseDown)
|
||||
canvas.addEventListener('mousemove', onMouseMove)
|
||||
canvas.addEventListener('mouseup', onMouseUp)
|
||||
canvas.addEventListener('wheel', onWheel)
|
||||
|
||||
// 键盘事件监听在window上
|
||||
window.addEventListener('keydown', onKeyDown)
|
||||
window.addEventListener('keyup', onKeyUp)
|
||||
|
||||
// 鼠标离开画布时停止拖拽
|
||||
canvas.addEventListener('mouseleave', () => {
|
||||
if (this.isDragging) {
|
||||
this.isDragging = false
|
||||
canvas.style.cursor = 'grab'
|
||||
}
|
||||
})
|
||||
|
||||
// 初始化光标样式
|
||||
canvas.style.cursor = 'grab'
|
||||
|
||||
// 保存事件处理器以便清理
|
||||
this.eventHandlers = { onMouseDown, onMouseMove, onMouseUp, onWheel, onKeyDown, onKeyUp, handleClick }
|
||||
this.handleClick = handleClick
|
||||
}
|
||||
|
||||
setTargetPosition(x: number, z: number) {
|
||||
// 限制目标位置在边界内
|
||||
const clampedX = THREE.MathUtils.clamp(x, this.boundaryMinX, this.boundaryMaxX)
|
||||
const clampedZ = THREE.MathUtils.clamp(z, this.boundaryMinZ, this.boundaryMaxZ)
|
||||
|
||||
this.target.x = clampedX
|
||||
this.target.z = clampedZ
|
||||
|
||||
this.updateCameraPosition()
|
||||
}
|
||||
|
||||
updateCameraPosition() {
|
||||
// 固定2.5D视角计算
|
||||
const phi = THREE.MathUtils.degToRad(90 - this.cameraPitch)
|
||||
const theta = this.cameraAngle
|
||||
|
||||
const x = this.target.x + this.cameraHeight * Math.sin(phi) * Math.cos(theta)
|
||||
const y = this.target.y + this.cameraHeight * Math.cos(phi)
|
||||
const z: number = this.target.z + this.cameraHeight * Math.sin(phi) * Math.sin(theta)
|
||||
|
||||
(this.camera.position as THREE.Vector3).set(x, y, z)
|
||||
this.camera.lookAt(this.target)
|
||||
}
|
||||
|
||||
update(deltaTime?: number) {
|
||||
if (!this.enabled) return
|
||||
|
||||
// 键盘控制(速度加倍)
|
||||
let moveX = 0, moveZ = 0
|
||||
if (this.keys.w || this.keys.up) moveZ += 1
|
||||
if (this.keys.s || this.keys.down) moveZ -= 1
|
||||
if (this.keys.a || this.keys.left) moveX -= 1
|
||||
if (this.keys.d || this.keys.right) moveX += 1
|
||||
|
||||
if (moveX !== 0 || moveZ !== 0) {
|
||||
const speed = deltaTime ? this.moveSpeed.keyboard * deltaTime * 0.16 : this.moveSpeed.keyboard * 0.066
|
||||
|
||||
// 根据固定45度角度旋转移动方向
|
||||
const angle = -this.cameraAngle
|
||||
const cos = Math.cos(angle)
|
||||
const sin = Math.sin(angle)
|
||||
|
||||
const worldMoveX = (moveX * cos - moveZ * sin) * speed
|
||||
const worldMoveZ = (moveX * sin + moveZ * cos) * speed
|
||||
|
||||
this.setTargetPosition(this.target.x + worldMoveX, this.target.z + worldMoveZ)
|
||||
}
|
||||
}
|
||||
|
||||
showClickMarker(position: THREE.Vector3) {
|
||||
// 移除旧的标记
|
||||
if (this.clickMarker) {
|
||||
this.scene.remove(this.clickMarker)
|
||||
}
|
||||
|
||||
// 创建新的标记(圆形标记)
|
||||
const markerGeometry = new THREE.RingGeometry(cm(50), cm(70), 32)
|
||||
const markerMaterial = new THREE.MeshBasicMaterial({
|
||||
color: 0x00ffff,
|
||||
side: THREE.DoubleSide,
|
||||
transparent: true,
|
||||
opacity: 0.7
|
||||
})
|
||||
const marker = new THREE.Mesh(markerGeometry, markerMaterial)
|
||||
marker.position.copy(position)
|
||||
marker.position.y += cm(5) // 稍微高于地面
|
||||
marker.rotation.x = -Math.PI / 2 // 水平放置
|
||||
|
||||
this.scene.add(marker)
|
||||
this.clickMarker = marker
|
||||
|
||||
// 2秒后淡出移除
|
||||
setTimeout(() => {
|
||||
if (this.clickMarker === marker) {
|
||||
const fadeOut = () => {
|
||||
markerMaterial.opacity -= 0.05
|
||||
if (markerMaterial.opacity > 0) {
|
||||
requestAnimationFrame(fadeOut)
|
||||
} else {
|
||||
this.scene.remove(marker)
|
||||
if (this.clickMarker === marker) {
|
||||
this.clickMarker = null
|
||||
}
|
||||
}
|
||||
}
|
||||
fadeOut()
|
||||
}
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
// 设置边界
|
||||
setBoundary(minX: number, maxX: number, minZ: number, maxZ: number) {
|
||||
this.boundaryMinX = cm(minX)
|
||||
this.boundaryMaxX = cm(maxX)
|
||||
this.boundaryMinZ = cm(minZ)
|
||||
this.boundaryMaxZ = cm(maxZ)
|
||||
|
||||
// 确保当前目标在边界内
|
||||
this.setTargetPosition(this.target.x, this.target.z)
|
||||
}
|
||||
|
||||
// 添加区域边界(用于区域点击检测)
|
||||
addAreaBoundary(boundaryMesh: THREE.Object3D, areaId: any, areaName?: string, areaType?: any) {
|
||||
this.areaBoundaries.push({ boundary: boundaryMesh, areaId, areaName, areaType })
|
||||
}
|
||||
|
||||
// 设置区域点击回调
|
||||
setOnAreaClick(callback: (areaId: any, areaName?: string, areaType?: any) => void) {
|
||||
this.onAreaClick = callback
|
||||
}
|
||||
|
||||
addGroundObject(object: THREE.Object3D) {
|
||||
this.groundObjects.push(object)
|
||||
}
|
||||
|
||||
// 重置视角到指定位置
|
||||
resetView(x = 0, z = 0) {
|
||||
this.setTargetPosition(x, z)
|
||||
this.cameraHeight = cm(8000)
|
||||
this.updateCameraPosition()
|
||||
}
|
||||
|
||||
dispose() {
|
||||
const canvas = this.domElement
|
||||
const handlers = this.eventHandlers
|
||||
|
||||
if (canvas && handlers) {
|
||||
canvas.removeEventListener('mousedown', handlers.onMouseDown)
|
||||
canvas.removeEventListener('mousemove', handlers.onMouseMove)
|
||||
canvas.removeEventListener('mouseup', handlers.onMouseUp)
|
||||
canvas.removeEventListener('wheel', handlers.onWheel)
|
||||
|
||||
window.removeEventListener('keydown', handlers.onKeyDown)
|
||||
window.removeEventListener('keyup', handlers.onKeyUp)
|
||||
|
||||
canvas.style.cursor = 'default'
|
||||
}
|
||||
|
||||
if (this.clickMarker) {
|
||||
this.scene.remove(this.clickMarker)
|
||||
this.clickMarker = null
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,303 @@
|
||||
<template>
|
||||
<div class="404-container">
|
||||
<h1>404 Not Found</h1>
|
||||
<div class="error-page">
|
||||
<div class="error-wrapper">
|
||||
<!-- 背景装饰 -->
|
||||
<div class="decorations">
|
||||
<div class="decoration-1"></div>
|
||||
<div class="decoration-2"></div>
|
||||
<div class="decoration-3"></div>
|
||||
</div>
|
||||
|
||||
<!-- SVG 404 动画 -->
|
||||
<div class="svg-container">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 400">
|
||||
<!-- 极简404 -->
|
||||
<g class="minimal-numbers">
|
||||
<!-- 第一个4 - 只显示核心结构 -->
|
||||
|
||||
<path class="line-path" d="M120,100 L120,180" stroke="#1890ff" fill="none" stroke-width="4" stroke-linecap="round" />
|
||||
<path class="line-path" d="M200,180 L120,180" stroke="#1890ff" fill="none" stroke-width="4" stroke-linecap="round" />
|
||||
<path class="line-path" d="M200,100 L200,260" stroke="#1890ff" fill="none" stroke-width="4" stroke-linecap="round" />
|
||||
|
||||
<!-- 0 - 空心圆 -->
|
||||
<circle cx="280" cy="180" r="40" fill="none" stroke="#52c41a" stroke-width="4" />
|
||||
<circle cx="280" cy="180" r="15" fill="#fff" stroke="#52c41a" stroke-width="2" />
|
||||
|
||||
<!-- 第二个4 -->
|
||||
<path d="M360,100 L360,180 M440,260 L440,260 M440,180 L360,180 M440,100 L440,260" fill="none"
|
||||
stroke="#faad14" stroke-width="4" stroke-linecap="round" />
|
||||
</g>
|
||||
|
||||
<!-- 十字线 -->
|
||||
<path d="M500,100 L700,300 M500,300 L700,100" stroke="#f5222d" stroke-width="3" stroke-linecap="round"
|
||||
stroke-dasharray="10,5" />
|
||||
|
||||
<!-- 消失点动画 -->
|
||||
<g class="vanishing-point">
|
||||
<circle cx="600" cy="200" r="3" fill="#1890ff">
|
||||
<animate attributeName="r" values="3;20;3" dur="2s" repeatCount="indefinite" />
|
||||
<animate attributeName="opacity" values="1;0;1" dur="2s" repeatCount="indefinite" />
|
||||
</circle>
|
||||
|
||||
<!-- 扩散波纹 -->
|
||||
<circle cx="600" cy="200" r="10" fill="none" stroke="#1890ff" stroke-width="1" opacity="0.5">
|
||||
<animate attributeName="r" values="10;40;10" dur="2s" repeatCount="indefinite" begin="0.5s" />
|
||||
<animate attributeName="opacity" values="0.5;0;0.5" dur="2s" repeatCount="indefinite" begin="0.5s" />
|
||||
</circle>
|
||||
|
||||
<circle cx="600" cy="200" r="10" fill="none" stroke="#52c41a" stroke-width="1" opacity="0.5">
|
||||
<animate attributeName="r" values="10;60;10" dur="2s" repeatCount="indefinite" begin="1s" />
|
||||
<animate attributeName="opacity" values="0.5;0;0.5" dur="2s" repeatCount="indefinite" begin="1s" />
|
||||
</circle>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<h2 class="title">哎呀!页面不见了</h2>
|
||||
<p class="description">
|
||||
您访问的页面不存在或无访问权限。
|
||||
可能是链接失效、页面移除,或您的权限不足。
|
||||
</p>
|
||||
|
||||
<div class="action-buttons">
|
||||
<el-button type="primary" class="primary-btn" @click="goHome">
|
||||
<el-icon><House /></el-icon>
|
||||
返回首页
|
||||
</el-button>
|
||||
<el-button class="secondary-btn" @click="goBack">
|
||||
<el-icon><RefreshLeft /></el-icon>
|
||||
返回上页
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { House, RefreshLeft } from '@element-plus/icons-vue'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const goHome = () => {
|
||||
router.push('/')
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
router.go(-1)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// 添加路径动画
|
||||
setTimeout(() => {
|
||||
document.querySelectorAll('.path').forEach((path: any, index: number) => {
|
||||
const length = path.getTotalLength()
|
||||
path.style.strokeDasharray = length
|
||||
path.style.strokeDashoffset = length
|
||||
path.style.animation = `draw 2s ease forwards ${index * 0.3}s`
|
||||
})
|
||||
}, 100)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.error-page {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.error-wrapper {
|
||||
background: rgba(255, 255, 255, 0.98);
|
||||
border-radius: 30px;
|
||||
padding: 60px;
|
||||
max-width: 1000px;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
|
||||
animation: slideUp 0.6s ease-out;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
padding: 30px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.decorations {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
overflow: hidden;
|
||||
z-index: -1;
|
||||
|
||||
.decoration-1,
|
||||
.decoration-2,
|
||||
.decoration-3 {
|
||||
position: absolute;
|
||||
background: linear-gradient(45deg, #667eea22, #764ba222);
|
||||
border-radius: 50%;
|
||||
animation: float 6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.decoration-1 {
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
top: -150px;
|
||||
right: -150px;
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
.decoration-2 {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
bottom: -100px;
|
||||
left: -100px;
|
||||
animation-delay: 2s;
|
||||
}
|
||||
|
||||
.decoration-3 {
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
top: 50%;
|
||||
right: 30%;
|
||||
animation-delay: 4s;
|
||||
}
|
||||
}
|
||||
|
||||
.svg-container {
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
|
||||
svg {
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
height: auto;
|
||||
|
||||
.path {
|
||||
fill: none;
|
||||
stroke: #1890ff;
|
||||
stroke-width: 10;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
background: linear-gradient(45deg, #667eea, #764ba2);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: 18px;
|
||||
color: #666;
|
||||
margin-bottom: 40px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
margin-bottom: 50px;
|
||||
|
||||
.el-button {
|
||||
margin: 0 10px;
|
||||
padding: 15px 40px;
|
||||
font-size: 16px;
|
||||
border-radius: 30px;
|
||||
transition: all 0.3s;
|
||||
|
||||
.el-icon {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
&.primary-btn {
|
||||
background: linear-gradient(45deg, #667eea, #764ba2);
|
||||
border: none;
|
||||
color: #fff;
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
&.secondary-btn {
|
||||
border: 2px solid #1890ff;
|
||||
color: #1890ff;
|
||||
|
||||
&:hover {
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
transform: translateY(-3px);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 动画定义 */
|
||||
@keyframes slideUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(50px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes draw {
|
||||
to {
|
||||
stroke-dashoffset: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateY(-20px);
|
||||
}
|
||||
}
|
||||
|
||||
/* 响应式调整 */
|
||||
@media (max-width: 768px) {
|
||||
.title {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.action-buttons .el-button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin: 10px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,89 +1,23 @@
|
||||
<template>
|
||||
<div class="login-container">
|
||||
<div class="login-card">
|
||||
<!-- 左侧品牌区 -->
|
||||
<div class="login-left-panel">
|
||||
<div class="brand-info">
|
||||
<svg-icon icon-class="dashboard" class="brand-logo" />
|
||||
<h1 class="brand-name">VUE 3 ADMIN</h1>
|
||||
<!-- <svg-icon icon-class="dashboard" class="brand-logo" /> -->
|
||||
<img src="../../../public/logo/1.png" style="width:160px;height: 65px;">
|
||||
<!-- <h1 class="brand-name">天豹云仓</h1> -->
|
||||
<p class="brand-desc">现代化仓储管理系统 - 助力企业高效运营</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧表单区 -->
|
||||
<div class="login-right-panel">
|
||||
<lang-select class="set-language" />
|
||||
|
||||
<!-- 登录表单 -->
|
||||
<!-- ========== 注册表单 ========== -->
|
||||
<el-form
|
||||
v-if="!showRegister"
|
||||
ref="loginFormRef"
|
||||
:model="loginForm"
|
||||
:rules="loginRules"
|
||||
class="login-form"
|
||||
auto-complete="on"
|
||||
label-position="top"
|
||||
>
|
||||
<div class="title-container">
|
||||
<h3 class="title">{{ $t('login.title') }}</h3>
|
||||
<p class="subtitle">欢迎回来,请登录您的账户</p>
|
||||
</div>
|
||||
|
||||
<el-form-item prop="username" :label="$t('login.username')">
|
||||
<el-input
|
||||
ref="usernameRef"
|
||||
v-model="loginForm.username"
|
||||
:placeholder="$t('login.usernamePlaceholder')"
|
||||
name="username"
|
||||
type="text"
|
||||
tabindex="1"
|
||||
auto-complete="on"
|
||||
>
|
||||
<template #prefix>
|
||||
<svg-icon icon-class="user" />
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item prop="password" :label="$t('login.password')">
|
||||
<el-input
|
||||
:key="passwordType"
|
||||
ref="passwordRef"
|
||||
v-model="loginForm.password"
|
||||
:type="passwordType"
|
||||
:placeholder="$t('login.passwordPlaceholder')"
|
||||
name="password"
|
||||
tabindex="2"
|
||||
auto-complete="on"
|
||||
@keyup.enter="handleLogin"
|
||||
>
|
||||
<template #prefix>
|
||||
<svg-icon icon-class="password" />
|
||||
</template>
|
||||
<template #suffix>
|
||||
<span class="show-pwd" @click="showPwd">
|
||||
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
|
||||
</span>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-button
|
||||
:loading="loading"
|
||||
type="primary"
|
||||
class="submit-btn"
|
||||
@click.prevent="handleLogin"
|
||||
>
|
||||
{{ loading ? $t('login.loggingIn') : $t('login.logIn') }}
|
||||
</el-button>
|
||||
|
||||
<div class="form-footer">
|
||||
<span>{{ $t('login.noAccount') }}</span>
|
||||
<el-button type="link" @click="showRegister = true">{{ $t('login.register') }}</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<!-- 注册表单 -->
|
||||
<el-form
|
||||
v-else
|
||||
v-if="showRegister"
|
||||
ref="registerFormRef"
|
||||
:model="registerForm"
|
||||
:rules="registerRules"
|
||||
@ -105,9 +39,7 @@
|
||||
tabindex="1"
|
||||
auto-complete="on"
|
||||
>
|
||||
<template #prefix>
|
||||
<svg-icon icon-class="user" />
|
||||
</template>
|
||||
<template #prefix><svg-icon icon-class="user" /></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
@ -117,30 +49,25 @@
|
||||
:placeholder="$t('login.emailPlaceholder')"
|
||||
name="email"
|
||||
type="email"
|
||||
tabindex="4"
|
||||
tabindex="2"
|
||||
auto-complete="on"
|
||||
>
|
||||
<template #prefix>
|
||||
<svg-icon icon-class="email" />
|
||||
</template>
|
||||
<template #prefix><svg-icon icon-class="email" /></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-input
|
||||
v-model="registerForm.real_name"
|
||||
:placeholder="$t('login.realNamePlaceholder')"
|
||||
name="real_name"
|
||||
type="text"
|
||||
tabindex="5"
|
||||
auto-complete="on"
|
||||
>
|
||||
<template #prefix>
|
||||
<svg-icon icon-class="user" />
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-input
|
||||
v-model="registerForm.real_name"
|
||||
:placeholder="$t('login.realNamePlaceholder')"
|
||||
name="real_name"
|
||||
type="text"
|
||||
tabindex="3"
|
||||
auto-complete="on"
|
||||
>
|
||||
<template #prefix><svg-icon icon-class="user" /></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item prop="password" :label="$t('login.password')">
|
||||
<el-input
|
||||
@ -149,12 +76,10 @@
|
||||
:type="passwordType"
|
||||
:placeholder="$t('login.passwordPlaceholder')"
|
||||
name="password"
|
||||
tabindex="2"
|
||||
tabindex="4"
|
||||
auto-complete="on"
|
||||
>
|
||||
<template #prefix>
|
||||
<svg-icon icon-class="password" />
|
||||
</template>
|
||||
<template #prefix><svg-icon icon-class="password" /></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
@ -165,16 +90,15 @@
|
||||
:type="passwordType"
|
||||
:placeholder="$t('login.confirmPassword')"
|
||||
name="confirmPassword"
|
||||
tabindex="3"
|
||||
tabindex="5"
|
||||
auto-complete="on"
|
||||
>
|
||||
<template #prefix>
|
||||
<svg-icon icon-class="password" />
|
||||
</template>
|
||||
<template #prefix><svg-icon icon-class="password" /></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-button
|
||||
:loading="loading"
|
||||
type="primary"
|
||||
class="submit-btn"
|
||||
@click.prevent="handleRegister"
|
||||
@ -187,16 +111,137 @@
|
||||
<el-button type="link" @click="showRegister = false">{{ $t('login.logIn') }}</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<!-- ========== 登录区(账号 + 扫码 Tab) ========== -->
|
||||
<div v-else class="login-tabs-wrap">
|
||||
<div class="title-container">
|
||||
<h3 class="title">{{ $t('login.title') }}</h3>
|
||||
<p class="subtitle">欢迎回来,请登录您的账户</p>
|
||||
</div>
|
||||
|
||||
<!-- Tab 切换按钮 -->
|
||||
<div class="login-tabs">
|
||||
<button
|
||||
class="tab-btn"
|
||||
:class="{ active: activeTab === 'account' }"
|
||||
@click="switchTab('account')"
|
||||
>
|
||||
{{ $t('login.accountLogin') }}
|
||||
</button>
|
||||
<button
|
||||
class="tab-btn"
|
||||
:class="{ active: activeTab === 'qrcode' }"
|
||||
@click="switchTab('qrcode')"
|
||||
>
|
||||
{{ $t('login.qrcodeLogin') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 账号登录表单 -->
|
||||
<el-form
|
||||
v-show="activeTab === 'account'"
|
||||
ref="loginFormRef"
|
||||
:model="loginForm"
|
||||
:rules="loginRules"
|
||||
class="login-form"
|
||||
auto-complete="on"
|
||||
label-position="top"
|
||||
>
|
||||
<el-form-item prop="username" :label="$t('login.username')">
|
||||
<el-input
|
||||
ref="usernameRef"
|
||||
v-model="loginForm.username"
|
||||
:placeholder="$t('login.usernamePlaceholder')"
|
||||
name="username"
|
||||
type="text"
|
||||
tabindex="1"
|
||||
auto-complete="on"
|
||||
>
|
||||
<template #prefix><svg-icon icon-class="user" /></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item prop="password" :label="$t('login.password')">
|
||||
<el-input
|
||||
:key="passwordType"
|
||||
ref="passwordRef"
|
||||
v-model="loginForm.password"
|
||||
:type="passwordType"
|
||||
:placeholder="$t('login.passwordPlaceholder')"
|
||||
name="password"
|
||||
tabindex="2"
|
||||
auto-complete="on"
|
||||
@keyup.enter="handleLogin"
|
||||
>
|
||||
<template #prefix><svg-icon icon-class="password" /></template>
|
||||
<template #suffix>
|
||||
<span class="show-pwd" @click="showPwd">
|
||||
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
|
||||
</span>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-button
|
||||
:loading="loading"
|
||||
type="primary"
|
||||
class="submit-btn"
|
||||
@click.prevent="handleLogin"
|
||||
>
|
||||
{{ loading ? $t('login.loggingIn') : $t('login.logIn') }}
|
||||
</el-button>
|
||||
|
||||
<div class="form-footer">
|
||||
<span>{{ $t('login.noAccount') }}</span>
|
||||
<el-button type="link" @click="showRegister = true">{{ $t('login.register') }}</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<!-- 微信扫码登录面板 -->
|
||||
<div v-show="activeTab === 'qrcode'" class="qrcode-panel">
|
||||
<p class="qrcode-desc">{{ $t('login.qrcodeDesc') }}</p>
|
||||
|
||||
<!-- 二维码展示区 -->
|
||||
<div class="qrcode-box" @click="qrcodeExpired ? refreshQrCode() : undefined">
|
||||
<!-- 加载中 -->
|
||||
<div v-if="qrcodeLoading" class="qrcode-mask">
|
||||
<el-icon class="loading-icon"><Loading /></el-icon>
|
||||
<span>{{ $t('login.qrcodeLoading') }}</span>
|
||||
</div>
|
||||
<!-- 已扫码等待确认 -->
|
||||
<div v-else-if="qrcodeScanned" class="qrcode-mask scanned">
|
||||
<el-icon><CircleCheck /></el-icon>
|
||||
<span>{{ $t('login.qrcodeScanned') }}</span>
|
||||
</div>
|
||||
<!-- 过期遮罩 -->
|
||||
<div v-else-if="qrcodeExpired" class="qrcode-mask expired" style="cursor:pointer">
|
||||
<el-icon><RefreshRight /></el-icon>
|
||||
<span>{{ $t('login.qrcodeExpired') }}</span>
|
||||
<small>{{ $t('login.qrcodeRefresh') }}</small>
|
||||
</div>
|
||||
<!-- 二维码图片 -->
|
||||
<img v-if="qrcodeUrl" :src="qrcodeUrl" class="qrcode-img" alt="WeChat QR Code" />
|
||||
<div v-else-if="!qrcodeLoading" class="qrcode-placeholder" />
|
||||
</div>
|
||||
|
||||
<p class="qrcode-waiting" v-if="!qrcodeExpired && !qrcodeLoading && !qrcodeScanned">
|
||||
{{ $t('login.qrcodeWaiting') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, nextTick, watch } from 'vue'
|
||||
import { ref, reactive, watch, onUnmounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, type FormInstance } from 'element-plus'
|
||||
import { Loading, CircleCheck, RefreshRight } from '@element-plus/icons-vue'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import * as userApi from '@/api/user'
|
||||
import { setToken } from '@/utils/auth'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import LangSelect from '@/components/LangSelect/index.vue'
|
||||
|
||||
@ -205,36 +250,36 @@ const route = useRoute()
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// ---- 表单 refs ----
|
||||
const loginFormRef = ref<FormInstance>()
|
||||
const registerFormRef = ref<FormInstance>()
|
||||
|
||||
// ---- 视图状态 ----
|
||||
const showRegister = ref(false)
|
||||
const activeTab = ref<'account' | 'qrcode'>('account')
|
||||
|
||||
const loginForm = reactive({
|
||||
username: '',
|
||||
password: ''
|
||||
})
|
||||
|
||||
const registerForm = reactive({
|
||||
username: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
email:'',
|
||||
real_name:'',
|
||||
})
|
||||
|
||||
// ---- 账号登录 ----
|
||||
const loginForm = reactive({ username: '', password: '' })
|
||||
const loginRules = {
|
||||
username: [{ required: true, trigger: 'blur', message: t('login.usernamePlaceholder') }],
|
||||
password: [{ required: true, trigger: 'blur', message: t('login.passwordPlaceholder') }]
|
||||
}
|
||||
|
||||
const validateConfirmPassword = (rule: any, value: string, callback: any) => {
|
||||
// ---- 注册 ----
|
||||
const registerForm = reactive({
|
||||
username: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
email: '',
|
||||
real_name: ''
|
||||
})
|
||||
const validateConfirmPassword = (_rule: any, value: string, callback: any) => {
|
||||
if (value !== registerForm.password) {
|
||||
callback(new Error(t('login.passwordMismatch')))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
const registerRules = {
|
||||
username: [{ required: true, trigger: 'blur', message: t('login.usernamePlaceholder') }],
|
||||
password: [
|
||||
@ -247,15 +292,16 @@ const registerRules = {
|
||||
]
|
||||
}
|
||||
|
||||
// ---- 密码显示切换 ----
|
||||
const passwordType = ref('password')
|
||||
const loading = ref(false)
|
||||
const showPwd = () => {
|
||||
passwordType.value = passwordType.value === 'password' ? '' : 'password'
|
||||
}
|
||||
|
||||
// ---- 路由重定向 ----
|
||||
const redirect = ref('')
|
||||
const otherQuery = ref({})
|
||||
|
||||
const otherQuery = ref<Record<string, any>>({})
|
||||
watch(
|
||||
() => route.query,
|
||||
(query) => {
|
||||
@ -268,6 +314,7 @@ watch(
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
// ---- 登录 ----
|
||||
const handleLogin = () => {
|
||||
loginFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
@ -275,8 +322,8 @@ const handleLogin = () => {
|
||||
try {
|
||||
await userStore.login(loginForm)
|
||||
router.push({ path: redirect.value || '/', query: otherQuery.value })
|
||||
} catch (error: any) {
|
||||
// Error is already handled by request interceptor with ElMessage
|
||||
} catch {
|
||||
// handled by interceptor
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@ -284,28 +331,155 @@ const handleLogin = () => {
|
||||
})
|
||||
}
|
||||
|
||||
// ---- 注册 ----
|
||||
const handleRegister = () => {
|
||||
registerFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
loading.value = true
|
||||
try {
|
||||
const { username, email, real_name, password } = registerForm
|
||||
await userStore.register({
|
||||
username,
|
||||
email,
|
||||
real_name,
|
||||
password
|
||||
})
|
||||
await userStore.register({ username, email, real_name, password })
|
||||
ElMessage.success(t('login.registerSuccess') || '注册成功')
|
||||
showRegister.value = false
|
||||
} catch (error: any) {
|
||||
// Error is handled by request interceptor
|
||||
} catch {
|
||||
// handled by interceptor
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// ====================================================
|
||||
// 微信扫码登录
|
||||
// ====================================================
|
||||
const qrcodeUrl = ref('')
|
||||
const qrcodeLoading = ref(false)
|
||||
const qrcodeExpired = ref(false)
|
||||
const qrcodeScanned = ref(false)
|
||||
let pollingAborted = false
|
||||
let currentPollingVersion = 0
|
||||
|
||||
const qrBaseUrl = 'https://ye4s.wms.gztbyc.com/qrcode/build?text='
|
||||
const loginLinkTemplate = 'https://ye4s.wms.gztbyc.com/mini/?spm=0.4.${code}.1.4'
|
||||
|
||||
/** 构造完整二维码 URL */
|
||||
const getFullQrUrl = (code: string) => {
|
||||
const targetUrl = loginLinkTemplate.replace('${code}', code)
|
||||
return qrBaseUrl + encodeURIComponent(targetUrl)
|
||||
}
|
||||
|
||||
/** 停止当前轮询 */
|
||||
const stopPolling = () => {
|
||||
pollingAborted = true
|
||||
currentPollingVersion++
|
||||
}
|
||||
|
||||
/** 跳转到已登录状态 */
|
||||
const doLoginWithToken = (token: string) => {
|
||||
setToken(token)
|
||||
userStore.$patch({ token })
|
||||
router.push({ path: redirect.value || '/', query: otherQuery.value })
|
||||
}
|
||||
|
||||
/** 长轮询 */
|
||||
const startPolling = () => {
|
||||
pollingAborted = false
|
||||
const version = currentPollingVersion
|
||||
const poll = async () => {
|
||||
if (pollingAborted || currentPollingVersion !== version) return
|
||||
try {
|
||||
const resp = await (userApi as any).getLoginWechatCode({
|
||||
clientCode: qrcodeClientCode,
|
||||
})
|
||||
if (pollingAborted || currentPollingVersion !== version) return
|
||||
|
||||
const data = resp?.data
|
||||
if (data) {
|
||||
// 更新缓存的 clientCode
|
||||
if (data.clientCode || data.client_code) {
|
||||
qrcodeClientCode = data.clientCode || data.client_code
|
||||
}
|
||||
|
||||
// 服务端返回 token 或 loginToken 表示扫码登录成功
|
||||
if (data.loginToken || data.token) {
|
||||
qrcodeScanned.value = true
|
||||
stopPolling()
|
||||
setTimeout(() => doLoginWithToken(data.loginToken || data.token), 800)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新状态
|
||||
if (data.status === 'scanned' || data.scanned) {
|
||||
qrcodeScanned.value = true
|
||||
}
|
||||
if (data.status === 'expired') {
|
||||
qrcodeExpired.value = true
|
||||
stopPolling()
|
||||
return
|
||||
}
|
||||
if (data.qrCodeUrl || data.code) {
|
||||
qrcodeUrl.value = data.code ? getFullQrUrl(data.code) : data.qrCodeUrl
|
||||
}
|
||||
}
|
||||
// 继续下一轮
|
||||
poll()
|
||||
} catch (err: any) {
|
||||
if (pollingAborted || currentPollingVersion !== version) return
|
||||
// 网络错误等,稍等后重试
|
||||
setTimeout(poll, 3000)
|
||||
}
|
||||
}
|
||||
poll()
|
||||
}
|
||||
|
||||
let qrcodeClientCode = ''
|
||||
|
||||
/** 初次获取二维码 */
|
||||
const fetchQrCode = async () => {
|
||||
qrcodeLoading.value = true
|
||||
qrcodeExpired.value = false
|
||||
qrcodeScanned.value = false
|
||||
qrcodeUrl.value = ''
|
||||
qrcodeClientCode = ''
|
||||
try {
|
||||
const resp = await (userApi as any).getLoginWechatCode()
|
||||
const data = resp?.data
|
||||
if (data) {
|
||||
qrcodeClientCode = data.clientCode || data.client_code
|
||||
const code = data.code
|
||||
qrcodeUrl.value = code ? getFullQrUrl(code) : (data.qrCodeUrl || data.qr_code_url)
|
||||
if (qrcodeClientCode) {
|
||||
startPolling()
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
qrcodeExpired.value = true
|
||||
} finally {
|
||||
qrcodeLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 手动刷新二维码 */
|
||||
const refreshQrCode = () => {
|
||||
stopPolling()
|
||||
fetchQrCode()
|
||||
}
|
||||
|
||||
/** Tab 切换 */
|
||||
const switchTab = (tab: 'account' | 'qrcode') => {
|
||||
if (tab === activeTab.value) return
|
||||
activeTab.value = tab
|
||||
if (tab === 'qrcode') {
|
||||
fetchQrCode()
|
||||
} else {
|
||||
stopPolling()
|
||||
}
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
stopPolling()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@ -376,7 +550,7 @@ const handleRegister = () => {
|
||||
|
||||
.login-left-panel {
|
||||
flex: 1;
|
||||
background: linear-gradient(to bottom, #1890ff, #001529);
|
||||
background: linear-gradient(to bottom, #1890ff, #5c9cd8);
|
||||
padding: 40px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -414,8 +588,9 @@ const handleRegister = () => {
|
||||
}
|
||||
|
||||
.brand-desc {
|
||||
font-size: 16px;
|
||||
font-size: 20px;
|
||||
opacity: 0.8;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -481,9 +656,160 @@ const handleRegister = () => {
|
||||
color: #409eff;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 登录 Tab ----
|
||||
.login-tabs-wrap {
|
||||
width: 100%;
|
||||
|
||||
/* 固定登录和扫码面板高度,防止切换时抖动 */
|
||||
.login-form,
|
||||
.qrcode-panel {
|
||||
height: 330px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
.login-tabs {
|
||||
display: flex;
|
||||
border-bottom: 2px solid #f0f2f5;
|
||||
margin-bottom: 24px;
|
||||
|
||||
.tab-btn {
|
||||
flex: 1;
|
||||
background: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
padding: 10px 0;
|
||||
font-size: 15px;
|
||||
color: #909399;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
transition: color 0.2s;
|
||||
|
||||
&.active {
|
||||
color: #409eff;
|
||||
font-weight: 600;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -2px;
|
||||
left: 10%;
|
||||
width: 80%;
|
||||
height: 2px;
|
||||
background: #409eff;
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover:not(.active) {
|
||||
color: #606266;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 微信扫码面板 ----
|
||||
.qrcode-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 8px 0 16px;
|
||||
|
||||
.qrcode-desc {
|
||||
height: 18px; /* 固定描述文字高度 */
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
margin-bottom: 20px;
|
||||
text-align: center;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.qrcode-box {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
flex-shrink: 0; /* 防止尺寸被压缩 */
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 8px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #fafafa;
|
||||
|
||||
.qrcode-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.qrcode-placeholder {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
.qrcode-mask {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
z-index: 2;
|
||||
|
||||
.el-icon {
|
||||
font-size: 36px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 12px;
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
&.scanned .el-icon {
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
&.expired .el-icon {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.loading-icon {
|
||||
animation: rotating 1.5s linear infinite;
|
||||
font-size: 32px;
|
||||
color: #409eff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.qrcode-waiting {
|
||||
height: 18px; /* 固定底部提示文字高度 */
|
||||
margin-top: 14px;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes rotating {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* 响应式适配 */
|
||||
@media screen and (max-width: 768px) {
|
||||
.login-card {
|
||||
|
||||
@ -54,11 +54,12 @@
|
||||
placeholder="请选择部门"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option label="技术部" value="技术部" />
|
||||
<el-option label="产品部" value="产品部" />
|
||||
<el-option label="设计部" value="设计部" />
|
||||
<el-option label="市场部" value="市场部" />
|
||||
<el-option label="运营部" value="运营部" />
|
||||
<el-option
|
||||
v-for="item in DEPARTMENT_OPTIONS"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
@ -95,6 +96,7 @@
|
||||
import { ref, watch, reactive } from 'vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { DEPARTMENT_OPTIONS } from '../profile-config'
|
||||
|
||||
const props = defineProps<{
|
||||
user: any
|
||||
@ -136,6 +138,7 @@ const rules = reactive<FormRules>({
|
||||
|
||||
watch(() => props.user, (newVal) => {
|
||||
if (newVal) {
|
||||
console.log('BasicInfoForm received user data from parent:', newVal)
|
||||
form.nickname = newVal.nickname || ''
|
||||
form.email = newVal.email || ''
|
||||
form.phone = newVal.phone || ''
|
||||
|
||||
@ -73,10 +73,13 @@ import ChangePasswordDialog from './components/ChangePasswordDialog.vue'
|
||||
import WelcomCard from '../dashboard/components/WelcomCard.vue'
|
||||
import Bind from './components/Bind.vue'
|
||||
|
||||
// 引入配置文件
|
||||
import { MOCK_SECURITY_INFO, MOCK_OPERATION_LOGS, PROFILE_TABS } from './profile-config'
|
||||
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const activeTab = ref('basic')
|
||||
const activeTab = ref<string>(PROFILE_TABS?.[0]?.name ?? 'basic')
|
||||
const showPasswordDialog = ref(false)
|
||||
|
||||
// User Info
|
||||
@ -87,11 +90,11 @@ watch(() => userStore.user, (newVal) => {
|
||||
userInfo.value = {
|
||||
id: newVal.id,
|
||||
username: newVal.username,
|
||||
nickname: newVal.employees_name || newVal.nickname, // Vue 2 used employees_name for nickname in one place
|
||||
nickname: newVal.employees_name || newVal.nickname,
|
||||
avatar: newVal.avatar || 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
||||
email: newVal.email,
|
||||
phone: newVal.phone,
|
||||
department: newVal.department || newVal.employees_name, // Vue 2 mapped department to employees_name? keeping logic but maybe check
|
||||
department: newVal.department || '',
|
||||
position: newVal.position,
|
||||
bio: newVal.bio,
|
||||
lastLogin: newVal.last_login_at,
|
||||
@ -102,32 +105,11 @@ watch(() => userStore.user, (newVal) => {
|
||||
}
|
||||
}, { immediate: true, deep: true })
|
||||
|
||||
// Security Info (Mocked as per Vue 2)
|
||||
const securityInfo = reactive({
|
||||
passwordStrength: 'strong',
|
||||
lastPasswordChange: '2023-12-01',
|
||||
twoFactorEnabled: true,
|
||||
emailVerified: true,
|
||||
phoneVerified: true,
|
||||
loginDevices: [
|
||||
{ id: 1, device: 'Chrome on Windows', location: '北京', lastActive: '2024-01-20 14:30', current: true },
|
||||
{ id: 2, device: 'Safari on iPhone', location: '上海', lastActive: '2024-01-19 09:15', current: false }
|
||||
]
|
||||
})
|
||||
// Security Info (From Config)
|
||||
const securityInfo = reactive({ ...MOCK_SECURITY_INFO })
|
||||
|
||||
// Operation Logs (Mocked as per Vue 2)
|
||||
const operationLogs = reactive({
|
||||
list: [
|
||||
{ id: 1, action: '登录系统', ip: '192.168.1.100', time: '2024-01-20 14:30:22', status: '成功' },
|
||||
{ id: 2, action: '修改密码', ip: '192.168.1.100', time: '2024-01-19 10:15:33', status: '成功' },
|
||||
{ id: 3, action: '更新个人信息', ip: '192.168.1.100', time: '2024-01-18 16:20:45', status: '成功' },
|
||||
{ id: 4, action: '导出数据', ip: '192.168.1.100', time: '2024-01-17 11:05:12', status: '成功' },
|
||||
{ id: 5, action: '登录系统', ip: '192.168.1.101', time: '2024-01-16 09:30:55', status: '失败' }
|
||||
],
|
||||
total: 45,
|
||||
page: 1,
|
||||
loading: false
|
||||
})
|
||||
// Operation Logs (From Config)
|
||||
const operationLogs = reactive({ ...MOCK_OPERATION_LOGS })
|
||||
|
||||
onMounted(() => {
|
||||
loadOperationLogs()
|
||||
|
||||
49
src/views/profile/profile-config.ts
Normal file
49
src/views/profile/profile-config.ts
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 个人中心页配置文件
|
||||
* 用于存放静态配置、Mock数据模板、表单选项等,实现视图与配置解耦
|
||||
*/
|
||||
|
||||
// 1. 标签页配置
|
||||
export const PROFILE_TABS = [
|
||||
{ label: '基本信息', name: 'basic', component: 'BasicInfoForm' },
|
||||
{ label: '账户安全', name: 'security', component: 'AccountSecurity' },
|
||||
{ label: '操作日志', name: 'logs', component: 'OperationLogs' },
|
||||
{ label: '加入公司', name: 'joinStore', component: 'WelcomCard' },
|
||||
{ label: '微信绑定', name: 'bind', component: 'Bind' }
|
||||
]
|
||||
|
||||
// 2. 部门选项配置 (BasicInfoForm 使用)
|
||||
export const DEPARTMENT_OPTIONS = [
|
||||
{ label: '技术部', value: '技术部' },
|
||||
{ label: '产品部', value: '产品部' },
|
||||
{ label: '设计部', value: '设计部' },
|
||||
{ label: '市场部', value: '市场部' },
|
||||
{ label: '运营部', value: '运营部' }
|
||||
]
|
||||
|
||||
// 3. 账户安全 Mock 数据
|
||||
export const MOCK_SECURITY_INFO = {
|
||||
passwordStrength: 'strong',
|
||||
lastPasswordChange: '2023-12-01',
|
||||
twoFactorEnabled: true,
|
||||
emailVerified: true,
|
||||
phoneVerified: true,
|
||||
loginDevices: [
|
||||
{ id: 1, device: 'Chrome on Windows', location: '北京', lastActive: '2024-01-20 14:30', current: true },
|
||||
{ id: 2, device: 'Safari on iPhone', location: '上海', lastActive: '2024-01-19 09:15', current: false }
|
||||
]
|
||||
}
|
||||
|
||||
// 4. 操作日志 Mock 数据
|
||||
export const MOCK_OPERATION_LOGS = {
|
||||
list: [
|
||||
{ id: 1, action: '登录系统', ip: '192.168.1.100', time: '2024-01-20 14:30:22', status: '成功' },
|
||||
{ id: 2, action: '修改密码', ip: '192.168.1.100', time: '2024-01-19 10:15:33', status: '成功' },
|
||||
{ id: 3, action: '更新个人信息', ip: '192.168.1.100', time: '2024-01-18 16:20:45', status: '成功' },
|
||||
{ id: 4, action: '导出数据', ip: '192.168.1.100', time: '2024-01-17 11:05:12', status: '成功' },
|
||||
{ id: 5, action: '登录系统', ip: '192.168.1.101', time: '2024-01-16 09:30:55', status: '失败' }
|
||||
],
|
||||
total: 45,
|
||||
page: 1,
|
||||
loading: false
|
||||
}
|
||||
@ -227,7 +227,7 @@ import { useUserStore } from '@/stores/modules/user'
|
||||
// Utils
|
||||
import { parseTime } from '@/utils/index'
|
||||
import { buildStockQuery } from '@/utils/stockQueryBuilder'
|
||||
import { labelInner } from 'echarts/types/src/label/labelStyle.js'
|
||||
// import { labelInner } from 'echarts/types/src/label/labelStyle.js'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const hasPermission = (perm: string) => {
|
||||
|
||||
@ -57,8 +57,8 @@
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import * as stationApi from '@/api/print/station'
|
||||
import { t } from 'vue-router/dist/index-DFCq6eJK.js'
|
||||
import { fi } from 'element-plus/es/locales.mjs'
|
||||
// import { t } from 'vue-router/dist/index-DFCq6eJK.js'
|
||||
// import { fi } from 'element-plus/es/locales.mjs'
|
||||
|
||||
// 从父组件接收的外部属性
|
||||
const props = defineProps({
|
||||
|
||||
17
日志.md
17
日志.md
@ -101,4 +101,19 @@ stock获取回收站商品接口复用了商品信息接口stock.warehouse.list
|
||||
|
||||
三、后续计划
|
||||
完善接口设计,排除故障接口,测试接口功能。
|
||||
实现将项目打包并上传到服务器实现静态资源托管。
|
||||
实现将项目打包并上传到服务器实现静态资源托管。
|
||||
|
||||
2026.3.28
|
||||
一、今日完成
|
||||
-404页面新增路由重定向和返回上一个页面功能,优化使用体验。
|
||||
-登录页面新增微信扫码登录功能。
|
||||
-优化注册/登录页面样式。
|
||||
-新增项目打包并推送到服务器、服务器项目回滚脚本。
|
||||
- 添加了配置文件(profile-config.ts),包含静态配置、模拟数据模板以及用户个人资料页面的表单选项。
|
||||
|
||||
二、问题记录
|
||||
无
|
||||
|
||||
三、后续计划
|
||||
更新项目样式、布局。
|
||||
完善测试api接口,修复问题。
|
||||
Loading…
x
Reference in New Issue
Block a user