Skip to content

Commit 671cf41

Browse files
authored
Merge pull request #226 from little3201/develop
修改mock认证
2 parents 890252a + b45e0c3 commit 671cf41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1445
-880
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
"pinia": "^2.3.1",
2121
"quasar": "^2.18.1",
2222
"vue": "^3.5.13",
23-
"vue-i18n": "^11.1.2",
23+
"vue-i18n": "^11.1.3",
2424
"vue-router": "^4.5.0"
2525
},
2626
"devDependencies": {
27-
"@eslint/js": "^9.23.0",
27+
"@eslint/js": "^9.24.0",
2828
"@lottiefiles/dotlottie-web": "^0.38.2",
2929
"@quasar/app-vite": "^2.2.0",
30-
"@types/node": "^20.17.28",
30+
"@types/node": "^20.17.30",
3131
"@vue/eslint-config-typescript": "^14.5.0",
3232
"autoprefixer": "^10.4.21",
33-
"eslint": "^9.23.0",
33+
"eslint": "^9.24.0",
3434
"eslint-plugin-vue": "^9.33.0",
3535
"globals": "^15.15.0",
3636
"msw": "^2.7.3",
@@ -43,5 +43,5 @@
4343
"public"
4444
]
4545
},
46-
"packageManager": "pnpm@9.14.4"
46+
"packageManager": "pnpm@10.8.0+sha512.0e82714d1b5b43c74610193cb20734897c1d00de89d0e18420aebc5977fa13d780a9cb05734624e81ebd81cc876cd464794850641c48b9544326b5622ca29971"
4747
}

pnpm-lock.yaml

Lines changed: 480 additions & 477 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

