@quantabit/mentor-sdk 1.0.0
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/LICENSE +21 -0
- package/README.md +93 -0
- package/dist/index.cjs +607 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.esm.js +591 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/styles.css +1 -0
- package/package.json +83 -0
- package/types/index.d.ts +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QuantaBit Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @quantabit/mentor-sdk
|
|
2
|
+
|
|
3
|
+
> QuantaBit Mentor System SDK - Mentor-mentee binding, inheritance rewards, and relationship network
|
|
4
|
+
|
|
5
|
+
## 📦 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @quantabit/mentor-sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add @quantabit/mentor-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 🚀 Quick Start
|
|
14
|
+
|
|
15
|
+
### 1. Setup Provider
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
import { MentorProvider } from "@quantabit/mentor-sdk";
|
|
19
|
+
import "@quantabit/mentor-sdk/styles.css";
|
|
20
|
+
|
|
21
|
+
function App() {
|
|
22
|
+
return (
|
|
23
|
+
<MentorProvider
|
|
24
|
+
apiUrl="https://api.example.com/v1"
|
|
25
|
+
token="your-auth-token"
|
|
26
|
+
language="en"
|
|
27
|
+
onBind={(result) => console.log("Mentor bound:", result)}
|
|
28
|
+
>
|
|
29
|
+
<YourComponent />
|
|
30
|
+
</MentorProvider>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. Using Components
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
import { MentorCard, BindMentorForm } from '@quantabit/mentor-sdk';
|
|
39
|
+
|
|
40
|
+
// Mentor/Mentee card
|
|
41
|
+
<MentorCard
|
|
42
|
+
user={mentorData}
|
|
43
|
+
role="mentor"
|
|
44
|
+
onUnbind={(user) => handleUnbind(user)}
|
|
45
|
+
onViewProfile={(user) => navigateToProfile(user.did)}
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
// Bind mentor form
|
|
49
|
+
<BindMentorForm
|
|
50
|
+
onSuccess={(result) => handleSuccess(result)}
|
|
51
|
+
onCancel={() => setShowForm(false)}
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 3. Using Hooks
|
|
56
|
+
|
|
57
|
+
```jsx
|
|
58
|
+
import { useMentor } from "@quantabit/mentor-sdk";
|
|
59
|
+
|
|
60
|
+
function MyComponent() {
|
|
61
|
+
const {
|
|
62
|
+
myMentor, // My mentor
|
|
63
|
+
myApprentices, // My mentees
|
|
64
|
+
rewards, // Reward records
|
|
65
|
+
bindMentor, // Bind a mentor
|
|
66
|
+
loadRewards, // Load rewards
|
|
67
|
+
} = useMentor();
|
|
68
|
+
|
|
69
|
+
return <div>...</div>;
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 🎁 Reward Types
|
|
74
|
+
|
|
75
|
+
- **Mentorship Reward**: Earned upon successful mentor-mentee binding
|
|
76
|
+
- **First Deposit Commission**: Mentor earns commission from mentee's first deposit
|
|
77
|
+
- **Task Inheritance**: Mentor earns inheritance rewards when mentee completes tasks
|
|
78
|
+
- **Daily Active Reward**: Mentor earns activity rewards when mentee stays active
|
|
79
|
+
|
|
80
|
+
## 📄 License
|
|
81
|
+
|
|
82
|
+
MIT License
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 🌐 Brand & Links
|
|
89
|
+
- Official Mainnet: [QuantaBit Chain](https://qbitchain.io/)
|
|
90
|
+
- Developer Platform: [Developer Platform](https://developer.quantabit.io/)
|
|
91
|
+
- Open Platform: [Open Platform](https://open.quantabit.io/)
|
|
92
|
+
- Payment Platform: [Pay Platform](https://pay.qbitwallet.io/)
|
|
93
|
+
- Feedback: [Feedback](https://xwin.live/qbit)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var sdkConfig = require('@quantabit/sdk-config');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Mentor SDK - API 客户端
|
|
8
|
+
* 导师系统后端接口封装
|
|
9
|
+
*
|
|
10
|
+
* 使用 BaseApiClient 基类简化代码
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 导师 API 客户端
|
|
16
|
+
*/
|
|
17
|
+
class MentorApiClient extends sdkConfig.BaseApiClient {
|
|
18
|
+
constructor(config = {}) {
|
|
19
|
+
super('/mentor', config);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// ============ 导师查询 ============
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 获取导师列表
|
|
26
|
+
* @param {Object} params - 查询参数
|
|
27
|
+
*/
|
|
28
|
+
async getMentors(params = {}) {
|
|
29
|
+
return this.get('/list', params);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 获取导师详情
|
|
34
|
+
* @param {string} mentorId - 导师 ID
|
|
35
|
+
*/
|
|
36
|
+
async getMentor(mentorId) {
|
|
37
|
+
return this.get(`/${mentorId}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 搜索导师
|
|
42
|
+
* @param {string} keyword - 关键词
|
|
43
|
+
* @param {Object} params - 查询参数
|
|
44
|
+
*/
|
|
45
|
+
async searchMentors(keyword, params = {}) {
|
|
46
|
+
return this.get('/search', {
|
|
47
|
+
keyword,
|
|
48
|
+
...params
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 获取推荐导师
|
|
54
|
+
* @param {number} limit - 数量
|
|
55
|
+
*/
|
|
56
|
+
async getRecommendedMentors(limit = 10) {
|
|
57
|
+
return this.get('/recommended', {
|
|
58
|
+
limit
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ============ 导师关系 ============
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 申请成为学员
|
|
66
|
+
* @param {string} mentorId - 导师 ID
|
|
67
|
+
* @param {Object} application - 申请信息
|
|
68
|
+
*/
|
|
69
|
+
async applyAsMentee(mentorId, application = {}) {
|
|
70
|
+
return this.post(`/${mentorId}/apply`, application);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 获取我的导师
|
|
75
|
+
*/
|
|
76
|
+
async getMyMentor() {
|
|
77
|
+
return this.get('/my/mentor');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 获取我的学员
|
|
82
|
+
* @param {Object} params - 查询参数
|
|
83
|
+
*/
|
|
84
|
+
async getMyMentees(params = {}) {
|
|
85
|
+
return this.get('/my/mentees', params);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 解除导师关系
|
|
90
|
+
* @param {string} relationshipId - 关系 ID
|
|
91
|
+
* @param {string} reason - 原因
|
|
92
|
+
*/
|
|
93
|
+
async endRelationship(relationshipId, reason = '') {
|
|
94
|
+
return this.post(`/relationships/${relationshipId}/end`, {
|
|
95
|
+
reason
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ============ 导师申请管理 ============
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 申请成为导师
|
|
103
|
+
* @param {Object} application - 申请数据
|
|
104
|
+
*/
|
|
105
|
+
async applyAsMentor(application) {
|
|
106
|
+
return this.post('/apply', application);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 获取学员申请
|
|
111
|
+
* @param {Object} params - 查询参数
|
|
112
|
+
*/
|
|
113
|
+
async getMenteeApplications(params = {}) {
|
|
114
|
+
return this.get('/applications', params);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 处理学员申请
|
|
119
|
+
* @param {string} applicationId - 申请 ID
|
|
120
|
+
* @param {boolean} approved - 是否批准
|
|
121
|
+
* @param {string} message - 消息
|
|
122
|
+
*/
|
|
123
|
+
async handleApplication(applicationId, approved, message = '') {
|
|
124
|
+
return this.post(`/applications/${applicationId}`, {
|
|
125
|
+
approved,
|
|
126
|
+
message
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ============ 辅导管理 ============
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 创建辅导计划
|
|
134
|
+
* @param {string} menteeId - 学员 ID
|
|
135
|
+
* @param {Object} plan - 计划数据
|
|
136
|
+
*/
|
|
137
|
+
async createPlan(menteeId, plan) {
|
|
138
|
+
return this.post(`/mentees/${menteeId}/plans`, plan);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 获取辅导计划
|
|
143
|
+
* @param {string} menteeId - 学员 ID
|
|
144
|
+
*/
|
|
145
|
+
async getPlans(menteeId) {
|
|
146
|
+
return this.get(`/mentees/${menteeId}/plans`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 更新计划进度
|
|
151
|
+
* @param {string} planId - 计划 ID
|
|
152
|
+
* @param {Object} progress - 进度数据
|
|
153
|
+
*/
|
|
154
|
+
async updatePlanProgress(planId, progress) {
|
|
155
|
+
return this.put(`/plans/${planId}/progress`, progress);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ============ 辅导记录 ============
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 添加辅导记录
|
|
162
|
+
* @param {string} menteeId - 学员 ID
|
|
163
|
+
* @param {Object} record - 记录数据
|
|
164
|
+
*/
|
|
165
|
+
async addRecord(menteeId, record) {
|
|
166
|
+
return this.post(`/mentees/${menteeId}/records`, record);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 获取辅导记录
|
|
171
|
+
* @param {string} menteeId - 学员 ID
|
|
172
|
+
* @param {Object} params - 查询参数
|
|
173
|
+
*/
|
|
174
|
+
async getRecords(menteeId, params = {}) {
|
|
175
|
+
return this.get(`/mentees/${menteeId}/records`, params);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ============ 评价反馈 ============
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 评价导师
|
|
182
|
+
* @param {string} mentorId - 导师 ID
|
|
183
|
+
* @param {Object} review - 评价数据
|
|
184
|
+
*/
|
|
185
|
+
async reviewMentor(mentorId, review) {
|
|
186
|
+
return this.post(`/${mentorId}/review`, review);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* 获取导师评价
|
|
191
|
+
* @param {string} mentorId - 导师 ID
|
|
192
|
+
* @param {Object} params - 查询参数
|
|
193
|
+
*/
|
|
194
|
+
async getMentorReviews(mentorId, params = {}) {
|
|
195
|
+
return this.get(`/${mentorId}/reviews`, params);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// ============ 导师资料 ============
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 更新导师资料
|
|
202
|
+
* @param {Object} profile - 资料数据
|
|
203
|
+
*/
|
|
204
|
+
async updateMentorProfile(profile) {
|
|
205
|
+
return this.put('/my/profile', profile);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 设置可用时间
|
|
210
|
+
* @param {Object} availability - 可用时间配置
|
|
211
|
+
*/
|
|
212
|
+
async setAvailability(availability) {
|
|
213
|
+
return this.put('/my/availability', availability);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 获取导师统计
|
|
218
|
+
*/
|
|
219
|
+
async getMentorStats() {
|
|
220
|
+
return this.get('/my/stats');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// 创建默认实例
|
|
225
|
+
const mentorApi = new MentorApiClient();
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Mentor SDK - 国际化 i18n
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];
|
|
232
|
+
const messages = {
|
|
233
|
+
zh: {
|
|
234
|
+
loading: '加载中...',
|
|
235
|
+
mentor: '师傅',
|
|
236
|
+
apprentice: '徒弟',
|
|
237
|
+
mentorSystem: '师徒系统',
|
|
238
|
+
// 关系
|
|
239
|
+
myMentor: '我的师傅',
|
|
240
|
+
myApprentices: '我的徒弟',
|
|
241
|
+
noMentor: '暂无师傅',
|
|
242
|
+
noApprentices: '暂无徒弟',
|
|
243
|
+
// 操作
|
|
244
|
+
bindMentor: '拜师',
|
|
245
|
+
unbind: '解除关系',
|
|
246
|
+
inviteApprentice: '收徒',
|
|
247
|
+
viewProfile: '查看主页',
|
|
248
|
+
// 状态
|
|
249
|
+
statusActive: '正常',
|
|
250
|
+
statusExpired: '已失效',
|
|
251
|
+
bindTime: '绑定时间',
|
|
252
|
+
apprenticeCount: '徒弟数量',
|
|
253
|
+
// 奖励
|
|
254
|
+
rewards: '传承奖励',
|
|
255
|
+
rewardHistory: '奖励记录',
|
|
256
|
+
noRewards: '暂无奖励',
|
|
257
|
+
totalReward: '累计奖励',
|
|
258
|
+
pendingReward: '待领取',
|
|
259
|
+
claimReward: '领取奖励',
|
|
260
|
+
// 奖励类型
|
|
261
|
+
rewardBind: '拜师奖励',
|
|
262
|
+
rewardFirstCharge: '首充分成',
|
|
263
|
+
rewardTask: '任务传承',
|
|
264
|
+
rewardDaily: '日常活跃',
|
|
265
|
+
// 表单
|
|
266
|
+
enterMentorCode: '输入师傅邀请码',
|
|
267
|
+
codePlaceholder: '请输入师傅的邀请码',
|
|
268
|
+
myCode: '我的收徒码',
|
|
269
|
+
copyCode: '复制邀请码',
|
|
270
|
+
shareCode: '分享邀请码',
|
|
271
|
+
// 提示
|
|
272
|
+
bindSuccess: '拜师成功',
|
|
273
|
+
unbindConfirm: '确定解除师徒关系?',
|
|
274
|
+
unbindSuccess: '已解除关系',
|
|
275
|
+
copySuccess: '已复制到剪贴板',
|
|
276
|
+
// 规则
|
|
277
|
+
rules: '师徒规则',
|
|
278
|
+
rule1: '每人只能拜一位师傅',
|
|
279
|
+
rule2: '徒弟完成任务,师傅获得传承奖励',
|
|
280
|
+
rule3: '徒弟首充,师傅获得分成'
|
|
281
|
+
},
|
|
282
|
+
ja: {
|
|
283
|
+
loading: '読み込み中...',
|
|
284
|
+
mentor: '師匠',
|
|
285
|
+
apprentice: '弟子',
|
|
286
|
+
mentorSystem: '師弟システム',
|
|
287
|
+
// 关系
|
|
288
|
+
myMentor: '自分の師匠',
|
|
289
|
+
myApprentices: '自分の弟子',
|
|
290
|
+
noMentor: '師匠なし',
|
|
291
|
+
noApprentices: '弟子なし',
|
|
292
|
+
// 操作
|
|
293
|
+
bindMentor: '弟子入り',
|
|
294
|
+
unbind: '関係解除',
|
|
295
|
+
inviteApprentice: '弟子を取る',
|
|
296
|
+
viewProfile: 'プロフィールを見る',
|
|
297
|
+
// 状态
|
|
298
|
+
statusActive: '正常',
|
|
299
|
+
statusExpired: '無効',
|
|
300
|
+
bindTime: '紐付け日時',
|
|
301
|
+
apprenticeCount: '弟子数',
|
|
302
|
+
// 奖励
|
|
303
|
+
rewards: '伝承報酬',
|
|
304
|
+
rewardHistory: '報酬履歴',
|
|
305
|
+
noRewards: '報酬なし',
|
|
306
|
+
totalReward: '累計報酬',
|
|
307
|
+
pendingReward: '受け取り待ち',
|
|
308
|
+
claimReward: '報酬を受け取る',
|
|
309
|
+
// 奖励类型
|
|
310
|
+
rewardBind: '弟子入り報酬',
|
|
311
|
+
rewardFirstCharge: '初回チャージ配分',
|
|
312
|
+
rewardTask: 'タスク伝承',
|
|
313
|
+
rewardDaily: 'デイリーアクティブ',
|
|
314
|
+
// 表单
|
|
315
|
+
enterMentorCode: '師匠の招待コードを入力',
|
|
316
|
+
codePlaceholder: '師匠の招待コードを入力してください',
|
|
317
|
+
myCode: '自分の弟子入りコード',
|
|
318
|
+
copyCode: '招待コードをコピー',
|
|
319
|
+
shareCode: '招待コードをシェア',
|
|
320
|
+
// 提示
|
|
321
|
+
bindSuccess: '弟子入り成功',
|
|
322
|
+
unbindConfirm: '師弟関係を解除しますか?',
|
|
323
|
+
unbindSuccess: '関係を解除しました',
|
|
324
|
+
copySuccess: 'クリップボードにコピーしました',
|
|
325
|
+
// 规则
|
|
326
|
+
rules: '師弟ルール',
|
|
327
|
+
rule1: '弟子入りできる師匠は1人だけです',
|
|
328
|
+
rule2: '弟子がタスクを完了すると、師匠に伝承報酬が与えられます',
|
|
329
|
+
rule3: '弟子の初回チャージで、師匠に配分が与えられます'
|
|
330
|
+
},
|
|
331
|
+
ko: {
|
|
332
|
+
loading: '로딩 중...',
|
|
333
|
+
mentor: '스승',
|
|
334
|
+
apprentice: '제자',
|
|
335
|
+
mentorSystem: '사제 시스템',
|
|
336
|
+
// 关系
|
|
337
|
+
myMentor: '내 스승',
|
|
338
|
+
myApprentices: '내 제자',
|
|
339
|
+
noMentor: '스승 없음',
|
|
340
|
+
noApprentices: '제자 없음',
|
|
341
|
+
// 操作
|
|
342
|
+
bindMentor: '스승 모시기',
|
|
343
|
+
unbind: '관계 해제',
|
|
344
|
+
inviteApprentice: '제자 받기',
|
|
345
|
+
viewProfile: '프로필 보기',
|
|
346
|
+
// 状态
|
|
347
|
+
statusActive: '정상',
|
|
348
|
+
statusExpired: '무효화됨',
|
|
349
|
+
bindTime: '연결 시간',
|
|
350
|
+
apprenticeCount: '제자 수',
|
|
351
|
+
// 奖励
|
|
352
|
+
rewards: '전승 보상',
|
|
353
|
+
rewardHistory: '보상 기록',
|
|
354
|
+
noRewards: '보상 없음',
|
|
355
|
+
totalReward: '누적 보상',
|
|
356
|
+
pendingReward: '수령 대기',
|
|
357
|
+
claimReward: '보상 수령',
|
|
358
|
+
// 奖励类型
|
|
359
|
+
rewardBind: '스승 모시기 보상',
|
|
360
|
+
rewardFirstCharge: '첫 충전 보상',
|
|
361
|
+
rewardTask: '과제 전승',
|
|
362
|
+
rewardDaily: '일일 활성',
|
|
363
|
+
// 表单
|
|
364
|
+
enterMentorCode: '스승의 초대 코드 입력',
|
|
365
|
+
codePlaceholder: '스승의 초대 코드를 입력하세요',
|
|
366
|
+
myCode: '내 제자 코드',
|
|
367
|
+
copyCode: '초대 코드 복사',
|
|
368
|
+
shareCode: '초대 코드 공유',
|
|
369
|
+
// 提示
|
|
370
|
+
bindSuccess: '스승 모시기 성공',
|
|
371
|
+
unbindConfirm: '사제 관계를 해제하시겠습니까?',
|
|
372
|
+
unbindSuccess: '관계가 해제되었습니다',
|
|
373
|
+
copySuccess: '클립보드에 복사되었습니다',
|
|
374
|
+
// 规则
|
|
375
|
+
rules: '사제 규칙',
|
|
376
|
+
rule1: '스승은 한 명만 모실 수 있습니다',
|
|
377
|
+
rule2: '제자가 과제를 완료하면 스승에게 전승 보상이 주어집니다',
|
|
378
|
+
rule3: '제자의 첫 충전 시 스승이 보상을 받습니다'
|
|
379
|
+
},
|
|
380
|
+
en: {
|
|
381
|
+
loading: 'Loading...',
|
|
382
|
+
mentor: 'Mentor',
|
|
383
|
+
apprentice: 'Apprentice',
|
|
384
|
+
mentorSystem: 'Mentor System',
|
|
385
|
+
myMentor: 'My Mentor',
|
|
386
|
+
myApprentices: 'My Apprentices',
|
|
387
|
+
noMentor: 'No mentor yet',
|
|
388
|
+
noApprentices: 'No apprentices yet',
|
|
389
|
+
bindMentor: 'Find a Mentor',
|
|
390
|
+
unbind: 'Remove',
|
|
391
|
+
inviteApprentice: 'Invite',
|
|
392
|
+
viewProfile: 'View Profile',
|
|
393
|
+
statusActive: 'Active',
|
|
394
|
+
statusExpired: 'Expired',
|
|
395
|
+
bindTime: 'Bound on',
|
|
396
|
+
apprenticeCount: 'Apprentices',
|
|
397
|
+
rewards: 'Rewards',
|
|
398
|
+
rewardHistory: 'Reward History',
|
|
399
|
+
noRewards: 'No rewards',
|
|
400
|
+
totalReward: 'Total Rewards',
|
|
401
|
+
pendingReward: 'Pending',
|
|
402
|
+
claimReward: 'Claim',
|
|
403
|
+
rewardBind: 'Binding Bonus',
|
|
404
|
+
rewardFirstCharge: 'First Purchase',
|
|
405
|
+
rewardTask: 'Task Reward',
|
|
406
|
+
rewardDaily: 'Daily Active',
|
|
407
|
+
enterMentorCode: 'Enter Mentor Code',
|
|
408
|
+
codePlaceholder: 'Enter mentor invitation code',
|
|
409
|
+
myCode: 'My Invite Code',
|
|
410
|
+
copyCode: 'Copy Code',
|
|
411
|
+
shareCode: 'Share Code',
|
|
412
|
+
bindSuccess: 'Successfully bound',
|
|
413
|
+
unbindConfirm: 'Remove this relationship?',
|
|
414
|
+
unbindSuccess: 'Relationship removed',
|
|
415
|
+
copySuccess: 'Copied to clipboard',
|
|
416
|
+
rules: 'Rules',
|
|
417
|
+
rule1: 'You can only have one mentor',
|
|
418
|
+
rule2: 'Earn rewards when apprentices complete tasks',
|
|
419
|
+
rule3: 'Earn commission from apprentice purchases'
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
let currentLanguage = 'zh';
|
|
423
|
+
function setLanguage(lang) {
|
|
424
|
+
if (SUPPORTED_LANGUAGES.includes(lang)) {
|
|
425
|
+
currentLanguage = lang;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
function getLanguage() {
|
|
429
|
+
return currentLanguage;
|
|
430
|
+
}
|
|
431
|
+
function t(key, params) {
|
|
432
|
+
const msgs = messages[getLanguage()] || messages.zh;
|
|
433
|
+
let text = msgs[key] || key;
|
|
434
|
+
if (params) {
|
|
435
|
+
Object.keys(params).forEach(k => {
|
|
436
|
+
text = text.replace(new RegExp(`\\{${k}\\}`, 'g'), params[k]);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
return text;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Mentor SDK - Context Provider
|
|
444
|
+
*/
|
|
445
|
+
|
|
446
|
+
const MentorContext = /*#__PURE__*/React.createContext(null);
|
|
447
|
+
function MentorProvider({
|
|
448
|
+
children,
|
|
449
|
+
apiUrl,
|
|
450
|
+
token,
|
|
451
|
+
language = 'zh',
|
|
452
|
+
onBind,
|
|
453
|
+
onReward
|
|
454
|
+
}) {
|
|
455
|
+
const [myMentor, setMyMentor] = React.useState(null);
|
|
456
|
+
const [myApprentices, setMyApprentices] = React.useState([]);
|
|
457
|
+
const [rewards, setRewards] = React.useState([]);
|
|
458
|
+
const [stats, setStats] = React.useState(null);
|
|
459
|
+
const [loading, setLoading] = React.useState(false);
|
|
460
|
+
const [error, setError] = React.useState(null);
|
|
461
|
+
React.useEffect(() => {
|
|
462
|
+
setLanguage(language);
|
|
463
|
+
}, [language]);
|
|
464
|
+
const handleError = React.useCallback(err => {
|
|
465
|
+
setError(err);
|
|
466
|
+
onError?.(err);
|
|
467
|
+
}, [onError]);
|
|
468
|
+
const bindMentor = React.useCallback(async mentorId => {
|
|
469
|
+
setLoading(true);
|
|
470
|
+
try {
|
|
471
|
+
const result = await mentorApi.bind(mentorId);
|
|
472
|
+
onBind?.(result);
|
|
473
|
+
return result;
|
|
474
|
+
} catch (err) {
|
|
475
|
+
handleError(err);
|
|
476
|
+
throw err;
|
|
477
|
+
} finally {
|
|
478
|
+
setLoading(false);
|
|
479
|
+
}
|
|
480
|
+
}, [handleError, onBind]);
|
|
481
|
+
|
|
482
|
+
// 加载我的师傅
|
|
483
|
+
const loadMyMentor = React.useCallback(async () => {
|
|
484
|
+
setLoading(true);
|
|
485
|
+
try {
|
|
486
|
+
const result = await mentorApi.getMyMentor();
|
|
487
|
+
setMyMentor(result);
|
|
488
|
+
return result;
|
|
489
|
+
} catch (err) {
|
|
490
|
+
handleError(err);
|
|
491
|
+
} finally {
|
|
492
|
+
setLoading(false);
|
|
493
|
+
}
|
|
494
|
+
}, [handleError]);
|
|
495
|
+
|
|
496
|
+
// 加载我的徒弟
|
|
497
|
+
const loadMyApprentices = React.useCallback(async (params = {}) => {
|
|
498
|
+
setLoading(true);
|
|
499
|
+
try {
|
|
500
|
+
const result = await mentorApi.getMyApprentices(params);
|
|
501
|
+
const items = result.items || result.data || result || [];
|
|
502
|
+
setMyApprentices(items);
|
|
503
|
+
return items;
|
|
504
|
+
} catch (err) {
|
|
505
|
+
handleError(err);
|
|
506
|
+
} finally {
|
|
507
|
+
setLoading(false);
|
|
508
|
+
}
|
|
509
|
+
}, [handleError]);
|
|
510
|
+
|
|
511
|
+
// 解除关系
|
|
512
|
+
const unbind = React.useCallback(async relationId => {
|
|
513
|
+
setLoading(true);
|
|
514
|
+
try {
|
|
515
|
+
await mentorApi.unbind(relationId);
|
|
516
|
+
await loadMyMentor();
|
|
517
|
+
await loadMyApprentices();
|
|
518
|
+
} catch (err) {
|
|
519
|
+
handleError(err);
|
|
520
|
+
throw err;
|
|
521
|
+
} finally {
|
|
522
|
+
setLoading(false);
|
|
523
|
+
}
|
|
524
|
+
}, [handleError, loadMyMentor, loadMyApprentices]);
|
|
525
|
+
|
|
526
|
+
// 加载奖励记录
|
|
527
|
+
const loadRewards = React.useCallback(async (params = {}) => {
|
|
528
|
+
try {
|
|
529
|
+
const result = await mentorApi.getRewards(params);
|
|
530
|
+
const items = result.items || result.data || result || [];
|
|
531
|
+
setRewards(items);
|
|
532
|
+
return items;
|
|
533
|
+
} catch (err) {
|
|
534
|
+
handleError(err);
|
|
535
|
+
}
|
|
536
|
+
}, [handleError]);
|
|
537
|
+
|
|
538
|
+
// 加载统计
|
|
539
|
+
const loadStats = React.useCallback(async () => {
|
|
540
|
+
try {
|
|
541
|
+
const result = await mentorApi.getStats();
|
|
542
|
+
setStats(result);
|
|
543
|
+
return result;
|
|
544
|
+
} catch (err) {
|
|
545
|
+
handleError(err);
|
|
546
|
+
}
|
|
547
|
+
}, [handleError]);
|
|
548
|
+
const value = {
|
|
549
|
+
myMentor,
|
|
550
|
+
myApprentices,
|
|
551
|
+
rewards,
|
|
552
|
+
stats,
|
|
553
|
+
loading,
|
|
554
|
+
error,
|
|
555
|
+
bindMentor,
|
|
556
|
+
loadMyMentor,
|
|
557
|
+
loadMyApprentices,
|
|
558
|
+
unbind,
|
|
559
|
+
loadRewards,
|
|
560
|
+
loadStats,
|
|
561
|
+
api: mentorApi
|
|
562
|
+
};
|
|
563
|
+
return /*#__PURE__*/React.createElement(MentorContext.Provider, {
|
|
564
|
+
value: value
|
|
565
|
+
}, children);
|
|
566
|
+
}
|
|
567
|
+
function useMentor() {
|
|
568
|
+
const context = React.useContext(MentorContext);
|
|
569
|
+
if (!context) {
|
|
570
|
+
throw new Error('useMentor must be used within a MentorProvider');
|
|
571
|
+
}
|
|
572
|
+
return context;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function MentorCard() {
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function BindMentorForm() {
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Mentor SDK - 类型定义
|
|
585
|
+
*/
|
|
586
|
+
|
|
587
|
+
const createDefaultRelation = {};
|
|
588
|
+
const createDefaultReward = {};
|
|
589
|
+
const MentorStatus = {};
|
|
590
|
+
const RewardType = {};
|
|
591
|
+
|
|
592
|
+
exports.BindMentorForm = BindMentorForm;
|
|
593
|
+
exports.MentorApiClient = MentorApiClient;
|
|
594
|
+
exports.MentorCard = MentorCard;
|
|
595
|
+
exports.MentorProvider = MentorProvider;
|
|
596
|
+
exports.MentorStatus = MentorStatus;
|
|
597
|
+
exports.RewardType = RewardType;
|
|
598
|
+
exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
|
|
599
|
+
exports.createDefaultRelation = createDefaultRelation;
|
|
600
|
+
exports.createDefaultReward = createDefaultReward;
|
|
601
|
+
exports.getLanguage = getLanguage;
|
|
602
|
+
exports.mentorApi = mentorApi;
|
|
603
|
+
exports.messages = messages;
|
|
604
|
+
exports.setLanguage = setLanguage;
|
|
605
|
+
exports.t = t;
|
|
606
|
+
exports.useMentor = useMentor;
|
|
607
|
+
//# sourceMappingURL=index.cjs.map
|