inl-ui 0.1.121-mtapi → 0.1.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +49 -49
  2. package/dist/components/index.cjs +34 -36
  3. package/dist/components/index.js +34 -36
  4. package/dist/hooks/index.cjs +2 -2
  5. package/dist/hooks/index.js +2 -2
  6. package/dist/index.cjs +44 -46
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +44 -46
  9. package/dist/theme/index.js +70 -70
  10. package/dist/theme/scripts/dark-vars.js +21 -21
  11. package/dist/theme/scripts/default-vars.js +25 -25
  12. package/dist/theme/scripts/light-vars.js +22 -22
  13. package/dist/theme/style/color/bezierEasing.less +110 -110
  14. package/dist/theme/style/color/colorPalette.less +81 -81
  15. package/dist/theme/style/color/colors.less +162 -162
  16. package/dist/theme/style/color/tinyColor.less +1184 -1184
  17. package/dist/theme/style/compact.less +4 -4
  18. package/dist/theme/style/dark.less +4 -4
  19. package/dist/theme/style/default.less +4 -4
  20. package/dist/theme/style/index.less +2 -2
  21. package/dist/theme/style/index.tsx +2 -2
  22. package/dist/theme/style/themes/compact.less +295 -295
  23. package/dist/theme/style/themes/dark.less +790 -790
  24. package/dist/theme/style/themes/default.less +1067 -1067
  25. package/dist/theme/style/themes/index.less +7 -7
  26. package/dist/theme/style/themes/var-dark.less +343 -343
  27. package/dist/theme/style/themes/var-default.less +184 -184
  28. package/dist/theme/style/themes/variable.less +1122 -1122
  29. package/dist/theme/style/variable.less +4 -4
  30. package/dist/tplib/index.cjs +9 -9
  31. package/dist/tplib/index.js +9 -9
  32. package/dist/utils/index.cjs +2 -2
  33. package/dist/utils/index.js +2 -2
  34. package/dist/video/index.cjs +12 -12
  35. package/dist/video/index.js +12 -12
  36. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { XPopup, CommentBlock, setAxiosOption } from '@sszj-temp/mobile';
13
13
  import { marked } from 'marked';
14
14
  import '@sszj-temp/mobile/style.css';
15
15
 
16
- var version = "0.1.121-mtapi";
16
+ var version = "0.1.121";
17
17
 
