Skip to content
Open
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 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
ENV = 'development'

# base api
VUE_APP_BASE_API = '/dev-api'
VUE_APP_BASE_API = 'http://localhost:57381/api'
18 changes: 18 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,23 @@
"@/*": ["src/*"]
}
},
"signalR": {
"hubUrl": "http://localhost:57381/signalr",
"hubName": "rfidHub"
},
"api": {
"statsUrl": "http://localhost:57381/api/rfid/stats",
"pollIntervalSeconds": 10
},
"ui": {
"alertCountdownSeconds": 5
},
"tts": {
"enabled": true,
"lang": "zh-CN",
"rate": 1,
"pitch": 1
},
"exclude": ["node_modules", "dist"]

}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
"test:ci": "npm run lint && npm run test:unit"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^7.0.1",
"axios": "0.18.1",
"core-js": "3.6.5",
"element-ui": "2.13.2",
"jquery": "^3.7.1",
"js-cookie": "2.2.0",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"path-to-regexp": "2.4.0",
"signalr": "^2.4.3",
"vue": "2.6.10",
"vue-router": "3.0.6",
"vuex": "3.1.0"
Expand Down
3 changes: 3 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= webpackConfig.name %></title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/signalr@2.4.3/jquery.signalR.min.js"></script>
<script src="/signalr/hubs"></script>
</head>
<body>
<noscript>
Expand Down
10 changes: 10 additions & 0 deletions src/api/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// src/api/dashboard.js
import request from '@/utils/request'
import config from '@/config.js' // ✅ 新增这一行

export function getStats() {
return request({
url: config.api.statsUrl, // ✅ 使用配置里的地址
method: 'get'
}).then(res => res) // 直接返回接口数据
}
6 changes: 3 additions & 3 deletions src/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import request from '@/utils/request'

export function login(data) {
return request({
url: '/vue-admin-template/user/login',
url: '/login', // 对应后台路由
method: 'post',
data
})
}

export function getInfo(token) {
return request({
url: '/vue-admin-template/user/info',
url: '/userinfo',
method: 'get',
params: { token }
})
}

export function logout() {
return request({
url: '/vue-admin-template/user/logout',
url: '/logout',
method: 'post'
})
}
19 changes: 19 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default {
signalR: {
hubUrl: 'http://localhost:57381/signalr',
hubName: 'rfidHub'
},
api: {
statsUrl: 'http://localhost:57381/api/rfid/stats',
pollIntervalSeconds: 10
},
ui: {
alertCountdownSeconds: 5
},
tts: {
enabled: true,
lang: 'zh-CN',
rate: 1,
pitch: 1
}
}
50 changes: 40 additions & 10 deletions src/layout/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@
<div class="right-menu">
<el-dropdown class="avatar-container" trigger="click">
<div class="avatar-wrapper">
<img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar">
<div class="avatar-placeholder">{{ name.slice(0,1) }}</div>
<!-- <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar"> -->
<span class="user-name">{{ name }}</span>
<i class="el-icon-caret-bottom" />
</div>
<el-dropdown-menu slot="dropdown" class="user-dropdown">
<router-link to="/">
<el-dropdown-item>
Home
首页
</el-dropdown-item>
</router-link>
<a target="_blank" href="https://github.com/PanJiaChen/vue-admin-template/">
<el-dropdown-item>Github</el-dropdown-item>
</a>
<a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/">
<el-dropdown-item>Docs</el-dropdown-item>
<el-dropdown-item>文档</el-dropdown-item>
</a>
<el-dropdown-item divided @click.native="logout">
<span style="display:block;">Log Out</span>
<span style="display:block;">退出</span>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
Expand All @@ -32,7 +34,8 @@
</template>

<script>
import { mapGetters } from 'vuex'
import { mapState} from 'vuex'
import { mapGetters} from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'

