Skip to content

Commit

Permalink
refactor: 重构部分API请求部分,统合API至统一目录 (#240)
Browse files Browse the repository at this point in the history
* 尝试对api进行整理,并对story相关api进行初步替换

* 对censor相关api进行修改

* refactor api: 为了方便调试,对请求的指向性方法修改为代理转发,并由.env控制

* refactor api: 对config路径下请求进行整合,并对相关依赖进行修改

* refactor api:对story相关api删除无用依赖

* refactor api: 对censor相关api删除无用依赖

* refactor api: 对im_connections路径下的请求进行整理并替换对应的依赖

* style(api):优化im_connection函数显示

* refactor(api):整合utils路径下的请求,并整理对应依赖项

* refactor(api):解耦im_connection路径下相关依赖,同时修改部分api函数参数

* refactor(api):整合dice路径下的请求,并整理对应依赖

* refactor(api):整合backup路径下请求,并整理相关依赖

* refactor(api):整合banconfig下的请求,并整理相关依赖

* refactor(api):整合group路径下的请求,并修改相关依赖

* refactor(api):整合牌堆管理相关请求,并整理相关依赖

* refactor(api):整合js路径下的请求,并整理相关依赖

* refactor(api):整合登陆相关请求,并修改相关依赖

* refactor(api):整合helpdoc路径请求,并整理相关依赖

* refactor(api):整合resource路径下请求,并整合相关依赖

---------

Co-authored-by: chary <[email protected]>
  • Loading branch information
charyflys and chary authored Oct 15, 2024
1 parent 3673f44 commit 84cae05
Show file tree
Hide file tree
Showing 48 changed files with 1,746 additions and 787 deletions.
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_APP_APIURL="http://localhost:6394"
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"dependencies": {
"@codemirror/lang-javascript": "^6.2.2",
"@element-plus/icons-vue": "^2.3.1",
"@types/qs": "^6.9.16",
"@vueuse/core": "^10.11.0",
"asmcrypto.js": "^2.3.2",
"axios": "^1.7.2",
Expand All @@ -28,6 +29,7 @@
"highlight.js": "^11.10.0",
"lodash-es": "^4.17.21",
"pinia": "^2.1.7",
"qs": "^6.13.0",
"randomcolor": "^0.6.2",
"vue": "^3.4.33",
"vue-diff": "^1.2.4",
Expand Down
123 changes: 123 additions & 0 deletions pnpm-lock.yaml

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

8 changes: 5 additions & 3 deletions src/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ import {CircleCloseFilled} from '@element-plus/icons-vue'
import {passwordHash} from "./utils"
import { delay, replace } from "lodash-es"
import { getNewUtils, postUtilsCheckNews } from './api/utils'
import { checkSecurity } from './api/others'
dayjs.locale('zh-cn')
dayjs.extend(relativeTime);
Expand All @@ -149,7 +151,7 @@ const newsChecked = ref(true)
const newsMark = ref('')
const checkNews = async (close: any) => {
console.log('newsMark', newsMark.value)
const ret = await store.checkNews(newsMark.value)
const ret = await postUtilsCheckNews(newsMark.value)
if (ret?.result) {
ElMessage.success('已阅读最新的海豹新闻')
} else {
Expand All @@ -159,7 +161,7 @@ const checkNews = async (close: any) => {
close()
}
const updateNews = async () => {
const newsInfo = await store.news()
const newsInfo = await getNewUtils()
if (newsInfo.result) {
newsData.value = newsInfo.news
newsChecked.value = newsInfo.checked
Expand Down Expand Up @@ -190,7 +192,7 @@ const doUnlock = async () => {
}
const checkPassword = async () => {
if (!await store.checkSecurity()) {
if (!(await checkSecurity()).isOk) {
ElMessageBox.alert('欢迎使用海豹核心。<br/>如果您的服务开启在公网,为了保证您的安全性,请前往<b>“综合设置->基本设置”</b>界面,设置<b>UI界面密码</b>。<br/>或切换为只有本机可访问。<br><b>如果您不了解上面在说什么,请务必设置一个密码</b>', '提示', {dangerouslyUseHTMLString: true})
}
}
Expand Down
48 changes: 48 additions & 0 deletions src/api/backup/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { createRequest } from "..";

const baseUrl = '/backup/'
const request = createRequest(baseUrl)

export function getBackupList() {
return request<{items:BackupInfo[]}>('get', 'list')
}

export function getBackupConfig() {
return request<BackupConfig>('get', 'config_get')
}

export function setBackupConfig(data: BackupConfig) {
return request('post', 'config_set', data)
}

export function postDoBackup(selection: number) {
return request('post', 'do_backup', { selection })
}

export function postBackupDel(name: string) {
return request<{ success: boolean }>('post', 'delete?name=' + name, { name })
}

export function postBackupBatchDel(names: string[]) {
return request<{ result: true } | {
result: false,
fails: string[],
}>('post', 'batch_delete', { names })
}

type BackupConfig = {
autoBackupEnable: boolean,
autoBackupTime: string,
autoBackupSelection: number,
backupCleanStrategy: number,
backupCleanKeepCount: number,
backupCleanKeepDur: string,
backupCleanTrigger: number,
backupCleanCron: string,
autoBackupSelectionList: string[]
}
type BackupInfo = {
name: string,
fileSize: number,
selection: number
}
Loading

0 comments on commit 84cae05

Please sign in to comment.