@zfqh/uniapp 0.1.9 → 0.1.10

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.1.10](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.1.10...@zfqh/uniapp@0.1.10) (2026-06-21)
7
+
8
+ **Note:** Version bump only for package @zfqh/uniapp
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.1.9](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.1.8...@zfqh/uniapp@0.1.9) (2026-06-21)
7
15
 
8
16
  **Note:** Version bump only for package @zfqh/uniapp
@@ -2,15 +2,15 @@ import api from '../configs/api';
2
2
  import app from '../configs/app';
3
3
  import { createRequest, createInterceptors } from '../utils/request';
4
4
  import { LANGUAGE } from '../utils/consts';
5
+ import { defaultLocale } from '../utils/locale';
5
6
  import query from '../utils/query';
6
7
  import http from '@gmcb/uv-ui/libs/function/http';
7
8
  http.interceptors.request.use((conf) => {
8
9
  const store = uni.$store;
9
10
  if (store) {
10
11
  const { tenantId } = store.state.login?.info || {};
11
- const { appLanguage } = store.state.system?.info || {};
12
12
  const header = {
13
- 'X-Language': LANGUAGE[appLanguage],
13
+ 'X-Language': LANGUAGE[defaultLocale],
14
14
  'Tenant-Id': tenantId || 1,
15
15
  Channel: query.channel || app.channel,
16
16
  };
@@ -24,10 +24,18 @@ export default {
24
24
  return this.$store.state.login?.info || {};
25
25
  },
26
26
  queryString() {
27
- const { loginInfo } = this;
27
+ const { accessToken, storeId, userId, tenantId, storeName, tenantName, nickName, username, } = this.loginInfo;
28
28
  const q = {
29
- token: loginInfo.accessToken || '',
29
+ token: accessToken,
30
+ storeId,
31
+ userId,
32
+ tenantId,
33
+ storeName,
34
+ tenantName,
35
+ nickName,
36
+ username,
30
37
  app: app.code,
38
+ channel: app.channel,
31
39
  platform: PLATFORM_CODE,
32
40
  };
33
41
  if (query.primary) {
@@ -1,20 +1,11 @@
1
- import { storageKeys, getStorageSync, setStorage, setStorageSync, removeStorage } from '../utils/storage';
1
+ import { storageKeys, getStorageSync, setStorage, removeStorage } from '../utils/storage';
2
2
  import query from '../utils/query';
3
3
  import navigate from '../utils/navigate';
4
4
  import Throttle from '../utils/throttle';
5
5
  import { getPage } from '../utils/pages';
6
6
  import { postRefreshToken } from '../apis/core';
7
7
  const throttle = new Throttle();
8
- // #ifdef H5
9
- const queryToken = query.accessToken || query.token;
10
- if (queryToken != null) {
11
- const store = getStorageSync(storageKeys.login) || {};
12
- if (queryToken !== store.accessToken) {
13
- store.accessToken = queryToken;
14
- setStorageSync(storageKeys.login, store);
15
- }
16
- }
17
- // #endif
8
+ const _accessToken = query.accessToken || query.token;
18
9
  function getDefaultState() {
19
10
  return {
20
11
  accessToken: null,
@@ -33,8 +24,22 @@ function getDefaultState() {
33
24
  };
34
25
  }
35
26
  const store = {
36
- state: {
37
- info: getStorageSync(storageKeys.login) || getDefaultState(),
27
+ state() {
28
+ const defaultState = getDefaultState();
29
+ if (_accessToken) {
30
+ Object.keys(defaultState).forEach((key) => {
31
+ if (query[key] != null) {
32
+ defaultState[key] = query[key];
33
+ }
34
+ });
35
+ defaultState.accessToken = _accessToken;
36
+ return {
37
+ info: defaultState,
38
+ };
39
+ }
40
+ return {
41
+ info: getStorageSync(storageKeys.login) || defaultState,
42
+ };
38
43
  },
39
44
  getters: {
40
45
  // 是否已登录
@@ -48,7 +53,9 @@ const store = {
48
53
  data.accessToken = data.accessToken.replace(/^bearer\s+/i, '');
49
54
  }
50
55
  state.info = { ...state.info, ...data };
51
- setStorage(storageKeys.login, state.info);
56
+ if (!_accessToken) {
57
+ setStorage(storageKeys.login, state.info);
58
+ }
52
59
  },
53
60
  resetState(state) {
54
61
  state.info = getDefaultState();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zfqh/uniapp",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "uniapp公共模块",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "MIT",