@kevisual/api 0.0.47 → 0.0.49

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.
@@ -1,4 +1,4 @@
1
- // node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query-browser.js
1
+ // node_modules/.pnpm/@kevisual+query@0.0.40/node_modules/@kevisual/query/dist/query-browser.js
2
2
  var isTextForContentType = (contentType) => {
3
3
  if (!contentType)
4
4
  return false;
@@ -27,12 +27,12 @@ var adapter = async (opts = {}, overloadOpts) => {
27
27
  url = new URL(opts.url);
28
28
  } else {
29
29
  origin = window?.location?.origin || "http://localhost:51515";
30
- url = new URL(opts.url, origin);
30
+ url = new URL(opts?.url || "", origin);
31
31
  }
32
32
  const isGet = method === "GET";
33
33
  const oldSearchParams = url.searchParams;
34
34
  if (isGet) {
35
- let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts.body });
35
+ let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts?.params, ...opts?.body });
36
36
  url.search = searchParams.toString();
37
37
  } else {
38
38
  const params = {
@@ -57,11 +57,13 @@ var adapter = async (opts = {}, overloadOpts) => {
57
57
  } else if (isPostFile) {
58
58
  body = opts.body;
59
59
  } else {
60
- headers = {
61
- "Content-Type": "application/json",
62
- ...headers
63
- };
64
- body = JSON.stringify(opts.body);
60
+ if (opts.body && typeof opts.body === "object" && !(opts.body instanceof FormData)) {
61
+ headers = {
62
+ "Content-Type": "application/json",
63
+ ...headers
64
+ };
65
+ body = JSON.stringify(opts.body);
66
+ }
65
67
  }
66
68
  return fetch(url, {
67
69
  method: method.toUpperCase(),
@@ -131,7 +133,7 @@ class Query {
131
133
  "Content-Type": "application/json"
132
134
  };
133
135
  this.timeout = opts?.timeout || 60000 * 3;
134
- if (opts.beforeRequest) {
136
+ if (opts?.beforeRequest) {
135
137
  this.beforeRequest = opts.beforeRequest;
136
138
  } else {
137
139
  this.beforeRequest = async (opts2) => {
@@ -280,7 +282,7 @@ class BaseQuery {
280
282
  }
281
283
  }
282
284
 
283
- // node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query.js
285
+ // node_modules/.pnpm/@kevisual+query@0.0.40/node_modules/@kevisual/query/dist/query.js
284
286
  var setBaseResponse = (res) => {
285
287
  res.success = res.code === 200;
286
288
  res.showError = (fn) => {
@@ -350,6 +352,8 @@ class LoginCacheStore {
350
352
  this.cacheData.id = user.id;
351
353
  this.cacheData.accessToken = user.accessToken;
352
354
  this.cacheData.refreshToken = user.refreshToken;
355
+ this.cacheData.accessTokenExpiresIn = user.accessTokenExpiresIn;
356
+ this.cacheData.createdAt = user.createdAt;
353
357
  await this.setValue(this.cacheData);
354
358
  }
355
359
  getCurrentUser() {
@@ -854,7 +858,7 @@ class QueryLogin extends BaseQuery {
854
858
  this.isBrowser = opts?.isBrowser ?? true;
855
859
  this.init();
856
860
  this.onLoad = opts?.onLoad;
857
- this.storage = opts?.storage || localStorage;
861
+ this.storage = opts?.storage || globalThis?.localStorage;
858
862
  }
859
863
  setQuery(query) {
860
864
  this.query = query;
@@ -877,32 +881,32 @@ class QueryLogin extends BaseQuery {
877
881
  async login(data) {
878
882
  const res = await this.post({ key: "login", ...data });
879
883
  if (res.code === 200) {
880
- const { accessToken, refreshToken } = res?.data || {};
884
+ const { accessToken, refreshToken, accessTokenExpiresIn } = res?.data || {};
881
885
  this.storage.setItem("token", accessToken || "");
882
- await this.beforeSetLoginUser({ accessToken, refreshToken });
886
+ await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
883
887
  }
884
888
  return res;
885
889
  }
886
890
  async loginByCode(data) {
887
891
  const res = await this.post({ path: "sms", key: "login", data });
888
892
  if (res.code === 200) {
889
- const { accessToken, refreshToken } = res?.data || {};
893
+ const { accessToken, refreshToken, accessTokenExpiresIn } = res?.data || {};
890
894
  this.storage.setItem("token", accessToken || "");
891
- await this.beforeSetLoginUser({ accessToken, refreshToken });
895
+ await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
892
896
  }
893
897
  return res;
894
898
  }
895
899
  async setLoginToken(token) {
896
- const { accessToken, refreshToken } = token;
900
+ const { accessToken, refreshToken, accessTokenExpiresIn } = token;
897
901
  this.storage.setItem("token", accessToken || "");
898
- await this.beforeSetLoginUser({ accessToken, refreshToken });
902
+ await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
899
903
  }
900
904
  async loginByWechat(data) {
901
905
  const res = await this.post({ path: "wx", key: "open-login", code: data.code });
902
906
  if (res.code === 200) {
903
- const { accessToken, refreshToken } = res?.data || {};
907
+ const { accessToken, refreshToken, accessTokenExpiresIn } = res?.data || {};
904
908
  this.storage.setItem("token", accessToken || "");
905
- await this.beforeSetLoginUser({ accessToken, refreshToken });
909
+ await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
906
910
  }
907
911
  return res;
908
912
  }
@@ -919,7 +923,7 @@ class QueryLogin extends BaseQuery {
919
923
  }
920
924
  }
921
925
  }
922
- async beforeSetLoginUser({ accessToken, refreshToken, check401 }) {
926
+ async beforeSetLoginUser({ accessToken, refreshToken, check401, accessTokenExpiresIn }) {
923
927
  if (accessToken && refreshToken) {
924
928
  const resUser = await this.getMe(accessToken, check401);
925
929
  if (resUser.code === 200) {
@@ -929,7 +933,9 @@ class QueryLogin extends BaseQuery {
929
933
  user,
930
934
  id: user.id,
931
935
  accessToken,
932
- refreshToken
936
+ refreshToken,
937
+ accessTokenExpiresIn,
938
+ createdAt: Date.now()
933
939
  });
934
940
  } else {
935
941
  console.error("登录失败");
@@ -962,9 +968,9 @@ class QueryLogin extends BaseQuery {
962
968
  if (hasRefreshToken) {
963
969
  const res = await that.queryRefreshToken(hasRefreshToken);
964
970
  if (res.code === 200) {
965
- const { accessToken, refreshToken } = res?.data || {};
971
+ const { accessToken, refreshToken, accessTokenExpiresIn } = res?.data || {};
966
972
  that.storage.setItem("token", accessToken || "");
967
- await that.beforeSetLoginUser({ accessToken, refreshToken, check401: false });
973
+ await that.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn, check401: false });
968
974
  if (refetch && ctx && ctx.req && ctx.req.url && ctx.fetch) {
969
975
  await new Promise((resolve) => setTimeout(resolve, 1500));
970
976
  const url = ctx.req?.url;
@@ -1057,12 +1063,17 @@ class QueryLogin extends BaseQuery {
1057
1063
  const user = localUserList.find((userItem) => userItem.user.username === username);
1058
1064
  if (user) {
1059
1065
  this.storage.setItem("token", user.accessToken || "");
1060
- await this.beforeSetLoginUser({ accessToken: user.accessToken, refreshToken: user.refreshToken });
1066
+ await this.beforeSetLoginUser({
1067
+ accessToken: user.accessToken,
1068
+ refreshToken: user.refreshToken,
1069
+ accessTokenExpiresIn: user.accessTokenExpiresIn
1070
+ });
1061
1071
  return {
1062
1072
  code: 200,
1063
1073
  data: {
1064
1074
  accessToken: user.accessToken,
1065
- refreshToken: user.refreshToken
1075
+ refreshToken: user.refreshToken,
1076
+ accessTokenExpiresIn: user.accessTokenExpiresIn
1066
1077
  },
1067
1078
  success: true,
1068
1079
  message: "切换用户成功"
@@ -1070,9 +1081,9 @@ class QueryLogin extends BaseQuery {
1070
1081
  }
1071
1082
  const res = await this.postSwitchUser(username);
1072
1083
  if (res.code === 200) {
1073
- const { accessToken, refreshToken } = res?.data || {};
1084
+ const { accessToken, refreshToken, accessTokenExpiresIn } = res?.data || {};
1074
1085
  this.storage.setItem("token", accessToken || "");
1075
- await this.beforeSetLoginUser({ accessToken, refreshToken });
1086
+ await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
1076
1087
  }
1077
1088
  return res;
1078
1089
  }
@@ -1110,9 +1121,9 @@ class QueryLogin extends BaseQuery {
1110
1121
  loginToken: token
1111
1122
  });
1112
1123
  if (res.code === 200) {
1113
- const accessToken = res.data?.accessToken;
1124
+ const { accessTokenExpiresIn, accessToken, refreshToken } = res.data;
1114
1125
  this.storage.setItem("token", accessToken || "");
1115
- await this.beforeSetLoginUser({ accessToken, refreshToken: res.data?.refreshToken });
1126
+ await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
1116
1127
  return res;
1117
1128
  }
1118
1129
  return false;
@@ -0,0 +1,128 @@
1
+ import { Query } from '@kevisual/query';
2
+ import { Result, DataOpts } from '@kevisual/query/query';
3
+
4
+ type SimpleObject = Record<string, any>;
5
+ declare const markType: readonly ["simple", "md", "mdx", "wallnote", "excalidraw", "chat"];
6
+ type MarkType = (typeof markType)[number];
7
+ type MarkData = {
8
+ nodes?: any[];
9
+ edges?: any[];
10
+ elements?: any[];
11
+ permission?: any;
12
+ [key: string]: any;
13
+ };
14
+ type Mark = {
15
+ id: string;
16
+ title: string;
17
+ description: string;
18
+ markType: MarkType;
19
+ link: string;
20
+ data?: MarkData;
21
+ uid: string;
22
+ puid: string;
23
+ summary: string;
24
+ thumbnail?: string;
25
+ tags: string[];
26
+ createdAt: string;
27
+ updatedAt: string;
28
+ version: number;
29
+ };
30
+ type ShowMarkPick = Pick<Mark, 'id' | 'title' | 'description' | 'summary' | 'link' | 'tags' | 'thumbnail' | 'updatedAt'>;
31
+ type SearchOpts = {
32
+ page?: number;
33
+ pageSize?: number;
34
+ search?: string;
35
+ sort?: string;
36
+ markType?: MarkType;
37
+ [key: string]: any;
38
+ };
39
+ type QueryMarkOpts<T extends SimpleObject = SimpleObject> = {
40
+ query?: Query;
41
+ isBrowser?: boolean;
42
+ onLoad?: () => void;
43
+ } & T;
44
+ type ResultMarkList = {
45
+ list: Mark[];
46
+ pagination: {
47
+ pageSize: number;
48
+ current: number;
49
+ total: number;
50
+ };
51
+ };
52
+ type QueryMarkData = {
53
+ id?: string;
54
+ title?: string;
55
+ description?: string;
56
+ [key: string]: any;
57
+ };
58
+ type QueryMarkResult = {
59
+ accessToken: string;
60
+ refreshToken: string;
61
+ };
62
+ declare class QueryMarkBase<T extends SimpleObject = SimpleObject> {
63
+ query: Query;
64
+ isBrowser: boolean;
65
+ load?: boolean;
66
+ storage?: Storage;
67
+ onLoad?: () => void;
68
+ constructor(opts?: QueryMarkOpts<T>);
69
+ setQuery(query: Query): void;
70
+ private init;
71
+ post<T = Result<any>>(data: any, opts?: DataOpts): Promise<T>;
72
+ getMarkList(search: SearchOpts, opts?: DataOpts): Promise<{
73
+ code: number;
74
+ data?: ResultMarkList | undefined;
75
+ message?: string;
76
+ }>;
77
+ getMark(id: string, opts?: DataOpts): Promise<{
78
+ code: number;
79
+ data?: Mark | undefined;
80
+ message?: string;
81
+ }>;
82
+ getVersion(id: string, opts?: DataOpts): Promise<{
83
+ code: number;
84
+ data?: {
85
+ version: number;
86
+ id: string;
87
+ } | undefined;
88
+ message?: string;
89
+ }>;
90
+ /**
91
+ * 检查版本
92
+ * 当需要更新时,返回true
93
+ * @param id
94
+ * @param version
95
+ * @param opts
96
+ * @returns
97
+ */
98
+ checkVersion(id: string, version?: number, opts?: DataOpts): Promise<boolean>;
99
+ updateMark(data: any, opts?: DataOpts): Promise<{
100
+ code: number;
101
+ data?: Mark | undefined;
102
+ message?: string;
103
+ }>;
104
+ deleteMark(id: string, opts?: DataOpts): Promise<{
105
+ code: number;
106
+ data?: Mark | undefined;
107
+ message?: string;
108
+ }>;
109
+ }
110
+ declare class QueryMark extends QueryMarkBase<SimpleObject> {
111
+ markType: string;
112
+ constructor(opts?: QueryMarkOpts & {
113
+ markType?: MarkType;
114
+ });
115
+ getMarkList(search?: SearchOpts, opts?: DataOpts): Promise<{
116
+ code: number;
117
+ data?: ResultMarkList | undefined;
118
+ message?: string;
119
+ }>;
120
+ updateMark(data: any, opts?: DataOpts): Promise<{
121
+ code: number;
122
+ data?: Mark | undefined;
123
+ message?: string;
124
+ }>;
125
+ }
126
+
127
+ export { QueryMark, QueryMarkBase, markType };
128
+ export type { Mark, MarkData, MarkType, QueryMarkData, QueryMarkOpts, QueryMarkResult, ResultMarkList, SearchOpts, ShowMarkPick, SimpleObject };
@@ -0,0 +1,342 @@
1
+ // node_modules/.pnpm/@kevisual+query@0.0.40/node_modules/@kevisual/query/dist/query-browser.js
2
+ var isTextForContentType = (contentType) => {
3
+ if (!contentType)
4
+ return false;
5
+ const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
6
+ return textTypes.some((type) => contentType.includes(type));
7
+ };
8
+ var adapter = async (opts = {}, overloadOpts) => {
9
+ const controller = new AbortController;
10
+ const signal = controller.signal;
11
+ const isPostFile = opts.isPostFile || false;
12
+ let responseType = opts.responseType || "json";
13
+ if (opts.isBlob) {
14
+ responseType = "blob";
15
+ } else if (opts.isText) {
16
+ responseType = "text";
17
+ }
18
+ const timeout = opts.timeout || 60000 * 3;
19
+ const timer = setTimeout(() => {
20
+ controller.abort();
21
+ }, timeout);
22
+ let method = overloadOpts?.method || opts?.method || "POST";
23
+ let headers = { ...opts?.headers, ...overloadOpts?.headers };
24
+ let origin = "";
25
+ let url;
26
+ if (opts?.url?.startsWith("http")) {
27
+ url = new URL(opts.url);
28
+ } else {
29
+ origin = window?.location?.origin || "http://localhost:51515";
30
+ url = new URL(opts?.url || "", origin);
31
+ }
32
+ const isGet = method === "GET";
33
+ const oldSearchParams = url.searchParams;
34
+ if (isGet) {
35
+ let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts?.params, ...opts?.body });
36
+ url.search = searchParams.toString();
37
+ } else {
38
+ const params = {
39
+ ...Object.fromEntries(oldSearchParams),
40
+ ...opts.params
41
+ };
42
+ const searchParams = new URLSearchParams(params);
43
+ if (typeof opts.body === "object" && opts.body !== null) {
44
+ let body2 = opts.body || {};
45
+ if (!params.path && body2?.path) {
46
+ searchParams.set("path", body2.path);
47
+ if (body2?.key) {
48
+ searchParams.set("key", body2.key);
49
+ }
50
+ }
51
+ }
52
+ url.search = searchParams.toString();
53
+ }
54
+ let body = undefined;
55
+ if (isGet) {
56
+ body = undefined;
57
+ } else if (isPostFile) {
58
+ body = opts.body;
59
+ } else {
60
+ if (opts.body && typeof opts.body === "object" && !(opts.body instanceof FormData)) {
61
+ headers = {
62
+ "Content-Type": "application/json",
63
+ ...headers
64
+ };
65
+ body = JSON.stringify(opts.body);
66
+ }
67
+ }
68
+ return fetch(url, {
69
+ method: method.toUpperCase(),
70
+ signal,
71
+ body,
72
+ ...overloadOpts,
73
+ headers
74
+ }).then(async (response) => {
75
+ const contentType = response.headers.get("Content-Type");
76
+ if (responseType === "blob") {
77
+ return await response.blob();
78
+ }
79
+ const isText = responseType === "text";
80
+ const isJson = contentType && contentType.includes("application/json");
81
+ if (isJson && !isText) {
82
+ return await response.json();
83
+ } else if (isTextForContentType(contentType)) {
84
+ return {
85
+ code: response.status,
86
+ status: response.status,
87
+ data: await response.text()
88
+ };
89
+ } else {
90
+ return response;
91
+ }
92
+ }).catch((err) => {
93
+ if (err.name === "AbortError") {
94
+ return {
95
+ code: 408,
96
+ message: "请求超时"
97
+ };
98
+ }
99
+ return {
100
+ code: 500,
101
+ message: err.message || "网络错误"
102
+ };
103
+ }).finally(() => {
104
+ clearTimeout(timer);
105
+ });
106
+ };
107
+ var wrapperError = ({ code, message }) => {
108
+ const result = {
109
+ code: code || 500,
110
+ success: false,
111
+ message: message || "api request error",
112
+ showError: (fn) => {},
113
+ noMsg: true
114
+ };
115
+ return result;
116
+ };
117
+
118
+ class Query {
119
+ adapter;
120
+ url;
121
+ beforeRequest;
122
+ afterResponse;
123
+ headers;
124
+ timeout;
125
+ stop;
126
+ qws;
127
+ isClient = false;
128
+ constructor(opts) {
129
+ this.adapter = opts?.adapter || adapter;
130
+ const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
131
+ this.url = opts?.url || defaultURL;
132
+ this.headers = opts?.headers || {
133
+ "Content-Type": "application/json"
134
+ };
135
+ this.timeout = opts?.timeout || 60000 * 3;
136
+ if (opts?.beforeRequest) {
137
+ this.beforeRequest = opts.beforeRequest;
138
+ } else {
139
+ this.beforeRequest = async (opts2) => {
140
+ const token = globalThis?.localStorage?.getItem("token");
141
+ if (token) {
142
+ opts2.headers = {
143
+ ...opts2.headers,
144
+ Authorization: `Bearer ${token}`
145
+ };
146
+ }
147
+ return opts2;
148
+ };
149
+ }
150
+ }
151
+ setQueryWs(qws) {
152
+ this.qws = qws;
153
+ }
154
+ setStop(stop) {
155
+ this.stop = stop;
156
+ }
157
+ async get(params, options) {
158
+ return this.post(params, options);
159
+ }
160
+ async post(body, options) {
161
+ const url = options?.url || this.url;
162
+ const { headers, adapter: adapter2, beforeRequest, afterResponse, timeout, ...rest } = options || {};
163
+ const _headers = { ...this.headers, ...headers };
164
+ const _adapter = adapter2 || this.adapter;
165
+ const _beforeRequest = beforeRequest || this.beforeRequest;
166
+ const _afterResponse = afterResponse || this.afterResponse;
167
+ const _timeout = timeout || this.timeout;
168
+ const req = {
169
+ url,
170
+ headers: _headers,
171
+ body,
172
+ timeout: _timeout,
173
+ ...rest
174
+ };
175
+ try {
176
+ if (_beforeRequest) {
177
+ const res = await _beforeRequest(req);
178
+ if (res === false) {
179
+ return wrapperError({
180
+ code: 500,
181
+ message: "request is cancel",
182
+ req
183
+ });
184
+ }
185
+ }
186
+ } catch (e) {
187
+ console.error("request beforeFn error", e, req);
188
+ return wrapperError({
189
+ code: 500,
190
+ message: "api request beforeFn error"
191
+ });
192
+ }
193
+ if (this.stop && !options?.noStop) {
194
+ const that = this;
195
+ await new Promise((resolve) => {
196
+ let timer = 0;
197
+ const detect = setInterval(() => {
198
+ if (!that.stop) {
199
+ clearInterval(detect);
200
+ resolve(true);
201
+ }
202
+ timer++;
203
+ if (timer > 30) {
204
+ console.error("request stop: timeout", req.url, timer);
205
+ }
206
+ }, 1000);
207
+ });
208
+ }
209
+ return _adapter(req).then(async (res) => {
210
+ try {
211
+ if (_afterResponse) {
212
+ return await _afterResponse(res, {
213
+ req,
214
+ res,
215
+ fetch: adapter2
216
+ });
217
+ }
218
+ return res;
219
+ } catch (e) {
220
+ console.error("request afterFn error", e, req);
221
+ return wrapperError({
222
+ code: 500,
223
+ message: "api request afterFn error"
224
+ });
225
+ }
226
+ });
227
+ }
228
+ before(fn) {
229
+ this.beforeRequest = fn;
230
+ }
231
+ after(fn) {
232
+ this.afterResponse = fn;
233
+ }
234
+ async fetchText(urlOrOptions, options) {
235
+ let _options = { ...options };
236
+ if (typeof urlOrOptions === "string" && !_options.url) {
237
+ _options.url = urlOrOptions;
238
+ }
239
+ if (typeof urlOrOptions === "object") {
240
+ _options = { ...urlOrOptions, ..._options };
241
+ }
242
+ const res = await adapter({
243
+ method: "GET",
244
+ ..._options,
245
+ headers: {
246
+ ...this.headers,
247
+ ..._options?.headers || {}
248
+ }
249
+ });
250
+ if (res && !res.code) {
251
+ return {
252
+ code: 200,
253
+ data: res
254
+ };
255
+ }
256
+ return res;
257
+ }
258
+ }
259
+
260
+ // query/query-mark/index.ts
261
+ var markType = ["simple", "md", "mdx", "wallnote", "excalidraw", "chat"];
262
+
263
+ class QueryMarkBase {
264
+ query;
265
+ isBrowser;
266
+ load;
267
+ storage;
268
+ onLoad;
269
+ constructor(opts) {
270
+ this.query = opts?.query || new Query;
271
+ this.isBrowser = opts?.isBrowser ?? true;
272
+ this.init();
273
+ this.onLoad = opts?.onLoad;
274
+ }
275
+ setQuery(query) {
276
+ this.query = query;
277
+ }
278
+ async init() {
279
+ this.load = true;
280
+ this.onLoad?.();
281
+ }
282
+ async post(data, opts) {
283
+ try {
284
+ return this.query.post({ path: "mark", ...data }, opts);
285
+ } catch (error) {
286
+ console.log("error", error);
287
+ return {
288
+ code: 400
289
+ };
290
+ }
291
+ }
292
+ async getMarkList(search, opts) {
293
+ return this.post({ key: "list", ...search }, opts);
294
+ }
295
+ async getMark(id, opts) {
296
+ return this.post({ key: "get", id }, opts);
297
+ }
298
+ async getVersion(id, opts) {
299
+ return this.post({ key: "getVersion", id }, opts);
300
+ }
301
+ async checkVersion(id, version, opts) {
302
+ if (!version) {
303
+ return true;
304
+ }
305
+ const res = await this.getVersion(id, opts);
306
+ if (res.code === 200) {
307
+ if (res.data.version > version) {
308
+ return true;
309
+ }
310
+ return false;
311
+ }
312
+ return true;
313
+ }
314
+ async updateMark(data, opts) {
315
+ return this.post({ key: "update", data }, opts);
316
+ }
317
+ async deleteMark(id, opts) {
318
+ return this.post({ key: "delete", id }, opts);
319
+ }
320
+ }
321
+
322
+ class QueryMark extends QueryMarkBase {
323
+ markType;
324
+ constructor(opts) {
325
+ super(opts);
326
+ this.markType = opts?.markType || "simple";
327
+ }
328
+ async getMarkList(search, opts) {
329
+ return this.post({ key: "list", ...search, markType: this.markType }, opts);
330
+ }
331
+ async updateMark(data, opts) {
332
+ if (!data.id) {
333
+ data.markType = this.markType || "simple";
334
+ }
335
+ return super.updateMark(data, opts);
336
+ }
337
+ }
338
+ export {
339
+ markType,
340
+ QueryMarkBase,
341
+ QueryMark
342
+ };
@@ -145,7 +145,7 @@ declare class QueryProxy {
145
145
  token?: string;
146
146
  routerViewData?: RouterViewData;
147
147
  });
148
- getDefulatToken(): string;
148
+ getDefulatToken(): string | undefined;
149
149
  initRouterViewQuery(): void;
150
150
  initRouterView(item: RouterViewItem): RouterViewItem<{}>;
151
151
  /**
@@ -175,8 +175,8 @@ declare class QueryProxy {
175
175
  listRoutes(filterFn?: (item: Route) => boolean, opts?: {
176
176
  viewId?: string;
177
177
  query?: string;
178
- }): Promise<any>;
179
- getViewQuery(viewId: string): Promise<string>;
178
+ }): Promise<any[]>;
179
+ getViewQuery(viewId: string): Promise<string | undefined>;
180
180
  /**
181
181
  * 运行路由
182
182
  * @param msg
@@ -207,7 +207,7 @@ declare const initApi: (opts: {
207
207
  */
208
208
  exclude?: string;
209
209
  }) => Promise<{
210
- code: any;
210
+ code: number;
211
211
  message: string;
212
212
  }>;
213
213