18
18
  const setTheme = theme => {
19
19
  if (theme === "dark") {
@@ -215,7 +215,7 @@ const getCommonHeaders = () => {
215
215
  };
216
216
  const defaultConfig = {
217
217
  timeout: 1e3 * 10,
218
- baseURL: "/mtapi/"
218
+ baseURL: "/api/"
219
219
  };
220
220
  class ApiInstance {
221
221
  instance;
@@ -286,7 +286,7 @@ class Login$1 {
286
286
  constructor() {
287
287
  this.getQueryInfo();
288
288
  this.config.axios = new ApiInstance({
289
- baseURL: "/mtapi/common/v1/"
289
+ baseURL: "/api/common/v1/"
290
290
  }).instance;
291
291
  }
292
292
  checkSystemInfo() {
@@ -6610,14 +6610,14 @@ const Endpoint = RTCEndpoint;
6610
6610
 
6611
6611
  const playOneWebRtcMt = async (uuid, domId, dom, token) => {
6612
6612
  let play;
6613
- const response = await fetch(`/mtapi/vms/v1/camera/getByUuid?uuid=${uuid}`, {
6613
+ const response = await fetch(`/api/vms/v1/camera/getByUuid?uuid=${uuid}`, {
6614
6614
  method: "GET",
6615
6615
  headers: {
6616
6616
  token: token || sessionStorage.getItem("token") || ""
6617
6617
  }
6618
6618
  });
6619
6619
  const res = await response.json();
6620
- const urlResponse = await fetch(`/mtapi/vms/v1/camera/getWebrtcUrls?uuid=${uuid}`, {
6620
+ const urlResponse = await fetch(`/api/vms/v1/camera/getWebrtcUrls?uuid=${uuid}`, {
6621
6621
  method: "GET",
6622
6622
  headers: {
6623
6623
  token: token || sessionStorage.getItem("token") || ""
@@ -6929,7 +6929,7 @@ function getAlarmingCamera(config) {
6929
6929
  } catch (error) {}
6930
6930
  let timer = null;
6931
6931
  const getCurrentAlarm = async () => {
6932
- const res = await fetch("/mtapi/alarmlite/v1/record/list", {
6932
+ const res = await fetch("/api/alarmlite/v1/record/list", {
6933
6933
  method: "POST",
6934
6934
  headers,
6935
6935
  body: JSON.stringify({
@@ -6944,7 +6944,7 @@ function getAlarmingCamera(config) {
6944
6944
  return data.records;
6945
6945
  };
6946
6946
  const getCameraList = async (instId, zthingCode, alarmId, alarmName) => {
6947
- const res = await fetch(`/mtapi/thing/v1/adapter/thing/relation/findZInstsByClass/${instId}/DEVICE_CAMERA`, {
6947
+ const res = await fetch(`/api/thing/v1/adapter/thing/relation/findZInstsByClass/${instId}/DEVICE_CAMERA`, {
6948
6948
  method: "GET",
6949
6949
  headers
6950
6950
  });
@@ -6988,7 +6988,7 @@ const findAlarmDeviceById = async (ic, token) => {
6988
6988
  try {
6989
6989
  headers = resetHeader(token);
6990
6990
  } catch (error) {}
6991
- const res = await fetch("/mtapi/thing/v1/adapter/thing/common/findAlarmDevice", {
6991
+ const res = await fetch("/api/thing/v1/adapter/thing/common/findAlarmDevice", {
6992
6992
  method: "POST",
6993
6993
  headers,
6994
6994
  body: JSON.stringify({
@@ -7001,7 +7001,7 @@ const findAlarmDeviceById = async (ic, token) => {
7001
7001
  };
7002
7002
  const getDeviceList = async (param, token) => {
7003
7003
  const headers = resetHeader(token);
7004
- const res = await fetch("/mtapi/thing/v1/metric/data/getDataList", {
7004
+ const res = await fetch("/api/thing/v1/metric/data/getDataList", {
7005
7005
  method: "POST",
7006
7006
  headers,
7007
7007
  body: JSON.stringify(param)
@@ -7024,7 +7024,7 @@ const paramsToString = obj => {
7024
7024
  return arr.join("&");
7025
7025
  };
7026
7026
  const GetDeviceDetailOnce = async (codes, params) => {
7027
- const resPromise = await fetch("/mtapi/mtip/thing/v2/thingInst/findByCodeList?" + paramsToString(params), {
7027
+ const resPromise = await fetch("/api/mtip/thing/v2/thingInst/findByCodeList?" + paramsToString(params), {
7028
7028
  method: "POST",
7029
7029
  headers: resetHeader(params.token),
7030
7030
  body: JSON.stringify(codes)
@@ -7062,7 +7062,7 @@ const RefreshDeviceDetail = async (codes, token) => {
7062
7062
  }
7063
7063
  }
7064
7064
  }
7065
- const resPromise = await fetch("/mtapi/mtip/thing/v2/thingInst/reloadPropertiesValue", {
7065
+ const resPromise = await fetch("/api/mtip/thing/v2/thingInst/reloadPropertiesValue", {
7066
7066
  method: "POST",
7067
7067
  headers: resetHeader(token),
7068
7068
  body: JSON.stringify(pointCodes)
@@ -7182,7 +7182,7 @@ const getCorrelationInts = (data, code) => {
7182
7182
  };
7183
7183
  const findRelationEntitiesPage = async (data, code, params) => {
7184
7184
  const getDeviceState = getCorrelationInts(data, code);
7185
- const res = await fetch("/mtapi/mtip/thing/v2/thingInst/findRelationEntitiesPage?" + paramsToString(params), {
7185
+ const res = await fetch("/api/mtip/thing/v2/thingInst/findRelationEntitiesPage?" + paramsToString(params), {
7186
7186
  headers: resetHeader(params.token),
7187
7187
  method: "POST",
7188
7188
  body: JSON.stringify(getDeviceState)
@@ -7293,7 +7293,7 @@ async function checkIframeUrl(url) {
7293
7293
  const iframeUrl = getIframeUrl(url);
7294
7294
  let code = 200;
7295
7295
  try {
7296
- const res = await fetch(`/mtapi/common/v1/sysconfig/curlForResponseCode?requestMethod=get&url=${encodeURIComponent(iframeUrl)}`, {
7296
+ const res = await fetch(`/api/common/v1/sysconfig/curlForResponseCode?requestMethod=get&url=${encodeURIComponent(iframeUrl)}`, {
7297
7297
  headers: getCommonHeaders()
7298
7298
  });
7299
7299
  if (res.status !== 404) {
@@ -8759,7 +8759,7 @@ var loginBox = defineComponent({
8759
8759
  });
8760
8760
  const isClould = inject("isClould");
8761
8761
  const instance = new ApiInstance({
8762
- baseURL: "/mtapi/common/v1/"
8762
+ baseURL: "/api/common/v1/"
8763
8763
  }).instance;
8764
8764
  const systemTitle = inject("systemTitle");
8765
8765
  const platformLogo = inject("platformLogo");
@@ -9423,26 +9423,26 @@ const isIndependentApp = query => !!query.token && !!query.onlyPage;
9423
9423
  const loginFun = new Login$1();
9424
9424
  const httpUtil = {
9425
9425
  requestLogo: async () => {
9426
- const res = await fetch("/mtapi/common/v1/sysconfig/searchImage?imgType=4&editImg=1&clientType=web");
9426
+ const res = await fetch("/api/common/v1/sysconfig/searchImage?imgType=4&editImg=1&clientType=web");
9427
9427
  const blob = await res.blob();
9428
9428
  return URL.createObjectURL(blob);
9429
9429
  },
9430
9430
  requestUserTree: async () => {
9431
9431
  const headers = getCommonHeaders();
9432
- const res = await fetch("/mtapi/common/v1/menu/tree", {
9432
+ const res = await fetch("/api/common/v1/menu/tree", {
9433
9433
  headers
9434
9434
  });
9435
9435
  const treeData = await res.json();
9436
9436
  return treeData.data;
9437
9437
  },
9438
9438
  requestCopyright: async () => {
9439
- const res = await fetch("/mtapi/common/v1/sysconfig/getSysConfig?clientType=web");
9439
+ const res = await fetch("/api/common/v1/sysconfig/getSysConfig?clientType=web");
9440
9440
  const data = await res.json();
9441
9441
  return data.data.homepageCopyright;
9442
9442
  },
9443
9443
  postLogout: async () => {
9444
9444
  const headers = getCommonHeaders();
9445
- await fetch("/mtapi/common/v1/log/insert", {
9445
+ await fetch("/api/common/v1/log/insert", {
9446
9446
  method: "POST",
9447
9447
  headers: {
9448
9448
  ...headers,
@@ -9693,7 +9693,6 @@ const getDetailContainer = () => defineComponent({
9693
9693
  if (newTab) {
9694
9694
  dataId.value = newTab;
9695
9695
  }
9696
- dataId.value = props.name + dataId.value;
9697
9696
  const tab = {
9698
9697
  name,
9699
9698
  url: route.fullPath,
@@ -9701,10 +9700,9 @@ const getDetailContainer = () => defineComponent({
9701
9700
  uniqueKey: dataId.value,
9702
9701
  icon: props.icon,
9703
9702
  isExtraTab: true,
9704
- params: _.omit(route.query, "name"),
9705
- ogiginId: newRoute.params.id || newRoute.query.id
9703
+ params: _.omit(route.query, "name")
9706
9704
  };
9707
- const detail = detailList.value.find(item => item.uniqueKey === tab.uniqueKey);
9705
+ const detail = detailList.value.find(item => item.key + item.uniqueKey === tab.key + tab.uniqueKey);
9708
9706
  if (detail) {
9709
9707
  detail.url = newRoute.fullPath;
9710
9708
  if (Array.isArray(qiankunState.value.extraTabs)) {
@@ -9733,7 +9731,7 @@ const getDetailContainer = () => defineComponent({
9733
9731
  }
9734
9732
  });
9735
9733
  }
9736
- const activeTabKey = tab.uniqueKey;
9734
+ const activeTabKey = props.name + tab.uniqueKey;
9737
9735
  qiankunState.value = {
9738
9736
  ...(qiankunState.value ?? {}),
9739
9737
  activeTabKey
@@ -9796,7 +9794,7 @@ const getDetailContainer = () => defineComponent({
9796
9794
  }
9797
9795
  }, [createVNode(props.cpn, {
9798
9796
  "key": item.id,
9799
- "id": item.ogiginId,
9797
+ "id": item.id,
9800
9798
  "isActive": isActive.value && isDetailActive,
9801
9799
  "onClose": () => handleClose(item),
9802
9800
  "onRefresh": () => handleRefresh(item)
@@ -10095,7 +10093,7 @@ const VideoBox = defineComponent({
10095
10093
  }]];
10096
10094
  const infos = ref([]);
10097
10095
  const videoMove = async direction => {
10098
- await axios$2.get("/mtapi/vms/v1/control/hik/control", {
10096
+ await axios$2.get("/api/vms/v1/control/hik/control", {
10099
10097
  params: {
10100
10098
  cameraUuid: _prop.camera,
10101
10099
  command: direction
@@ -10110,7 +10108,7 @@ const VideoBox = defineComponent({
10110
10108
  const arr = infos.value.map(info => {
10111
10109
  return {};
10112
10110
  });
10113
- const res = await axios$2.get("/mtapi/vms/v1/camera/getThingDevice", {
10111
+ const res = await axios$2.get("/api/vms/v1/camera/getThingDevice", {
10114
10112
  params: {
10115
10113
  cameraUuid: uuid
10116
10114
  },
@@ -10126,7 +10124,7 @@ const VideoBox = defineComponent({
10126
10124
  };
10127
10125
  const camera = ref({});
10128
10126
  const getVideoDetail = async val => {
10129
- const res = await axios$2.get(`/mtapi/vms/v1/camera/getByUuid?uuid=${val}`, {
10127
+ const res = await axios$2.get(`/api/vms/v1/camera/getByUuid?uuid=${val}`, {
10130
10128
  headers: {
10131
10129
  token: sessionStorage.getItem("token") || ""
10132
10130
  }
@@ -10157,7 +10155,7 @@ const VideoBox = defineComponent({
10157
10155
  immediate: true
10158
10156
  });
10159
10157
  const changeStream = async code => {
10160
- const res = await axios$2.get(`/mtapi/vms/v1/camera/getWebrtcUrls`, {
10158
+ const res = await axios$2.get(`/api/vms/v1/camera/getWebrtcUrls`, {
10161
10159
  headers: {
10162
10160
  token: sessionStorage.getItem("token") || ""
10163
10161
  },
@@ -10380,7 +10378,7 @@ var Tree = defineComponent({
10380
10378
  });
10381
10379
  const getQueryGroup = async params => {
10382
10380
  return new Promise(async resolve => {
10383
- const res = await axios$2.get("/mtapi/vms/v1/cameraGroup/tree", {
10381
+ const res = await axios$2.get("/api/vms/v1/cameraGroup/tree", {
10384
10382
  headers: {
10385
10383
  token: sessionStorage.getItem("token") || ""
10386
10384
  },
@@ -10398,7 +10396,7 @@ var Tree = defineComponent({
10398
10396
  };
10399
10397
  const getGroup = async () => {
10400
10398
  return new Promise(async resolve => {
10401
- const res = await axios$2.get("/mtapi/vms/v1/cameraGroupType/findAll", {
10399
+ const res = await axios$2.get("/api/vms/v1/cameraGroupType/findAll", {
10402
10400
  headers: {
10403
10401
  token: sessionStorage.getItem("token") || ""
10404
10402
  }
@@ -10674,7 +10672,7 @@ const VideoBoxV2 = defineComponent({
10674
10672
  showInfo.value = _prop.showInfo;
10675
10673
  });
10676
10674
  const videoMove = async direction => {
10677
- await axios$2.get("/mtapi/vms/v1/control/hik/control", {
10675
+ await axios$2.get("/api/vms/v1/control/hik/control", {
10678
10676
  params: {
10679
10677
  cameraUuid: _prop.camera,
10680
10678
  command: direction
@@ -10699,7 +10697,7 @@ const VideoBoxV2 = defineComponent({
10699
10697
  if (tcpcArr.length === 0) {
10700
10698
  return;
10701
10699
  }
10702
- const res = await axios$2.post("/mtapi/mtip/thing/v2/thingClient/getPropertiesValueById", tcpcArr, {
10700
+ const res = await axios$2.post("/api/mtip/thing/v2/thingClient/getPropertiesValueById", tcpcArr, {
10703
10701
  headers: {
10704
10702
  token: sessionStorage.getItem("token")
10705
10703
  }
@@ -10720,7 +10718,7 @@ const VideoBoxV2 = defineComponent({
10720
10718
  const arr = infos.value.map(info => {
10721
10719
  return {};
10722
10720
  });
10723
- const res = await axios$2.post("/mtapi/vms/v1/cameraRelThing/getByParam", {
10721
+ const res = await axios$2.post("/api/vms/v1/cameraRelThing/getByParam", {
10724
10722
  cameraUuid: uuid2
10725
10723
  }, {
10726
10724
  headers: {
@@ -10740,7 +10738,7 @@ const VideoBoxV2 = defineComponent({
10740
10738
  };
10741
10739
  const camera = ref({});
10742
10740
  const getVideoDetail = async val => {
10743
- const res = await axios$2.get(`/mtapi/vms/v1/camera/getByUuid?uuid=${val}`, {
10741
+ const res = await axios$2.get(`/api/vms/v1/camera/getByUuid?uuid=${val}`, {
10744
10742
  headers: {
10745
10743
  token: sessionStorage.getItem("token") || ""
10746
10744
  }
@@ -10857,7 +10855,7 @@ const VideoBoxV2 = defineComponent({
10857
10855
  immediate: true
10858
10856
  });
10859
10857
  const changeStream = async code => {
10860
- const res = await axios$2.get(`/mtapi/vms/v1/camera/getWebrtcUrls`, {
10858
+ const res = await axios$2.get(`/api/vms/v1/camera/getWebrtcUrls`, {
10861
10859
  headers: {
10862
10860
  token: sessionStorage.getItem("token") || ""
10863
10861
  },
@@ -11843,7 +11841,7 @@ const VideoPlayerV1 = defineComponent({
11843
11841
  videoInfo2.value = camera;
11844
11842
  init();
11845
11843
  } else if (camera && typeof camera === "string") {
11846
- const res = await axios$2.post(`/mtapi/sfvideo/v1/camera/getCameraByCameraId`, {
11844
+ const res = await axios$2.post(`/api/sfvideo/v1/camera/getCameraByCameraId`, {
11847
11845
  id: camera
11848
11846
  }, {
11849
11847
  headers: {
@@ -12643,7 +12641,7 @@ var index$4 = installComponent(PeopleSelect, "people-select");
12643
12641
 
12644
12642
  const getParamList$1 = async data => {
12645
12643
  const headers = getCommonHeaders();
12646
- const res = await fetch("/mtapi/common/v1/param/group/list", {
12644
+ const res = await fetch("/api/common/v1/param/group/list", {
12647
12645
  method: "POST",
12648
12646
  body: JSON.stringify(data),
12649
12647
  headers
@@ -12652,7 +12650,7 @@ const getParamList$1 = async data => {
12652
12650
  };
12653
12651
  const getParamDefineList$1 = async groupId => {
12654
12652
  const headers = getCommonHeaders();
12655
- const res = await fetch(`/mtapi/common/v1/param/group/getDefineAndValueListByGroupId?groupId=${groupId}`, {
12653
+ const res = await fetch(`/api/common/v1/param/group/getDefineAndValueListByGroupId?groupId=${groupId}`, {
12656
12654
  method: "GET",
12657
12655
  headers
12658
12656
  });
@@ -12660,7 +12658,7 @@ const getParamDefineList$1 = async groupId => {
12660
12658
  };
12661
12659
  const batchSaveParamsValue$1 = async form => {
12662
12660
  const headers = getCommonHeaders();
12663
- const res = await fetch("/mtapi/common/v1/param/value/updateBatch", {
12661
+ const res = await fetch("/api/common/v1/param/value/updateBatch", {
12664
12662
  method: "POST",
12665
12663
  headers,
12666
12664
  body: JSON.stringify(form)
@@ -13452,7 +13450,7 @@ const ParamItem = defineComponent({
13452
13450
 
13453
13451
  const getParamList = async data => {
13454
13452
  const headers = getCommonHeaders();
13455
- const res = await fetch("/mtapi/common/v1/param/group/list", {
13453
+ const res = await fetch("/api/common/v1/param/group/list", {
13456
13454
  method: "POST",
13457
13455
  body: JSON.stringify(data),
13458
13456
  headers
@@ -13461,7 +13459,7 @@ const getParamList = async data => {
13461
13459
  };
13462
13460
  const getParamDefineList = async groupId => {
13463
13461
  const headers = getCommonHeaders();
13464
- const res = await fetch(`/mtapi/common/v1/param/group/getDefineAndValueListByGroupId?groupId=${groupId}`, {
13462
+ const res = await fetch(`/api/common/v1/param/group/getDefineAndValueListByGroupId?groupId=${groupId}`, {
13465
13463
  method: "GET",
13466
13464
  headers
13467
13465
  });
@@ -13469,7 +13467,7 @@ const getParamDefineList = async groupId => {
13469
13467
  };
13470
13468
  const batchSaveParamsValue = async form => {
13471
13469
  const headers = getCommonHeaders();
13472
- const res = await fetch("/mtapi/common/v1/param/value/updateBatch", {
13470
+ const res = await fetch("/api/common/v1/param/value/updateBatch", {
13473
13471
  method: "POST",
13474
13472
  headers,
13475
13473
  body: JSON.stringify(form)
@@ -14124,7 +14122,7 @@ const SszComment = defineComponent({
14124
14122
  // 评论api的前缀
14125
14123
  baseUrl: {
14126
14124
  type: String,
14127
- default: "/mtapi/taskcoordinationcenter/v2/tri/"
14125
+ default: "/api/taskcoordinationcenter/v2/tri/"
14128
14126
  },
14129
14127
  // 传给commentBlock的参数 api: http://192.168.5.46:36000/comment
14130
14128
  commentProps: {
@@ -14236,7 +14234,7 @@ function formatDataString(str) {
14236
14234
  function request(question, streamCallback, doneCallback) {
14237
14235
  const controller = new AbortController();
14238
14236
  const signal = controller.signal;
14239
- fetch("/mtapi/chat/v1/chat/chat", {
14237
+ fetch("/api/chat/v1/chat/chat", {
14240
14238
  signal,
14241
14239
  method: "POST",
14242
14240
  headers: {
@@ -14353,7 +14351,7 @@ async function audioToText(file) {
14353
14351
  const formData = new FormData();
14354
14352
  formData.append("file", file);
14355
14353
  formData.append("upload_id", "1");
14356
- const [path] = await fetch("/mtapi/chat/v1/upload", {
14354
+ const [path] = await fetch("/api/chat/v1/upload", {
14357
14355
  // headers,
14358
14356
  method: "POST",
14359
14357
  body: formData
@@ -14364,7 +14362,7 @@ async function audioToText(file) {
14364
14362
  }
14365
14363
  const {
14366
14364
  result
14367
- } = await fetch(`/mtapi/chat/v1/translate?path=${path}&session_hash=1`, {
14365
+ } = await fetch(`/api/chat/v1/translate?path=${path}&session_hash=1`, {
14368
14366
  headers,
14369
14367
  method: "POST"
14370
14368
  }).then(res => res.json());
@@ -1,70 +1,70 @@
1
- const less = require("less");
2
- const defaultVars = require("./scripts/default-vars");
3
-
4
- const dark = require("./scripts/dark-vars");
5
- const light = require("./scripts/light-vars");
6
-
7
- const path = require("path");
8
- const varDark = path.join(__dirname, ".", "style");
9
- const themeConfig = [
10
- {
11
- theme: "dark",
12
- htmlThemeAttr: "dark",
13
- modifyVars: {
14
- hack: `true;@import "${require.resolve(
15
- varDark + "/color/colorPalette.less"
16
- )}";@import "${require.resolve(varDark + "/themes/var-dark.less")}";`,
17
- ...defaultVars,
18
- ...dark,
19
- "root-entry-name": "dark",
20
- },
21
- },
22
- {
23
- theme: "light",
24
- htmlThemeAttr: "light",
25
- modifyVars: {
26
- // 引入除了变量外的其他内容
27
- hack: `true;@import "${require.resolve(
28
- varDark + "/color/colorPalette.less"
29
- )}";@import "${require.resolve(varDark + "/themes/var-default.less")}";`,
30
- ...defaultVars,
31
- ...light,
32
- "root-entry-name": "default",
33
- },
34
- },
35
- ];
36
- const additionalData = async (content, filename) => {
37
- const themePromises = themeConfig.map(async (t) => {
38
- const { htmlThemeAttr, modifyVars = {} } = t;
39
- const options = {
40
- javascriptEnabled: true,
41
- modifyVars,
42
- relativeUrls: true,
43
- filename,
44
- };
45
- try {
46
- const { css } = await less.render(content, options);
47
- let res = "";
48
- if (htmlThemeAttr && css) {
49
- res = `
50
- [data-doc-theme=${htmlThemeAttr}] {
51
- ${css}
52
- }
53
- `;
54
- }
55
- return Promise.resolve(res);
56
- } catch (error) {
57
- // eslint-disable-next-line no-console
58
- console.log(error);
59
- return Promise.reject(content);
60
- }
61
- });
62
- let res = content;
63
- for (const themePromise of themePromises) {
64
- const theme = await themePromise;
65
- res += theme;
66
- }
67
- return res;
68
- };
69
-
70
- exports.default = additionalData;
1
+ const less = require("less");
2
+ const defaultVars = require("./scripts/default-vars");
3
+
4
+ const dark = require("./scripts/dark-vars");
5
+ const light = require("./scripts/light-vars");
6
+
7
+ const path = require("path");
8
+ const varDark = path.join(__dirname, ".", "style");
9
+ const themeConfig = [
10
+ {
11
+ theme: "dark",
12
+ htmlThemeAttr: "dark",
13
+ modifyVars: {
14
+ hack: `true;@import "${require.resolve(
15
+ varDark + "/color/colorPalette.less"
16
+ )}";@import "${require.resolve(varDark + "/themes/var-dark.less")}";`,
17
+ ...defaultVars,
18
+ ...dark,
19
+ "root-entry-name": "dark",
20
+ },
21
+ },
22
+ {
23
+ theme: "light",
24
+ htmlThemeAttr: "light",
25
+ modifyVars: {
26
+ // 引入除了变量外的其他内容
27
+ hack: `true;@import "${require.resolve(
28
+ varDark + "/color/colorPalette.less"
29
+ )}";@import "${require.resolve(varDark + "/themes/var-default.less")}";`,
30
+ ...defaultVars,
31
+ ...light,
32
+ "root-entry-name": "default",
33
+ },
34
+ },
35
+ ];
36
+ const additionalData = async (content, filename) => {
37
+ const themePromises = themeConfig.map(async (t) => {
38
+ const { htmlThemeAttr, modifyVars = {} } = t;
39
+ const options = {
40
+ javascriptEnabled: true,
41
+ modifyVars,
42
+ relativeUrls: true,
43
+ filename,
44
+ };
45
+ try {
46
+ const { css } = await less.render(content, options);
47
+ let res = "";
48
+ if (htmlThemeAttr && css) {
49
+ res = `
50
+ [data-doc-theme=${htmlThemeAttr}] {
51
+ ${css}
52
+ }
53
+ `;
54
+ }
55
+ return Promise.resolve(res);
56
+ } catch (error) {
57
+ // eslint-disable-next-line no-console
58
+ console.log(error);
59
+ return Promise.reject(content);
60
+ }
61
+ });
62
+ let res = content;
63
+ for (const themePromise of themePromises) {
64
+ const theme = await themePromise;
65
+ res += theme;
66
+ }
67
+ return res;
68
+ };
69
+
70
+ exports.default = additionalData;
@@ -1,21 +1,21 @@
1
- /**
2
- * convert dark.less into js vars
3
- *
4
- * const darkVars = require('./dark-vars');
5
- */
6
- const fs = require("fs");
7
- const path = require("path");
8
- const lessToJs = require("less-vars-to-js");
9
-
10
- const stylePath = path.join(__dirname, "..", "style");
11
- const darkLess = fs.readFileSync(
12
- path.join(stylePath, "themes", "var-dark.less"),
13
- "utf8"
14
- );
15
-
16
- const darkPaletteLess = lessToJs(darkLess, {
17
- stripPrefix: true,
18
- resolveVariables: false,
19
- });
20
-
21
- module.exports = darkPaletteLess;
1
+ /**
2
+ * convert dark.less into js vars
3
+ *
4
+ * const darkVars = require('./dark-vars');
5
+ */
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const lessToJs = require("less-vars-to-js");
9
+
10
+ const stylePath = path.join(__dirname, "..", "style");
11
+ const darkLess = fs.readFileSync(
12
+ path.join(stylePath, "themes", "var-dark.less"),
13
+ "utf8"
14
+ );
15
+
16
+ const darkPaletteLess = lessToJs(darkLess, {
17
+ stripPrefix: true,
18
+ resolveVariables: false,
19
+ });
20
+
21
+ module.exports = darkPaletteLess;
@@ -1,25 +1,25 @@
1
- /**
2
- * convert default.less into js vars
3
- *
4
- * const darkVars = require('./default-vars');
5
- */
6
- const fs = require("fs");
7
- const path = require("path");
8
- const lessToJs = require("less-vars-to-js");
9
-
10
- const stylePath = path.join(__dirname, "..", "style");
11
- const colorLess = fs.readFileSync(
12
- path.join(stylePath, "color", "colors.less"),
13
- "utf8"
14
- );
15
- const defaultLess = fs.readFileSync(
16
- path.join(stylePath, "themes", "default.less"),
17
- "utf8"
18
- );
19
-
20
- const defaultPaletteLess = lessToJs(`${colorLess}${defaultLess}`, {
21
- stripPrefix: true,
22
- resolveVariables: false,
23
- });
24
-
25
- module.exports = defaultPaletteLess;
1
+ /**
2
+ * convert default.less into js vars
3
+ *
4
+ * const darkVars = require('./default-vars');
5
+ */
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const lessToJs = require("less-vars-to-js");
9
+
10
+ const stylePath = path.join(__dirname, "..", "style");
11
+ const colorLess = fs.readFileSync(
12
+ path.join(stylePath, "color", "colors.less"),
13
+ "utf8"
14
+ );
15
+ const defaultLess = fs.readFileSync(
16
+ path.join(stylePath, "themes", "default.less"),
17
+ "utf8"
18
+ );
19
+
20
+ const defaultPaletteLess = lessToJs(`${colorLess}${defaultLess}`, {
21
+ stripPrefix: true,
22
+ resolveVariables: false,
23
+ });
24
+
25
+ module.exports = defaultPaletteLess;
@@ -1,22 +1,22 @@
1
- /**
2
- * convert dark.less into js vars
3
- *
4
- * const darkVars = require('./dark-vars');
5
- */
6
- const fs = require("fs");
7
- const path = require("path");
8
- const lessToJs = require("less-vars-to-js");
9
-
10
- const stylePath = path.join(__dirname, "..", "style");
11
- const lightLess = fs.readFileSync(
12
- path.join(stylePath, "themes", "var-default.less"),
13
- "utf8"
14
- );
15
-
16
- // 注册变量,过滤其他内容
17
- const lightPaletteLess = lessToJs(lightLess, {
18
- stripPrefix: true,
19
- resolveVariables: false,
20
- });
21
-
22
- module.exports = lightPaletteLess;
1
+ /**
2
+ * convert dark.less into js vars
3
+ *
4
+ * const darkVars = require('./dark-vars');
5
+ */
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const lessToJs = require("less-vars-to-js");
9
+
10
+ const stylePath = path.join(__dirname, "..", "style");
11
+ const lightLess = fs.readFileSync(
12
+ path.join(stylePath, "themes", "var-default.less"),
13
+ "utf8"
14
+ );
15
+
16
+ // 注册变量,过滤其他内容
17
+ const lightPaletteLess = lessToJs(lightLess, {
18
+ stripPrefix: true,
19
+ resolveVariables: false,
20
+ });
21
+
22
+ module.exports = lightPaletteLess;