Skip to content

Commit

Permalink
Merge pull request #33 from OVINC-CN/feat_wxpay
Browse files Browse the repository at this point in the history
feat: wxpay
  • Loading branch information
OrenZhang authored Jul 2, 2024
2 parents 8aab7c1 + 670f21f commit ad825bf
Show file tree
Hide file tree
Showing 8 changed files with 408 additions and 51 deletions.
376 changes: 338 additions & 38 deletions src/App.vue

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/api/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ export const preCheckAPI = (data) => new Promise((resolve, reject) => {
(err) => reject(err),
);
});

export const getChatLogs = (params) => new Promise((resolve, reject) => {
http.get('/chat/logs/', {params}).then(
(res) => resolve(res),
(err) => reject(err),
);
});
7 changes: 0 additions & 7 deletions src/api/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ export const listModelsAPI = () => new Promise((resolve, reject) => {
);
});

export const checkModelPermissionAPI = (model) => new Promise((resolve, reject) => {
http.get(`/models/check/?model=${model}`).then(
(res) => resolve(res),
(err) => reject(err),
);
});

export const listSystemPresetAPI = () => new Promise((resolve, reject) => {
http.get('/system_presets/').then(
(res) => resolve(res),
Expand Down
22 changes: 22 additions & 0 deletions src/api/wallet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import http from './index';

export const getMyWalletAPI = () => new Promise((resolve, reject) => {
http.get('/wallets/mine/').then(
(res) => resolve(res),
(err) => reject(err),
);
});

export const getWalletConfigAPI = () => new Promise((resolve, reject) => {
http.get('/wallets/config/').then(
(res) => resolve(res),
(err) => reject(err),
);
});

export const getPreChargeAPI = (amount) => new Promise((resolve, reject) => {
http.post('/wallets/pre_charge/', {amount}).then(
(res) => resolve(res),
(err) => reject(err),
);
});
3 changes: 3 additions & 0 deletions src/components/ChatInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ const doChat = async () => {
}, (err) => {
emits('setChatLoading', false);
Message.error(err.response.data.message);
if (err.response.status === 403) {
store.commit('setUserInfoVisible', true);
}
});
if (!key) {
return;
Expand Down
16 changes: 16 additions & 0 deletions src/locale/en-us.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ const mEnUS = {
Tools: 'Tools',
ToolUseTips: 'Some models do not support tool, if the output does not meet expectations, please switch models',
PleaseChooseTool: 'Please choose tool',
UserInfo: 'User Info',
Username: 'Usernsme',
Balance: 'Balance',
ModelName: 'Model',
PromptTokens: 'Prompt Tokens',
CompletionTokens: 'Completion Tokens',
Price: 'Price',
RequestTime: 'Time',
ChatHistory: 'Chat History',
Charge: 'Charge',
Refresh: 'Refresh',
Amount: 'Amount',
Cancel: 'Cancel',
WeChatScan: 'Use WeChat to Scan',
FinishCharge: 'Pay Success',
Tokens: 'Tokens',
};

export default mEnUS;
16 changes: 16 additions & 0 deletions src/locale/zh-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ const mZhCN = {
Tools: '插件',
ToolUseTips: '部分模型不支持插件,如果输出不符合预期,请切换模型',
PleaseChooseTool: '请选择插件',
UserInfo: '用户信息',
Username: '用户名',
Balance: '余额',
ModelName: '模型',
PromptTokens: '提示令牌数',
CompletionTokens: '响应令牌数',
Price: '计费',
RequestTime: '请求时间',
ChatHistory: '历史计费',
Charge: '充值',
Refresh: '刷新',
Amount: '金额',
Cancel: '取消',
WeChatScan: '微信扫码',
FinishCharge: '完成支付',
Tokens: '令牌数',
};

export default mZhCN;
12 changes: 6 additions & 6 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {createStore} from 'vuex';
import {getUserInfoAPI} from '../api/user';
import {listModelsAPI} from '../api/model';
import router from '../router';
import {getUserInfoAPI} from '@/api/user';
import {listModelsAPI} from '@/api/model';

const store = createStore({
state() {
Expand All @@ -14,6 +13,7 @@ const store = createStore({
last_login: '',
user_type: '',
},
userInfoVisible: false,
userProperties: {
avatar: null,
phone_number: null,
Expand All @@ -25,6 +25,9 @@ const store = createStore({
};
},
mutations: {
setUserInfoVisible(state, payload) {
state.userInfoVisible = payload;
},
setMainLoading(state, payload) {
state.mainLoading = payload;
},
Expand All @@ -42,9 +45,6 @@ const store = createStore({
},
setModels(state, payload) {
state.models = payload;
if (!payload.length) {
router.push({name: 'PermissionDenied'});
}
},
setCurrentModel(state, payload) {
state.currentModel = payload;
Expand Down

0 comments on commit ad825bf

Please sign in to comment.