Expand All @@ -41,11 +44,18 @@ export default {
Breadcrumb,
Hamburger
},
// data() {
// return {
// username: ''
// }
// },
computed: {
...mapGetters([
'sidebar',
'avatar'
])
...mapGetters(['sidebar', 'avatar']),
...mapState('user', ['name']) // 从 state 直接映射
},

mounted() {
console.log('Vuex state:', this.$store.state)
},
methods: {
toggleSideBar() {
Expand Down Expand Up @@ -83,7 +93,27 @@ export default {
.breadcrumb-container {
float: left;
}

.avatar-placeholder {
width: 32px;
height: 32px;
line-height: 32px;
border-radius: 50%;
background: linear-gradient(135deg, #2c7dfa, #00d084);
color: #fff;
text-align: center;
font-weight: 600;
margin-right: 6px;
display: inline-block;
vertical-align: middle;
}
.user-name {
font-weight: 500;
color: #333;
vertical-align: middle;
}
.right-menu-item {
margin-left: 8px;
}
.right-menu {
float: right;
height: 100%;
Expand Down
6 changes: 5 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n
Expand All @@ -14,6 +13,11 @@ import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
import '@fortawesome/fontawesome-free/css/all.min.css' // 图标
import $ from 'jquery'
import 'signalr'

window.$ = $

/**
* If you don't want to use mock-server
Expand Down
10 changes: 7 additions & 3 deletions src/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ router.beforeEach(async(to, from, next) => {
} catch (error) {
// remove token and go to login page to re-login
await store.dispatch('user/resetToken')
Message.error(error || 'Has Error')
next(`/login?redirect=${to.path}`)
NProgress.done()
Message({
message: (error && error.message) || 'Has Error',
type: 'error',
showClose: true
})
next(`/login?redirect=${to.path}`)
NProgress.done()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const constantRoutes = [
path: 'dashboard',
name: 'Dashboard',
component: () => import('@/views/dashboard/index'),
meta: { title: 'Dashboard', icon: 'dashboard' }
meta: { title: '软镜洗消', icon: 'dashboard' }
}]
},

Expand Down
7 changes: 5 additions & 2 deletions src/store/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ const actions = {
return new Promise((resolve, reject) => {
login({ username: username.trim(), password: password }).then(response => {
const { data } = response
commit('SET_TOKEN', data.token)
setToken(data.token)
const token = data.token
const name = data.UserName || username // 这里确保有用户名
commit('SET_TOKEN', token)
commit('SET_NAME', name)
setToken(token) // 保存 token
resolve()
}).catch(error => {
reject(error)
Expand Down
Empty file added src/styles/dashboard.scss
Empty file.
30 changes: 19 additions & 11 deletions src/styles/variables.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
// sidebar
$menuText:#bfcbd9;
$menuActiveText:#409EFF;
$subMenuActiveText:#f4f4f5; //https://github.com/ElemeFE/element/issues/12951
// src/styles/variables.scss

$menuBg:#304156;
$menuHover:#263445;
// ========== Element UI 主题变量 ==========
$menuText: #bfcbd9;
$menuActiveText: #409EFF;
$subMenuActiveText: #f4f4f5;

$subMenuBg:#1f2d3d;
$subMenuHover:#001528;
$menuBg: #304156;
$menuHover: #263445;
$subMenuBg: #1f2d3d;
$subMenuHover: #001528;

$sideBarWidth: 210px;

// the :export directive is the magic sauce for webpack
// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
// ========== 登录页 / 全局通用变量 ==========
$bg: #0a1a2f;
$light_gray: #e0e6f0;
$cursor: #ffffff;
$primary: #2c7dfa;
$secondary: #00d084;
$dark_gray: #889aa4;

// ========== 导出给 JavaScript 使用 ==========
:export {
menuText: $menuText;
menuActiveText: $menuActiveText;
Expand All @@ -22,4 +30,4 @@ $sideBarWidth: 210px;
subMenuBg: $subMenuBg;
subMenuHover: $subMenuHover;
sideBarWidth: $sideBarWidth;
}
}
Loading