diff --git a/pages/index.vue b/pages/index.vue
index 3ca77e4..af8e907 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -1,6 +1,9 @@
-
+
+
+
+
@@ -107,6 +110,7 @@ const reload = async () => {
const getSlide = useServerRequest>('/cms/ad/side');
const getLink = useServerRequest>('/oa/link?linkType=友情链接');
const [{data: slide}, {data: link}] = await Promise.all([getSlide, getLink]);
+ console.log(slide.value)
banner.value = slide.value?.data;
links.value = link.value?.data;
}
diff --git a/pages/test.vue b/pages/test.vue
new file mode 100644
index 0000000..3c8abce
--- /dev/null
+++ b/pages/test.vue
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+ Dropdown List
+
+
+
+
+
+
+ Action 1
+ Action 2
+ Action 3
+ Action 4
+ Action 5
+
+
+
+
+
Tag 1
+
+
+
+
diff --git a/types/config.ts b/types/config.ts
new file mode 100644
index 0000000..80f3308
--- /dev/null
+++ b/types/config.ts
@@ -0,0 +1,12 @@
+export interface Config {
+ tel1?: string;
+ icpNo?: string;
+ tel2?: string;
+ copyright?: string;
+ qrcode?: string;
+ domain?: string;
+ siteName?: string;
+ siteLogo?: string;
+ subpageBanner?: string;
+ bottomBg?: string;
+}
diff --git a/utils/common.ts b/utils/common.ts
new file mode 100644
index 0000000..be4c9ba
--- /dev/null
+++ b/utils/common.ts
@@ -0,0 +1,52 @@
+/**需要进行持久化的数据:把需要持久化的数据放在下面这个对象中,才会持久化,不需要持久化的数据就不用放到这里了。 */
+const enduring: { [key: string]: () => Ref } = {
+ useToken, useConfigInfo
+}
+
+//下面的俩函数在app.vue的onMounted中统一调用,或者在其它情况挂载后单独调用。
+/**把所有指定数据保存到本地存储
+ * @param key 要保存的数据名。不填的话就是保存全部(一般不填,统一在页面关闭时保存。如果是特别重要的数据,就时不时单独保存一下即可。)
+ */
+export const setLocal = (key?: string) => {
+ if (key) {
+ console.log('只保存', key);
+ const useKey = 'use' + key.slice(0, 1).toUpperCase() + key.slice(1).toLowerCase(); //首字母大写,其它全部转小写
+ const func = enduring[useKey];
+ if (!func) {
+ console.log('没有找到', useKey, '对应的函数');
+ return;
+ }
+ localStorage.setItem(key, JSON.stringify(func().value));
+ } else {
+ console.log('正在保存全部数据');
+ for (const key in enduring) {
+ if (Object.prototype.hasOwnProperty.call(enduring, key)) {
+ const element = enduring[key];
+ const setKey = key.toLowerCase().substring(3); //去掉前面的use ,其它全部转小写
+ try {
+ localStorage.setItem(setKey, JSON.stringify(element().value));
+ } catch (error) {
+ console.log(`在设置${setKey}的数据时出现错误`, error);
+ }
+ }
+ }
+ }
+};
+/**从本地存储获取数据到state中 */
+export const getLoacl = () => {
+ for (const key in enduring) {
+ if (Object.prototype.hasOwnProperty.call(enduring, key)) {
+ const element = enduring[key];
+ const setKey = key.toLowerCase().substring(3); //去掉前面的use ,其它全部转小写
+ try {
+ const localData = localStorage.getItem(setKey) || '';
+ if (localData) {
+ element().value = JSON.parse(localData);
+ console.log(setKey, '的本地存储数据获取成功', element().value);
+ }
+ } catch (error) {
+ console.log(`在获取${setKey}的数据时出现错误`, error);
+ }
+ }
+ }
+};
diff --git a/utils/request.ts b/utils/request.ts
new file mode 100644
index 0000000..59bca99
--- /dev/null
+++ b/utils/request.ts
@@ -0,0 +1,88 @@
+/**
+ * axios 实例
+ */
+import axios from 'axios';
+import type { AxiosResponse } from 'axios';
+import {API_BASE_URL, TOKEN_HEADER_NAME, LAYOUT_PATH, TOKEN_STORE_NAME} from '@/config';
+import type { ApiResult } from '@/api';
+import { getHostname, getTenantId } from '@/utils/domain';
+
+const service = axios.create({
+ baseURL: API_BASE_URL
+});
+
+/**
+ * 添加请求拦截器
+ */
+service.interceptors.request.use(
+ (config) => {
+ const TENANT_ID = localStorage.getItem('TenantId') || 5;
+ const token = localStorage.getItem(TOKEN_STORE_NAME);
+ // 添加 token 到 header
+ if (token && config.headers) {
+ config.headers.common[TOKEN_HEADER_NAME] = token;
+ }
+ // 获取租户ID
+ if (config.headers) {
+ // 附加企业ID
+ const companyId = localStorage.getItem('CompanyId');
+ if (companyId) {
+ config.headers.common['CompanyId'] = companyId;
+ }
+ // 通过网站域名获取租户ID
+ if (getHostname()) {
+ config.headers.common['Domain'] = getHostname();
+ }
+ // 解析二级域名获取租户ID
+ if (getTenantId()) {
+ config.headers.common['TenantId'] = getTenantId();
+ return config;
+ }
+ if (TENANT_ID) {
+ config.headers.common['TenantId'] = TENANT_ID;
+ return config;
+ }
+ }
+ return config;
+ },
+ (error) => {
+ return Promise.reject(error);
+ }
+);
+
+/**
+ * 添加响应拦截器
+ */
+service.interceptors.response.use(
+ (res: AxiosResponse>) => {
+ // 登录过期处理
+ if (res.data?.code === 401) {
+ // const currentPath = unref(router.currentRoute).path;
+ // if (currentPath == LAYOUT_PATH) {
+ // logout(true);
+ // } else {
+ // Modal.destroyAll();
+ // Modal.info({
+ // title: '系统提示',
+ // content: '登录状态已过期, 请退出重新登录!',
+ // okText: '重新登录',
+ // onOk: () => {
+ // logout(false, currentPath);
+ // }
+ // });
+ // }
+ // return Promise.reject(new Error(res.data.message));
+ }
+ // token 自动续期
+ const token = res.headers[TOKEN_HEADER_NAME.toLowerCase()];
+ if (token) {
+ localStorage.setItem(TOKEN_STORE_NAME, token);
+ }
+ return res;
+ },
+ (error) => {
+ return Promise.reject(error);
+ }
+);
+
+export default service;