ezhizao_zx 5 tháng trước cách đây
mục cha
commit
aeb9820951
3 tập tin đã thay đổi với 46 bổ sung0 xóa
  1. 12 0
      src/utils/auth.js
  2. 18 0
      src/utils/request.js
  3. 16 0
      src/views/dialog/notification.vue

+ 12 - 0
src/utils/auth.js

@@ -26,3 +26,15 @@ export function setTenant(tenant) {
   const tenantStr = JSON.stringify(tenant)
   return Cookies.set(TenantKey, tenantStr)
 }
+
+/** 已阅读公告缓存 */
+const notificationKey = 'Dms-Notification'
+export function setShowedNotification(id) {
+  const showedNotification = !Cookies.get(notificationKey) ? [] : JSON.parse(Cookies.get(notificationKey))
+  showedNotification.push(id)
+  return Cookies.set(notificationKey, JSON.stringify(showedNotification))
+}
+export function getShowedNotification() {
+  const showedNotification = Cookies.get(notificationKey)
+  return showedNotification ? JSON.parse(showedNotification) : null
+}

+ 18 - 0
src/utils/request.js

@@ -13,6 +13,22 @@ let downloadLoadingInstance
 export let isRelogin = { show: false }
 
 axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
+
+const preService = axios.create({
+  baseURL: import.meta.env.VITE_APP_BASE_API,
+  timeout: 1000,
+  headers: {
+    Authorization: 'Bearer' + getToken(),
+    tenantId: tenantInfo.tenantId,
+    appKey: 'ezhizao-identity'
+  },
+  method: 'get',
+  url: '',
+  data: {},
+  params: {},
+
+})
+
 // 创建axios实例
 const service = axios.create({
   // axios中请求配置有baseURL选项,表示请求URL公共部分
@@ -38,6 +54,8 @@ service.interceptors.request.use(
     }
     // appKey 根据该值,获取菜单,不要修改
     config.headers['appKey'] = 'ezhizao-identity'
+    // 当登录状态为已登录时才可以获取公告
+
     // get请求映射params参数
     if (config.method === 'get' && config.params) {
       let url = config.url + '?' + tansParams(config.params)

+ 16 - 0
src/views/dialog/notification.vue

@@ -0,0 +1,16 @@
+<template>
+  <!-- 公告 -->
+  <el-dialog v-model="visible" :show-close="false" width="500">
+    <template #header>
+      <div class="my-header">
+        <h4>{{ title }}</h4>
+      </div>
+    </template>
+    <div v-html="content"></div>
+  </el-dialog>
+</template>
+<script setup>
+const title = ref('测试公告')
+const content = ref('测试公告内容')
+const visible = ref(false)
+</script>