diff --git a/.gitignore b/.gitignore index a19f004..b5708e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,23 @@ -# ---> Vue -# gitignore template for Vue.js projects -# -# Recommended template: Node.gitignore +.DS_Store +node_modules +/dist +/situation -# TODO: where does this rule come from? -docs/_book - -# TODO: where does this rule come from? -test/ +# local env files +.env.local +.env.*.local +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +package-lock.json +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..d7b13c5 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,9 @@ +{ + "tabWidth": 2, + "useTabs": false, + "semi": false, + "singleQuote": true, + "trailingComma": "es5", + "bracketSpacing": false, + "htmlWhitespaceSensitivity": "ignore" +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..010dba8 --- /dev/null +++ b/index.html @@ -0,0 +1,15 @@ + + + + + + + 燃谷科技(南京)有限公司 + + + + +
+ + + diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..f792213 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "ES6", + "module": "commonjs", + "allowSyntheticDefaultImports": true, + "baseUrl": "./", + "paths": { + "@/*": ["src/*"], + "_c/*": ["src/components/*"] + } + }, + "exclude": ["node_modules", "dist", "protal"] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..9a69f74 --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "portal", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite --host", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "@vueuse/core": "^13.8.0", + "axios": "^1.11.0", + "element-plus": "^2.11.1", + "js-cookie": "^3.0.5", + "mitt": "^3.0.1", + "pinia": "^3.0.3", + "pinia-plugin-persistedstate": "^4.5.0", + "terser": "^5.43.1", + "vue": "^3.5.18", + "vue-router": "^4.5.1" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^6.0.1", + "fast-glob": "^3.3.3", + "postcss-pxtorem": "^6.1.0", + "sass": "^1.91.0", + "sass-loader": "^16.0.5", + "vite": "^7.1.2", + "vite-plugin-svg-icons": "^2.0.1" + } +} diff --git a/public/config.js b/public/config.js new file mode 100644 index 0000000..d3e1383 --- /dev/null +++ b/public/config.js @@ -0,0 +1,5 @@ +window.GD_KEYS = [ + '348d477ba83826e46b32d3ff10fffe82', + 'ed2ea36f8564541569c370254845d93d', + 'c1da03827f956a215311c0f5229bddc3', +] diff --git a/public/nav/index.js b/public/nav/index.js new file mode 100644 index 0000000..f45ea8d --- /dev/null +++ b/public/nav/index.js @@ -0,0 +1,51 @@ +window.nav = { + header: [ + {id: 1, label: '首页', url: '/', hasChildren: false}, + {id: 2, label: '产品中心', url: '/product', hasChildren: false}, + {id: 3, label: '服务与支撑', url: '/services', hasChildren: false}, + {id: 4, label: '新闻中心', url: '/news', hasChildren: false}, + {id: 5, label: '关于我们', url: '/about', hasChildren: false}, + {id: 6, label: '联系我们', url: '/link', hasChildren: false}, + ], + footer: [ + { + id: 1, + headerId: 2, + label: '产品中心', + url: '', + hasChildren: true, + children: [ + {id: 1.1, headerId: 2, label: '智能加载服务', url: '/product'}, + {id: 1.2, headerId: 2, label: '智能加载服务', url: '/product'}, + {id: 1.3, headerId: 2, label: '智能加载服务', url: '/product'}, + {id: 1.4, headerId: 2, label: '智能加载服务', url: '/product'}, + ], + }, + { + id: 2, + headerId: 3, + label: '服务与支撑', + url: '/services', + hasChildren: false, + }, + { + id: 3, + headerId: 0, + label: '软件下载', + url: '/download', + hasChildren: false, + }, + {id: 4, headerId: 4, label: '新闻中心', url: '/news', hasChildren: false}, + { + id: 5, + headerId: 0, + label: '关于燃谷', + url: '', + hasChildren: true, + children: [ + {id: 5.1, headerId: 5, label: '公司简介', url: '/about'}, + {id: 5.2, headerId: 6, label: '联系我们', url: '/link'}, + ], + }, + ], +} diff --git a/public/rangu.svg b/public/rangu.svg new file mode 100644 index 0000000..ed8cb81 --- /dev/null +++ b/public/rangu.svg @@ -0,0 +1,55 @@ + + + + diff --git a/public/static/images/footer/QR_code.png b/public/static/images/footer/QR_code.png new file mode 100644 index 0000000..ddc7ecb Binary files /dev/null and b/public/static/images/footer/QR_code.png differ diff --git a/public/static/images/footer/logo.png b/public/static/images/footer/logo.png new file mode 100644 index 0000000..9000cdb Binary files /dev/null and b/public/static/images/footer/logo.png differ diff --git a/public/static/images/footer/logo_label_CN.png b/public/static/images/footer/logo_label_CN.png new file mode 100644 index 0000000..15c9594 Binary files /dev/null and b/public/static/images/footer/logo_label_CN.png differ diff --git a/public/static/images/footer/logo_lable_EN.png b/public/static/images/footer/logo_lable_EN.png new file mode 100644 index 0000000..dc5efd3 Binary files /dev/null and b/public/static/images/footer/logo_lable_EN.png differ diff --git a/public/static/images/footer/mark.png b/public/static/images/footer/mark.png new file mode 100644 index 0000000..ad1d018 Binary files /dev/null and b/public/static/images/footer/mark.png differ diff --git a/public/static/images/header/logo.png b/public/static/images/header/logo.png new file mode 100644 index 0000000..ef5a396 Binary files /dev/null and b/public/static/images/header/logo.png differ diff --git a/public/static/images/main/1.png b/public/static/images/main/1.png new file mode 100644 index 0000000..d180a8d Binary files /dev/null and b/public/static/images/main/1.png differ diff --git a/public/static/images/main/10.png b/public/static/images/main/10.png new file mode 100644 index 0000000..f407f45 Binary files /dev/null and b/public/static/images/main/10.png differ diff --git a/public/static/images/main/11.png b/public/static/images/main/11.png new file mode 100644 index 0000000..cdbe2a2 Binary files /dev/null and b/public/static/images/main/11.png differ diff --git a/public/static/images/main/12.png b/public/static/images/main/12.png new file mode 100644 index 0000000..b271967 Binary files /dev/null and b/public/static/images/main/12.png differ diff --git a/public/static/images/main/13.png b/public/static/images/main/13.png new file mode 100644 index 0000000..1e9fd21 Binary files /dev/null and b/public/static/images/main/13.png differ diff --git a/public/static/images/main/14.png b/public/static/images/main/14.png new file mode 100644 index 0000000..dd35d8d Binary files /dev/null and b/public/static/images/main/14.png differ diff --git a/public/static/images/main/15.png b/public/static/images/main/15.png new file mode 100644 index 0000000..31871b7 Binary files /dev/null and b/public/static/images/main/15.png differ diff --git a/public/static/images/main/16.png b/public/static/images/main/16.png new file mode 100644 index 0000000..d11e204 Binary files /dev/null and b/public/static/images/main/16.png differ diff --git a/public/static/images/main/17.png b/public/static/images/main/17.png new file mode 100644 index 0000000..2e9948f Binary files /dev/null and b/public/static/images/main/17.png differ diff --git a/public/static/images/main/18.png b/public/static/images/main/18.png new file mode 100644 index 0000000..96d42b3 Binary files /dev/null and b/public/static/images/main/18.png differ diff --git a/public/static/images/main/19.png b/public/static/images/main/19.png new file mode 100644 index 0000000..cbbff26 Binary files /dev/null and b/public/static/images/main/19.png differ diff --git a/public/static/images/main/2.png b/public/static/images/main/2.png new file mode 100644 index 0000000..9e18de4 Binary files /dev/null and b/public/static/images/main/2.png differ diff --git a/public/static/images/main/20.png b/public/static/images/main/20.png new file mode 100644 index 0000000..b43db8f Binary files /dev/null and b/public/static/images/main/20.png differ diff --git a/public/static/images/main/21.png b/public/static/images/main/21.png new file mode 100644 index 0000000..b43db8f Binary files /dev/null and b/public/static/images/main/21.png differ diff --git a/public/static/images/main/3.png b/public/static/images/main/3.png new file mode 100644 index 0000000..a2b4da9 Binary files /dev/null and b/public/static/images/main/3.png differ diff --git a/public/static/images/main/4.png b/public/static/images/main/4.png new file mode 100644 index 0000000..861d9ee Binary files /dev/null and b/public/static/images/main/4.png differ diff --git a/public/static/images/main/5.png b/public/static/images/main/5.png new file mode 100644 index 0000000..eb84cfa Binary files /dev/null and b/public/static/images/main/5.png differ diff --git a/public/static/images/main/6.png b/public/static/images/main/6.png new file mode 100644 index 0000000..649307f Binary files /dev/null and b/public/static/images/main/6.png differ diff --git a/public/static/images/main/7.png b/public/static/images/main/7.png new file mode 100644 index 0000000..e952c71 Binary files /dev/null and b/public/static/images/main/7.png differ diff --git a/public/static/images/main/8.png b/public/static/images/main/8.png new file mode 100644 index 0000000..d5415ae Binary files /dev/null and b/public/static/images/main/8.png differ diff --git a/public/static/images/main/9.png b/public/static/images/main/9.png new file mode 100644 index 0000000..2d83fc4 Binary files /dev/null and b/public/static/images/main/9.png differ diff --git a/public/static/images/main/banner.png b/public/static/images/main/banner.png new file mode 100644 index 0000000..eceacf5 Binary files /dev/null and b/public/static/images/main/banner.png differ diff --git a/src/api/device.js b/src/api/device.js new file mode 100644 index 0000000..4635dd9 --- /dev/null +++ b/src/api/device.js @@ -0,0 +1,19 @@ +import request from '@/utils/request' + +// 设备设置 +export function deviceSet(data) { + return request({ + url: '/rangu/rid/setting', + method: 'post', + data, + }) +} + +// 设备设置 +export function deviceGet(params) { + return request({ + url: '/rangu/rid/getting', + method: 'get', + params, + }) +} diff --git a/src/assets/font/HanYiDaHeiJian.ttf b/src/assets/font/HanYiDaHeiJian.ttf new file mode 100644 index 0000000..cdb7fa5 Binary files /dev/null and b/src/assets/font/HanYiDaHeiJian.ttf differ diff --git a/src/assets/font/HanYiZhongHeiJian.ttf b/src/assets/font/HanYiZhongHeiJian.ttf new file mode 100644 index 0000000..bb680b6 Binary files /dev/null and b/src/assets/font/HanYiZhongHeiJian.ttf differ diff --git a/src/assets/font/PingFang SC.ttf b/src/assets/font/PingFang SC.ttf new file mode 100644 index 0000000..69c6cd6 Binary files /dev/null and b/src/assets/font/PingFang SC.ttf differ diff --git a/src/assets/styles/font.scss b/src/assets/styles/font.scss new file mode 100644 index 0000000..9d0538a --- /dev/null +++ b/src/assets/styles/font.scss @@ -0,0 +1,14 @@ +@font-face { + font-family: 'PingFang SC'; + src: url('../font/PingFang SC.ttf'); +} + +@font-face { + font-family: 'HYDaHeiJ'; + src: url('../font/HanYiDaHeiJian.ttf'); +} + +@font-face { + font-family: 'HYZhongHeiJ'; + src: url('../font/HanYiZhongHeiJian.ttf'); +} diff --git a/src/assets/styles/index.scss b/src/assets/styles/index.scss new file mode 100644 index 0000000..d55882d --- /dev/null +++ b/src/assets/styles/index.scss @@ -0,0 +1,49 @@ +@use './variable.scss'; +@use './font.scss'; + +* { + margin: 0; + padding: 0; + list-style: none; + user-select: none; + text-decoration: none; + box-sizing: border-box; +} +body { + width: 100%; + height: 100%; + overflow-y: auto; +} + +.placeholder { + width: 100%; + height: 600px; + background-color: #d9d9d9; + font-size: 40px; +} +.page { + width: 100%; + height: 100%; + box-sizing: border-box; +} +.flex { + display: flex; +} +.j-s { + justify-content: space-between; +} +.j-a { + justify-content: space-around; +} +.j-c { + justify-content: center; +} +.a-c { + align-items: center; +} +.column { + flex-direction: column; +} +.wrap { + flex-wrap: wrap; +} diff --git a/src/assets/styles/variable.scss b/src/assets/styles/variable.scss new file mode 100644 index 0000000..fefac9b --- /dev/null +++ b/src/assets/styles/variable.scss @@ -0,0 +1,7 @@ +//项目提供scss全局变量 +$bg_color: #081314; + +$white: #ffffff; +$black: #000000; + +$border: 2px solid red; diff --git a/src/components/icon/svgIcon.vue b/src/components/icon/svgIcon.vue new file mode 100644 index 0000000..2ef1c25 --- /dev/null +++ b/src/components/icon/svgIcon.vue @@ -0,0 +1,32 @@ + + + + + + + diff --git a/src/components/swiper/index.vue b/src/components/swiper/index.vue new file mode 100644 index 0000000..359d550 --- /dev/null +++ b/src/components/swiper/index.vue @@ -0,0 +1,342 @@ + + + + + diff --git a/src/home.vue b/src/home.vue new file mode 100644 index 0000000..8398af0 --- /dev/null +++ b/src/home.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..29fe628 --- /dev/null +++ b/src/main.js @@ -0,0 +1,43 @@ +import {createApp} from 'vue' +import App from './home.vue' +import router from './router/index' +import ElementPlus from 'element-plus' +import zhCn from 'element-plus/es/locale/lang/zh-cn' +import mitt from 'mitt' +import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' + +import {createPinia} from 'pinia' +const pinia = createPinia() +pinia.use(piniaPluginPersistedstate) + +// ====================== 样式 ====================== +import 'element-plus/dist/index.css' +import '@/assets/styles/index.scss' + +// ====================== 工具和组件 ====================== +import {initRem, fontSize} from '@/utils/rem' +import IconSvg from '_c/icon/svgIcon.vue' + +// SVG图标注册 +import 'virtual:svg-icons-register' + +// 初始化rem适配 +initRem() + +// 创建事件总线 +const bus = mitt() + +// 创建应用实例 +const app = createApp(App) + +// 全局属性注册 +app.config.globalProperties.$fontSize = fontSize +app.config.globalProperties.$bus = bus + +// 全局组件注册 +app.component('icon-svg', IconSvg) +// 插件使用 +app.use(router).use(pinia).use(ElementPlus, {locale: zhCn}) + +// 挂载应用 +app.mount('#app') diff --git a/src/router/index.js b/src/router/index.js new file mode 100644 index 0000000..4680d77 --- /dev/null +++ b/src/router/index.js @@ -0,0 +1,71 @@ +import {createWebHashHistory, createRouter} from 'vue-router' + +import HomeView from '@/views/homepage/index.vue' + +const routes = [ + {path: '/', component: HomeView}, + { + path: '/product', + component: () => import('@/views/product/index.vue'), + meta: { + title: '产品中心', + }, + }, + { + path: '/services', + component: () => import('@/views/services/index.vue'), + meta: { + title: '服务与支撑', + }, + }, + { + path: '/news', + component: () => import('@/views/news/index.vue'), + meta: { + title: '新闻中心', + }, + }, + { + path: '/news/detail', + name: 'Detail', + component: () => import('@/views/news/detail.vue'), + }, + { + path: '/about', + component: () => import('@/views/about/index.vue'), + meta: { + title: '关于我们', + }, + }, + + { + path: '/link', + component: () => import('@/views/link/index.vue'), + meta: { + title: '联系我们', + }, + }, + { + path: '/download', + component: () => import('@/views/download/index.vue'), + meta: { + title: '下载中心', + }, + }, +] + +const router = createRouter({ + history: createWebHashHistory(), + routes, +}) + +router.afterEach((to, from) => { + // 只有路径变化时才滚动到顶部 + if (to.path !== from.path) { + requestAnimationFrame(() => { + window.scrollTo({top: 0, behavior: 'instant'}) + }) + } +}) + +export default router diff --git a/src/store/nav.js b/src/store/nav.js new file mode 100644 index 0000000..f9f901c --- /dev/null +++ b/src/store/nav.js @@ -0,0 +1,26 @@ +import {defineStore} from 'pinia' +import {ref} from 'vue' + +export const useNavStore = defineStore( + 'nav', + () => { + const navIndex = ref('/') + + const changeNavIndex = (id) => { + if (!id) { + return + } else { + navIndex.value = id + console.log(localStorage.getItem('nav')) + } + } + + return { + navIndex, + changeNavIndex, + } + }, + { + persist: true, + } +) diff --git a/src/utils/auth.js b/src/utils/auth.js new file mode 100644 index 0000000..f51f6b1 --- /dev/null +++ b/src/utils/auth.js @@ -0,0 +1,152 @@ +import Cookies from 'js-cookie' + +const SystemType = 'protal' + +// Cookie键名常量 +const COOKIE_KEYS = { + TOKEN: `${SystemType}-Server-Token`, + USER_TENANT_INFO: `${SystemType}-User-TenantInfo`, + USER_ID: `${SystemType}-UserId`, + LOGIN_TOKEN: `${SystemType}-Login-Token`, + USERNAME: `${SystemType}-Username`, + PASSWORD: `${SystemType}-Password`, + REMEMBER_ME: `${SystemType}-RememberMe`, +} + +// 默认Cookie选项 +const DEFAULT_COOKIE_OPTIONS = { + expires: 30, // 30天过期 +} + +// 请求接口token +export function getToken() { + return Cookies.get(COOKIE_KEYS.TOKEN) +} + +export function setToken(token) { + return Cookies.set(COOKIE_KEYS.TOKEN, token) +} + +export function removeToken() { + return Cookies.remove(COOKIE_KEYS.TOKEN) +} + +// 用户扩展数据 +export function getUserTenantInfo() { + return Cookies.get(COOKIE_KEYS.USER_TENANT_INFO) +} + +export function setUserTenantInfo(tenantInfo) { + return Cookies.set(COOKIE_KEYS.USER_TENANT_INFO, tenantInfo) +} + +export function removeUserTenantInfo() { + return Cookies.remove(COOKIE_KEYS.USER_TENANT_INFO) +} + +// userId缓存 +export function setUserId(userId) { + return Cookies.set(COOKIE_KEYS.USER_ID, userId) +} + +export function removeUserId() { + return Cookies.remove(COOKIE_KEYS.USER_ID) +} + +// 登陆token缓存 +export function getLoginToken() { + return Cookies.get(COOKIE_KEYS.LOGIN_TOKEN) +} + +export function setLoginToken(token) { + return Cookies.set(COOKIE_KEYS.LOGIN_TOKEN, token) +} + +export function removeLoginToken() { + return Cookies.remove(COOKIE_KEYS.LOGIN_TOKEN) +} + +// 用户账号密码缓存 +export function getUsernameToken() { + return Cookies.get(COOKIE_KEYS.USERNAME) +} + +export function setUsernameToken(token) { + return Cookies.set(COOKIE_KEYS.USERNAME, token, DEFAULT_COOKIE_OPTIONS) +} + +export function removeUsernameToken() { + return Cookies.remove(COOKIE_KEYS.USERNAME) +} + +export function getPasswordToken() { + return Cookies.get(COOKIE_KEYS.PASSWORD) +} + +export function setPasswordToken(token) { + return Cookies.set(COOKIE_KEYS.PASSWORD, token, DEFAULT_COOKIE_OPTIONS) +} + +export function removePasswordToken() { + return Cookies.remove(COOKIE_KEYS.PASSWORD) +} + +export function getRememberMeToken() { + return Cookies.get(COOKIE_KEYS.REMEMBER_ME) +} + +export function setRememberMeToken(token) { + return Cookies.set(COOKIE_KEYS.REMEMBER_ME, token, DEFAULT_COOKIE_OPTIONS) +} + +export function removeRememberMeToken() { + return Cookies.remove(COOKIE_KEYS.REMEMBER_ME) +} + +// 清空所有用户相关缓存 +export function clearAllUserData() { + removeToken() + removeUserTenantInfo() + removeUserId() + removeLoginToken() + removeUsernameToken() + removePasswordToken() + removeRememberMeToken() +} + +// 获取所有用户信息 +export function getAllUserInfo() { + return { + token: getToken(), + userTenantInfo: getUserTenantInfo(), + userId: Cookies.get(COOKIE_KEYS.USER_ID), + loginToken: getLoginToken(), + username: getUsernameToken(), + rememberMe: getRememberMeToken(), + } +} + +export default { + getToken, + setToken, + removeToken, + getUserTenantInfo, + setUserTenantInfo, + removeUserTenantInfo, + setUserId, + removeUserId, + getLoginToken, + setLoginToken, + removeLoginToken, + getUsernameToken, + setUsernameToken, + removeUsernameToken, + getPasswordToken, + setPasswordToken, + removePasswordToken, + getRememberMeToken, + setRememberMeToken, + removeRememberMeToken, + clearAllUserData, + getAllUserInfo, +} diff --git a/src/utils/index.js b/src/utils/index.js new file mode 100644 index 0000000..3eada4b --- /dev/null +++ b/src/utils/index.js @@ -0,0 +1,36 @@ +/** + * 根据屏幕宽度自适应计算字体大小(基于1920设计稿) + * @param {number} res - 设计稿上的原始尺寸 + * @returns {number} 自适应后的尺寸 + */ +export function fontSize(res) { + let clientWidth = + window.innerWidth || + document.documentElement.clientWidth || + document.body.clientWidth + if (!clientWidth) return + let fontSize = clientWidth / 1920 + return res * fontSize +} + +/** + * 生成随机背景色 + * @param {String} type 'hex' | 'rgb' 输出格式,默认 hex + * @returns {String} '#RRGGBB' 或 'rgb(r,g,b)' + * @example randomBgColor() + */ +export function randomBgColor(type = 'hex') { + if (type === 'rgb') { + const r = Math.floor(Math.random() * 256) + const g = Math.floor(Math.random() * 256) + const b = Math.floor(Math.random() * 256) + return `rgb(${r},${g},${b})` + } + // 默认 hex + return ( + '#' + + Math.floor(Math.random() * 0xffffff) + .toString(16) + .padStart(6, '0') + ) +} diff --git a/src/utils/rem.js b/src/utils/rem.js new file mode 100644 index 0000000..dd074aa --- /dev/null +++ b/src/utils/rem.js @@ -0,0 +1,42 @@ +// rem等比适配配置 +// 基准大小 +const baseSize = 16 +// 设计稿宽度 +const designWidth = 1920 +// 最大缩放比例 +const maxScale = 2 + +// 设置 rem 函数 +function setRem() { + // 当前页面宽度相对于设计稿宽度的缩放比例 + const scale = document.documentElement.clientWidth / designWidth + // 设置页面根节点字体大小(最高放大比例为maxScale) + document.documentElement.style.fontSize = + baseSize * Math.min(scale, maxScale) + 'px' +} + +// 根据设计稿尺寸计算实际尺寸 +export function fontSize(res) { + const clientWidth = + window.innerWidth || + document.documentElement.clientWidth || + document.body.clientWidth + if (!clientWidth) return res + const scale = clientWidth / designWidth + return res * Math.min(scale, maxScale) +} + +// 初始化rem配置 +export function initRem() { + setRem() + // 改变窗口大小时重新设置 rem + window.addEventListener('resize', setRem) +} + +// 移除rem监听(可选,用于清理) +export function removeRemListener() { + window.removeEventListener('resize', setRem) +} + +// 自动初始化(如果需要在导入时自动初始化) +// initRem() diff --git a/src/utils/request.js b/src/utils/request.js new file mode 100644 index 0000000..630276b --- /dev/null +++ b/src/utils/request.js @@ -0,0 +1,134 @@ +/** + * axios 封装 + */ +import axios from 'axios' +import {ElMessage, ElMessageBox} from 'element-plus' +import {tansParams} from '@/utils/index' +import {getToken, removeToken, removeUserTenantInfo} from '@/utils/auth' + +// 配置基础URL +const baseURL = window.config?.baseUrl || 'http://work.rangutech.cn:9131' + +// 设置默认请求头 +axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' + +// 创建axios实例 +const service = axios.create({ + baseURL, + timeout: 10000, // 添加合理的超时时间 +}) + +// 请求拦截器 +service.interceptors.request.use( + (config) => { + // 是否需要设置 token + const isToken = (config.headers || {}).isToken === false + + // 添加token到请求头 + if (getToken() && !isToken) { + config.headers.Authorization = `Bearer ${getToken()}` + } + + // GET请求参数处理 + if (config.method?.toLowerCase() === 'get' && config.params) { + const urlParams = tansParams(config.params) + config.url = `${config.url}?${urlParams}` + config.params = {} + } + + return config + }, + (error) => { + console.error('Request error:', error) + return Promise.reject(error) + } +) + +// 响应拦截器 +service.interceptors.response.use( + (response) => { + const {data, config} = response + + // 处理二进制数据响应 + if ( + config.responseType === 'blob' || + config.responseType === 'arraybuffer' + ) { + return data + } + + // 正常响应处理 + if (response.status === 200) { + return data + } + + // 异常响应处理 + return Promise.reject(response) + }, + (error) => { + const {config, response, message} = error + + console.error('Response error:', {config, response, message}) + + // 处理认证错误 + if (response && [401, 471, 472].includes(response.status)) { + handleAuthError(config, response) + return Promise.reject(error) + } + + // 处理网络错误 + handleNetworkError(message) + + return Promise.reject(error) + } +) + +/** + * 处理认证错误 + */ +function handleAuthError(config, response) { + const excludeUrls = ['/Token/Logout', '/Token/Access'] + + if (!excludeUrls.includes(config.url)) { + ElMessageBox.confirm( + '登录状态已过期,您可以继续留在该页面,或者重新登录', + '系统提示', + { + confirmButtonText: '重新登录', + cancelButtonText: '取消', + type: 'warning', + } + ) + .then(() => { + removeToken() + removeUserTenantInfo() + // 这里需要导入store + // store.dispatch('LogOut').then(() => {}); + window.location.reload() // 简单重载页面 + }) + .catch(() => { + // 用户取消操作 + }) + } +} + +/** + * 处理网络错误 + */ +function handleNetworkError(message) { + let errorMsg = message + + if (message === 'Network Error') { + errorMsg = '网络连接异常,请检查网络设置' + } else if (message.includes('timeout')) { + errorMsg = '请求超时,请稍后重试' + } + + ElMessage({ + message: errorMsg, + type: 'error', + duration: 5 * 1000, + }) +} + +export default service diff --git a/src/views/about/index.vue b/src/views/about/index.vue new file mode 100644 index 0000000..cd8aaa2 --- /dev/null +++ b/src/views/about/index.vue @@ -0,0 +1,150 @@ + + + + + diff --git a/src/views/download/index.vue b/src/views/download/index.vue new file mode 100644 index 0000000..28f9024 --- /dev/null +++ b/src/views/download/index.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/src/views/homepage/index.vue b/src/views/homepage/index.vue new file mode 100644 index 0000000..f0b050e --- /dev/null +++ b/src/views/homepage/index.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/src/views/layout/pc/footer/components/QRCode.vue b/src/views/layout/pc/footer/components/QRCode.vue new file mode 100644 index 0000000..927c30c --- /dev/null +++ b/src/views/layout/pc/footer/components/QRCode.vue @@ -0,0 +1,33 @@ + + + + + diff --git a/src/views/layout/pc/footer/components/logo.vue b/src/views/layout/pc/footer/components/logo.vue new file mode 100644 index 0000000..9a6d129 --- /dev/null +++ b/src/views/layout/pc/footer/components/logo.vue @@ -0,0 +1,40 @@ + + + + + diff --git a/src/views/layout/pc/footer/components/nav.vue b/src/views/layout/pc/footer/components/nav.vue new file mode 100644 index 0000000..28becbe --- /dev/null +++ b/src/views/layout/pc/footer/components/nav.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/src/views/layout/pc/footer/components/navNode.vue b/src/views/layout/pc/footer/components/navNode.vue new file mode 100644 index 0000000..9006bb8 --- /dev/null +++ b/src/views/layout/pc/footer/components/navNode.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/src/views/layout/pc/footer/index.vue b/src/views/layout/pc/footer/index.vue new file mode 100644 index 0000000..464c1a9 --- /dev/null +++ b/src/views/layout/pc/footer/index.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/src/views/layout/pc/header/index.vue b/src/views/layout/pc/header/index.vue new file mode 100644 index 0000000..f666a40 --- /dev/null +++ b/src/views/layout/pc/header/index.vue @@ -0,0 +1,35 @@ + + + + + diff --git a/src/views/layout/pc/header/nav.vue b/src/views/layout/pc/header/nav.vue new file mode 100644 index 0000000..88d509c --- /dev/null +++ b/src/views/layout/pc/header/nav.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/src/views/link/index.vue b/src/views/link/index.vue new file mode 100644 index 0000000..475523c --- /dev/null +++ b/src/views/link/index.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/views/link/map.vue b/src/views/link/map.vue new file mode 100644 index 0000000..3e7d64f --- /dev/null +++ b/src/views/link/map.vue @@ -0,0 +1,63 @@ + + + diff --git a/src/views/news/detail.vue b/src/views/news/detail.vue new file mode 100644 index 0000000..70a7c16 --- /dev/null +++ b/src/views/news/detail.vue @@ -0,0 +1,23 @@ + + + + + diff --git a/src/views/news/index.vue b/src/views/news/index.vue new file mode 100644 index 0000000..0fee65e --- /dev/null +++ b/src/views/news/index.vue @@ -0,0 +1,159 @@ + + + + + diff --git a/src/views/product/index.vue b/src/views/product/index.vue new file mode 100644 index 0000000..d08a665 --- /dev/null +++ b/src/views/product/index.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/src/views/services/index.vue b/src/views/services/index.vue new file mode 100644 index 0000000..abc1c9c --- /dev/null +++ b/src/views/services/index.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..b7706d7 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,59 @@ +import {defineConfig} from 'vite' +import vue from '@vitejs/plugin-vue' +// 导入 path +import path from 'path' +// pxToRem +import postCssPxToRem from 'postcss-pxtorem' +// svg +import {createSvgIconsPlugin} from 'vite-plugin-svg-icons' + +export default defineConfig({ + base: './', + build: { + outDir: 'protal_dist', + // 打包时使用 terser 压缩代码 + // minify: 'terser', + // 是否生成源映射文件,方便调试生产环境代码 + sourcemap: 'inline', + }, + plugins: [ + vue(), + createSvgIconsPlugin({ + // 指定 SVG 图标目录(绝对路径) + iconDirs: [path.resolve(process.cwd(), 'src/assets/icons/svg')], + // 指定 symbolId 格式 + symbolId: 'icon-[dir]-[name]', + // 自定义插入位置(可选) + inject: 'body-last', + }), + ], + resolve: { + // 配置别名 + alias: { + '@': path.resolve(__dirname, './src'), + _c: path.resolve(__dirname, './src/components'), + }, + // 省略扩展名导入 + extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'], + }, + css: { + // scss 全局变量的配置 + preprocessorOptions: { + scss: { + additionalData: `@use "@/assets/styles/variable.scss" as *;`, + api: 'modern-compiler', + silenceDeprecations: ['legacy-js-api'], + }, + }, + // pxToRem + postcss: { + plugins: [ + postCssPxToRem({ + // 1rem = 16px + rootValue: 16, + propList: ['*'], // 如果想要某些不适用rem,使用!名字即可 + }), + ], + }, + }, +})