Skip to content

Commit

Permalink
feat(sys-client): add sys-extension-api support for client;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Dec 24, 2021
1 parent 4a39c79 commit db33a72
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 34 deletions.
2 changes: 0 additions & 2 deletions packages/system-client/.env.development
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# just a flag
ENV = 'development'

# sys api base url
VUE_APP_BASE_API_SYS = '/sys-api'
VUE_APP_APP_CONSOLE_URI = 'http://localhost:9528/app-console'
2 changes: 0 additions & 2 deletions packages/system-client/.env.production
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# just a flag
ENV = 'production'

# sys api base url
VUE_APP_BASE_API_SYS = '/sys-api'
VUE_APP_APP_CONSOLE_URI = '/app-console'
3 changes: 0 additions & 3 deletions packages/system-client/.env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@ NODE_ENV = production

# just a flag
ENV = 'staging'

# sys api base url
VUE_APP_BASE_API_SYS = '/sys-api'
52 changes: 47 additions & 5 deletions packages/system-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/system-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"copy2gw": "sh copy2gateway.sh"
},
"dependencies": {
"@types/ws": "^8.2.2",
"axios": "^0.21.1",
"bson": "^4.5.3",
"clipboard": "2.0.4",
Expand All @@ -33,7 +34,8 @@
"screenfull": "4.2.0",
"vue": "2.6.10",
"vue-router": "3.0.2",
"vuex": "3.1.0"
"vuex": "3.1.0",
"ws": "^8.4.0"
},
"devDependencies": {
"@commitlint/cli": "^12.0.1",
Expand Down Expand Up @@ -94,4 +96,4 @@
"type": "git",
"url": "git+https://github.com/Maslow/less-framework.git"
}
}
}
20 changes: 10 additions & 10 deletions packages/system-client/src/api/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import request from '@/utils/request'
*/
export function getMyApplications() {
return request({
url: '/apps/my',
url: '/sys-api/apps/my',
method: 'get'
})
}
Expand All @@ -21,7 +21,7 @@ export function getMyApplications() {
*/
export async function getApplicationByAppid(appid) {
const res = await request({
url: `/apps/${appid}`,
url: `/sys-api/apps/${appid}`,
method: 'get'
})

Expand All @@ -35,7 +35,7 @@ export async function getApplicationByAppid(appid) {
*/
export async function createApplication({ name }) {
const res = await request({
url: `/apps/create`,
url: `/sys-api/apps/create`,
method: 'post',
data: {
name
Expand All @@ -51,7 +51,7 @@ export async function createApplication({ name }) {
*/
export async function updateApplication(appid, { name }) {
const res = await request({
url: `/apps/${appid}`,
url: `/sys-api/apps/${appid}`,
method: 'post',
data: {
name
Expand All @@ -67,7 +67,7 @@ export async function updateApplication(appid, { name }) {
*/
export async function removeApplication(appid) {
const res = await request({
url: `/apps/${appid}`,
url: `/sys-api/apps/${appid}`,
method: 'delete'
})
return res
Expand All @@ -80,7 +80,7 @@ export async function removeApplication(appid) {
*/
export async function startApplicationService(appid) {
const res = await request({
url: `/apps/${appid}/service/start`,
url: `/sys-api/apps/${appid}/service/start`,
method: 'post'
})
return res
Expand All @@ -93,7 +93,7 @@ export async function startApplicationService(appid) {
*/
export async function stopApplicationService(appid) {
const res = await request({
url: `/apps/${appid}/service/stop`,
url: `/sys-api/apps/${appid}/service/stop`,
method: 'post'
})
return res
Expand All @@ -106,7 +106,7 @@ export async function stopApplicationService(appid) {
*/
export async function removeApplicationService(appid) {
const res = await request({
url: `/apps/${appid}/service/remove`,
url: `/sys-api/apps/${appid}/service/remove`,
method: 'post'
})
return res
Expand All @@ -119,7 +119,7 @@ export async function removeApplicationService(appid) {
*/
export async function exportApplication(appid) {
const res = await request({
url: `/apps/${appid}/export`,
url: `/sys-api/apps/${appid}/export`,
method: 'get',
responseType: 'blob'
})
Expand All @@ -136,7 +136,7 @@ export async function importApplication(appid, file) {
const form = new FormData()
form.append('file', file)
const res = await request({
url: `/apps/${appid}/import`,
url: `/sys-api/apps/${appid}/import`,
method: 'post',
data: form,
headers: { 'Content-Type': 'multipart/form-data' }
Expand Down
9 changes: 9 additions & 0 deletions packages/system-client/src/api/cloud.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import { getToken } from '@/utils/auth'
import { Cloud } from 'laf-client-sdk'

export const cloud = new Cloud({
baseUrl: '/sys-extension-api',
dbProxyUrl: '/proxy/system',
getAccessToken: getToken
})
8 changes: 4 additions & 4 deletions packages/system-client/src/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import request from '@/utils/request'
*/
export function login(data) {
return request({
url: '/account/login',
url: '/sys-api/account/login',
method: 'post',
data
})
Expand All @@ -20,7 +20,7 @@ export function login(data) {
*/
export function getUserProfile() {
return request({
url: '/account/profile',
url: '/sys-api/account/profile',
method: 'get'
})
}
Expand All @@ -30,7 +30,7 @@ export function getUserProfile() {
*/
export function signup(data) {
return request({
url: '/account/signup',
url: '/sys-api/account/signup',
method: 'post',
data
})
Expand All @@ -41,7 +41,7 @@ export function signup(data) {
*/
export function edit(data) {
return request({
url: '/account/edit',
url: '/sys-api/account/edit',
method: 'post',
data
})
Expand Down
1 change: 0 additions & 1 deletion packages/system-client/src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { showInfo } from './show'

// create an axios instance
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API_SYS, // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
timeout: 60000 // request timeout
})
Expand Down
11 changes: 6 additions & 5 deletions packages/system-client/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ module.exports = {
// before: require('./mock/mock-server.js'),
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API_SYS]: {
'/sys-api': {
target: 'http://console.local-dev.host:8080/',
changeOrigin: true,
// pathRewrite: {
// ['^' + process.env.VUE_APP_BASE_API_SYS]: ''
// }
changeOrigin: true
},
'/sys-extension-api': {
target: 'http://console.local-dev.host:8080/',
changeOrigin: true
}
},
disableHostCheck: true
Expand Down

0 comments on commit db33a72

Please sign in to comment.