quasar.config.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export default defineConfig((ctx) => {
1212
// --> boot files are part of "main.js"
1313
// https://v2.quasar.dev/quasar-cli-vite/boot-files
1414
boot: [
15-
'i18n',
1615
'axios',
17-
'msw-server',
18-
'router'
16+
'i18n',
17+
'router',
18+
'msw-server'
1919
],
2020

2121
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
@@ -61,8 +61,7 @@ export default defineConfig((ctx) => {
6161
// analyze: true,
6262
env: {
6363
API: ctx.dev ? '/api' : 'https://101.42.255.156/api',
64-
CLIENT_ID: 'pkce-client',
65-
AUTHORITY_URL: 'http://127.0.0.1:8761'
64+
CLIENT_ID: 'pkce-client'
6665
},
6766
// rawDefine: {},
6867
// ignorePublicFolder: true,

src/api/authentication.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { getRandomString, generateVerifier, computeChallenge } from 'src/utils'
44

55

66
const client_id = process.env.CLIENT_ID
7-
const authorityUrl = process.env.AUTHORITY_URL
8-
97

108
export async function signIn() {
119
const state = getRandomString(16)
@@ -15,16 +13,22 @@ export async function signIn() {
1513
const codeChallenge = await computeChallenge(codeVerifier)
1614

1715
const params = new URLSearchParams({
18-
response_type: 'code',
1916
client_id: `${client_id}`,
2017
redirect_uri: `${window.location.origin}/callback`,
18+
state: state,
2119
scope: 'openid profile',
20+
response_type: 'code',
2221
code_challenge: codeChallenge,
23-
state: state,
2422
code_challenge_method: 'S256'
2523
})
2624

27-
window.location.href = `${authorityUrl}/${SERVER_URL.AUTHORIZE}?${params}`
25+
api.get(SERVER_URL.AUTHORIZE, { params }).then(res => {
26+
window.location.replace(res.request.responseURL)
27+
}).catch(error => {
28+
if (error) {
29+
window.location.replace('/login')
30+
}
31+
})
2832
}
2933

3034
export function handleCallback() {
@@ -46,28 +50,29 @@ export function handleCallback() {
4650
}
4751

4852
const params = new URLSearchParams({
49-
grant_type: 'authorization_code',
5053
client_id: `${client_id}`,
51-
code: code,
5254
redirect_uri: `${window.location.origin}/callback`,
55+
state: state,
56+
code: code,
5357
code_verifier: codeVerifier,
54-
state: state
58+
grant_type: 'authorization_code'
5559
})
5660
// Exchange authorization code for access token
57-
return api.post(`${authorityUrl}/${SERVER_URL.TOKEN}`, params)
61+
return api.post(SERVER_URL.TOKEN, params)
5862
}
5963

6064
export function getSub() {
61-
return api.get(`${authorityUrl}/${SERVER_URL.USERINFO}`)
65+
return api.get(SERVER_URL.USERINFO)
6266
}
6367

64-
export function signOut() {
65-
const idTokenHint = localStorage.getItem('id_token_hint')
68+
export function signOut(idToken: string) {
6669
const params = new URLSearchParams({
67-
id_token_hint: `${idTokenHint}`,
70+
id_token_hint: idToken,
6871
client_id: `${client_id}`,
6972
post_logout_redirect_uri: `${window.location.origin}`
7073
})
7174

72-
window.location.href = `${authorityUrl}/${SERVER_URL.LOGOUT}?${params}`
75+
api.post(SERVER_URL.LOGOUT, params).then(res => {
76+
window.location.replace(res.request.responseURL)
77+
})
7378
}

src/api/dictionaries.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,12 @@ export const modifyDictionary = (id: number, row: Dictionary) => {
6565
export const removeDictionary = (id: number) => {
6666
return api.delete(`${SERVER_URL.DICTIONARY}/${id}`)
6767
}
68+
69+
/**
70+
* Enable or Disable an existing row
71+
* @param id Row ID
72+
* @returns Enable or Disable result
73+
*/
74+
export const enableDictionary = (id: number) => {
75+
return api.patch(`${SERVER_URL.DICTIONARY}/${id}`)
76+
}

src/api/files.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ export const retrieveFiles = (pagination: Pagination, filters?: object) => {
1212
return api.get(SERVER_URL.FILE, { params: { ...pagination, page: pagination.page - 1, ...filters } })
1313
}
1414

15-
/**
16-
* Fetch a specific row
17-
* @param id Row ID
18-
* @returns Row data
19-
*/
20-
export const fetchFile = (id: number) => {
21-
return api.get(`${SERVER_URL.FILE}/${id}`)
22-
}
23-
2415
/**
2516
* Upload
2617
* @param row Row data

src/api/groups.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,27 @@ export const removeGroup = (id: number) => {
7474
return api.delete(`${SERVER_URL.GROUP}/${id}`)
7575
}
7676

77+
/**
78+
* Relation members for a row
79+
* @param id Row ID
80+
* @param usernames usernames
81+
* @returns Related status
82+
*/
83+
export const relationGroupMembers = (id: number, usernames: string[]) => {
84+
return api.patch(`${SERVER_URL.GROUP}/${id}/members`, usernames)
85+
}
86+
87+
/**
88+
* Remove members for a row
89+
* @param id Row ID
90+
* @param usernames usernames
91+
* @returns Deletion status
92+
*/
93+
export const removeGroupMembers = (id: number, usernames: number[]) => {
94+
const params = usernames ? { privilegeIds: usernames.join(',') } : {}
95+
return api.delete(`${SERVER_URL.GROUP}/${id}/members`, { params })
96+
}
97+
7798
/**
7899
* Relation privileges for a row
79100
* @param id Row ID

src/api/privileges.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { api } from 'boot/axios'
22
import { SERVER_URL } from 'src/constants'
3-
import type { Pagination } from 'src/types'
3+
import type { Pagination, Privilege } from 'src/types'
44

55
/**
66
* Retrieve rows
@@ -38,3 +38,22 @@ export const retrievePrivilegeTree = () => {
3838
export const fetchPrivilege = (id: number) => {
3939
return api.get(`${SERVER_URL.PRIVILEGE}/${id}`)
4040
}
41+
42+
/**
43+
* Modify an existing row
44+
* @param id Row ID
45+
* @param data Updated row data
46+
* @returns Modified row
47+
*/
48+
export const modifyPrivilege = (id: number, row: Privilege) => {
49+
return api.put(`${SERVER_URL.PRIVILEGE}/${id}`, row)
50+
}
51+
52+
/**
53+
* Enable or Disable an existing row
54+
* @param id Row ID
55+
* @returns Enable or Disable result
56+
*/
57+
export const enablePrivilege = (id: number) => {
58+
return api.patch(`${SERVER_URL.PRIVILEGE}/${id}`)
59+
}

src/api/regions.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ export const retrieveRegions = (pagination: Pagination, filters?: object) => {
1313
return api.get(SERVER_URL.REGION, { params: { ...pagination, page: pagination.page - 1, ...filters } })
1414
}
1515

16+
/**
17+
* Get row subset
18+
* @param id Row ID
19+
* @returns Subset data
20+
*/
21+
export const retrieveRegionSubset = (id: number) => {
22+
return api.get(`${SERVER_URL.REGION}/${id}/subset`)
23+
}
24+
1625
/**
1726
* Fetch a specific row
1827
* @param id Row ID
@@ -41,6 +50,15 @@ export const modifyRegion = (id: number, row: Region) => {
4150
return api.put(`${SERVER_URL.REGION}/${id}`, row)
4251
}
4352

53+
/**
54+
* Enable or Disable an existing row
55+
* @param id Row ID
56+
* @returns Enable or Disable result
57+
*/
58+
export const enableRegion = (id: number) => {
59+
return api.patch(`${SERVER_URL.REGION}/${id}`)
60+
}
61+
4462
/**
4563
* Remove a row
4664
* @param id Row ID

src/api/scripts.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { api } from 'boot/axios'
2+
import { SERVER_URL } from 'src/constants'
3+
4+
/**
5+
* Retrieve rows
6+
* @param filters Optional filter or sort parameters
7+
* @returns Rows data
8+
*/
9+
export const retrieveScripts = () => {
10+
return api.get(SERVER_URL.SCRIPT)
11+
}
12+
13+
/**
14+
* Fetch a specific row
15+
* @param id Row ID
16+
* @returns Row data
17+
*/
18+
export const fetchScript = (id: number) => {
19+
return api.get(`${SERVER_URL.SCRIPT}/${id}`)
20+
}

0 commit comments

Comments
 (0)