Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Clash Verge
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Clash Verge
Commits
4bb9e109
There was an error fetching the commit references. Please try again later.
Commit
4bb9e109
authored
3 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: add some clash api
parent
433716cf
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/pages/log.tsx
+19
-1
19 additions, 1 deletion
src/pages/log.tsx
src/services/common.ts
+56
-0
56 additions, 0 deletions
src/services/common.ts
src/services/index.ts
+2
-0
2 additions, 0 deletions
src/services/index.ts
with
77 additions
and
1 deletion
src/pages/log.tsx
+
19
−
1
View file @
4bb9e109
import
{
useEffect
}
from
"
react
"
;
import
{
Box
,
Typography
}
from
"
@mui/material
"
;
import
services
from
"
../services
"
;
const
LogPage
=
()
=>
{
const
LogPage
=
()
=>
{
return
<
h1
>
Log
</
h1
>;
useEffect
(()
=>
{
const
sourcePromise
=
services
.
getLogs
(
console
.
log
);
return
()
=>
{
sourcePromise
.
then
((
src
)
=>
src
.
cancel
());
};
},
[]);
return
(
<
Box
sx
=
{
{
width
:
0.9
,
maxWidth
:
"
850px
"
,
mx
:
"
auto
"
,
mb
:
2
}
}
>
<
Typography
variant
=
"h4"
component
=
"h1"
sx
=
{
{
py
:
2
}
}
>
Logs
</
Typography
>
</
Box
>
);
};
};
export
default
LogPage
;
export
default
LogPage
;
This diff is collapsed.
Click to expand it.
src/services/common.ts
0 → 100644
+
56
−
0
View file @
4bb9e109
import
axios
from
"
axios
"
;
import
axiosIns
from
"
./base
"
;
/// Get Version
export
async
function
getVersion
()
{
return
axiosIns
.
get
(
"
/version
"
)
as
Promise
<
{
premium
:
boolean
;
version
:
string
;
}
>
;
}
export
interface
ConfigType
{
port
:
number
;
mode
:
string
;
"
socket-port
"
:
number
;
"
allow-lan
"
:
boolean
;
"
log-level
"
:
string
;
"
mixed-port
"
:
number
;
}
/// Get current base configs
export
async
function
getConfigs
()
{
return
axiosIns
.
get
(
"
/configs
"
)
as
Promise
<
ConfigType
>
;
}
/// Update current configs
export
async
function
updateConfigs
(
config
:
Partial
<
ConfigType
>
)
{
return
axiosIns
.
patch
(
"
/configs
"
,
config
);
}
interface
RuleItem
{
type
:
string
;
payload
:
string
;
proxy
:
string
;
}
/// Get current rules
export
async
function
getRules
()
{
return
axiosIns
.
get
(
"
/rules
"
)
as
Promise
<
RuleItem
[]
>
;
}
/// Get logs stream
export
async
function
getLogs
(
callback
:
(
t
:
any
)
=>
void
)
{
const
source
=
axios
.
CancelToken
.
source
();
axiosIns
.
get
(
"
/logs
"
,
{
cancelToken
:
source
.
token
,
onDownloadProgress
:
(
progressEvent
)
=>
{
const
data
=
progressEvent
.
currentTarget
.
response
||
""
;
const
lastData
=
data
.
slice
(
data
.
trim
().
lastIndexOf
(
"
\n
"
)
+
1
);
callback
(
JSON
.
parse
(
lastData
));
},
});
return
source
;
}
This diff is collapsed.
Click to expand it.
src/services/index.ts
+
2
−
0
View file @
4bb9e109
import
*
as
common
from
"
./common
"
;
import
*
as
proxy
from
"
./proxy
"
;
import
*
as
proxy
from
"
./proxy
"
;
import
*
as
traffic
from
"
./traffic
"
;
import
*
as
traffic
from
"
./traffic
"
;
export
default
{
export
default
{
...
common
,
...
proxy
,
...
proxy
,
...
traffic
,
...
traffic
,
};
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment