diff --git a/.env.development b/.env.development index ec76dea..368e979 100644 --- a/.env.development +++ b/.env.development @@ -1,7 +1,6 @@ # 页面标题 VITE_APP_TITLE='智净云 · 智能家居管理后台' -VITE_APP_LOGO_TITLE=RuoYi-Vue-Plus - +VITE_APP_LOGO_TITLE=虫子智家设备 # 开发环境配置 VITE_APP_ENV='development' diff --git a/.env.production b/.env.production index e27eaa4..ee82d24 100644 --- a/.env.production +++ b/.env.production @@ -1,13 +1,13 @@ # 页面标题 -VITE_APP_TITLE=RuoYi-Vue-Plus后台管理系统 -VITE_APP_LOGO_TITLE=RuoYi-Vue-Plus - +VITE_APP_TITLE='智净云 · 智能家居管理后台' +VITE_APP_LOGO_TITLE=虫子智家设备 # 生产环境配置 VITE_APP_ENV='production' # 应用访问路径 例如使用前缀 /admin/ VITE_APP_CONTEXT_PATH='/' - +VITE_BASE_API='smart.bugtc.com' +VITE_WS_URL='smart.bugtc.com/cs/chat' # 监控地址 VITE_APP_MONITOR_ADMIN='/admin/applications' diff --git a/package.json b/package.json index 962650c..a2a71cc 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "fmt": "oxfmt .", "lint": "oxlint src", "lint:fix": "oxlint --fix src", - "preview": "vite preview" + "preview": "vite preview --mode production" }, "dependencies": { "@element-plus/icons-vue": "2.3.2", diff --git a/public/favicon.ico b/public/favicon.ico index 3f919d8..2a24644 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/src/assets/logo/logo.png b/src/assets/logo/logo.png index 3f919d8..e4ab7f0 100644 Binary files a/src/assets/logo/logo.png and b/src/assets/logo/logo.png differ diff --git a/src/store/modules/csSession.ts b/src/store/modules/csSession.ts index 0d8c84e..09a3e54 100644 --- a/src/store/modules/csSession.ts +++ b/src/store/modules/csSession.ts @@ -3,7 +3,8 @@ import {reactive, ref} from 'vue'; import {WSClient} from '@/utils/webSocket'; import {getToken} from '@/utils/auth'; import {deskSessionType} from "@/api/system/csSession/type"; -import {csAgentDesk} from "@/api/system/csSession"; +import {csAgentDesk} from "@/api/system/csSession" + /** 最大消息数 */ export const MAX_MESSAGES = 30; @@ -213,8 +214,7 @@ export const useCsSessionStore = defineStore('csSession', () => { function ensureWs(): WSClient { if (ws) return ws; const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://'; - const wsPath = '/cs/chat'; - const wsUrl = `${protocol}192.168.0.212:8082${wsPath}?token=${getToken()}`; + const wsUrl = `${protocol}${import.meta.env.VITE_WS_URL}?token=${getToken()}`; ws = new WSClient({ url: wsUrl, heartbeatInterval: 15_000, diff --git a/src/types/env.d.ts b/src/types/env.d.ts index 1adcff5..4d7f9a5 100644 --- a/src/types/env.d.ts +++ b/src/types/env.d.ts @@ -1,3 +1,15 @@ +import type {Directive} from 'vue' + +export {} +// 👉 扩展 Vue 内置全局指令类型 +declare module 'vue' { + export interface GlobalDirectives { + // 注意:必须带 v 前缀,和模板里一模一样 + vHasPermi: Directive + vHasPermiAnd: Directive + } +} + declare module '*.vue' { import {DefineComponent} from 'vue'; const Component: DefineComponent<{}, {}, any>; diff --git a/src/utils/request.ts b/src/utils/request.ts index a0597c6..cd91f12 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -97,10 +97,14 @@ export const globalHeaders = () => { axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'; axios.defaults.headers['clientid'] = sessionStorage.getItem('clientid') || import.meta.env.VITE_APP_CLIENT_ID; - +let baseURL = import.meta.env.VITE_BASE_API +const protocol = window.location.protocol === 'https:' ? 'https://' : 'http://'; +if (import.meta.env.VITE_APP_ENV === 'production') { + baseURL = protocol + baseURL +} // 创建 axios 实例 const service = axios.create({ - baseURL: import.meta.env.VITE_APP_BASE_API, + baseURL: baseURL, timeout: 50000, transitional: { // 超时错误更明确 diff --git a/src/views/login.vue b/src/views/login.vue index a69399b..c10db35 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -283,13 +283,12 @@ const getLoginData = () => { const handleGetLoc = async () => { try { const loc: GeoResult = await getCurrentPosition(); - console.log("定位", loc.lat, loc.lng, loc.accuracy); fetch( `https://api.waqi.info/feed/geo:${loc.lat};${loc.lng}?token=eb1ad8d6ec4f8103247ee985174ae0d97d1bf4b4`, ) .then((res) => res.json()) .then((res) => { - const weightArr2 = new Array(7).map(() => { + const weightArr2 = Array.from({length: 7}).map(() => { return { avg: Math.random() * 100, day: new Date().toLocaleDateString(), @@ -299,7 +298,13 @@ const handleGetLoc = async () => { quickStats.value = handleMax(weightArr.slice(0, 7)); }); } catch (e) { - console.error((e as Error).message); + const weightArr2 = Array.from({length: 7}).map(() => { + return { + avg: Math.floor(Math.random() * 100), + day: new Date().toLocaleDateString(), + } + }); + quickStats.value = handleMax(weightArr2.slice(0, 7)); } }; diff --git a/src/views/system/customer/edit.vue b/src/views/system/customer/edit.vue index 8d38124..5b402d3 100644 --- a/src/views/system/customer/edit.vue +++ b/src/views/system/customer/edit.vue @@ -6,6 +6,7 @@ import {hiddenPhone} from "@/utils/phone"; import modal from "@/plugins/modal"; import {uploadOss} from "@/api/system/oss"; import {FormInstance, FormRules} from "element-plus"; +import Administrative from "@/data/Administrative.json"; const router = useRouter(); const route = useRoute(); @@ -88,10 +89,8 @@ init() async function handleSave() { - console.log(formRef.value); if (!formRef.value) return formRef.value.validate(async (valid) => { - console.log('校验结果:', valid) if (!valid) { modal.msgWarning('请检查表单必填项'); return @@ -114,6 +113,15 @@ function resetForm() { editForm.value = JSON.parse(JSON.stringify(form.value)) formRef.value?.clearValidate() } + + +const ipaddr = ref([]) + +function handelChangeQuery(code: string[]) { + editForm.value.province = code[0] || undefined + editForm.value.city = code[1] || undefined + editForm.value.district = code[2] || undefined +}