feat: 添加测试更新相关代码
This commit is contained in:
1 parent
24f910e12c
commit
f4e4d8c8f7
4 files changed
+53
-1
No files matched your search
@@ -5,6 +5,17 @@
|
|||||||
<el-button v-for="item in Object.entries(testFunctionList)" @click="item[1]">
|
<el-button v-for="item in Object.entries(testFunctionList)" @click="item[1]">
|
||||||
{{ item[0] }}
|
{{ item[0] }}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<div>
|
||||||
|
测试更新
|
||||||
|
<el-upload :auto-upload="false" v-model="fileList" action="/api/system/update" ref="uploadRef">
|
||||||
|
<template #trigger>
|
||||||
|
<el-button type="primary">select file</el-button>
|
||||||
|
</template>
|
||||||
|
<el-button class="ml-3" type="success" @click="submitUpload">
|
||||||
|
upload to server
|
||||||
|
</el-button>
|
||||||
|
</el-upload>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -12,11 +23,19 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import useUserStore from '~/hooks/pinia/useUserStore';
|
import useUserStore from '~/hooks/pinia/useUserStore';
|
||||||
import useMiaoFetch, { testAuth } from '~/hooks/useMiaoFetch';
|
import useMiaoFetch, { testAuth } from '~/hooks/useMiaoFetch';
|
||||||
|
import type { UploadProps, UploadUserFile } from 'element-plus'
|
||||||
|
|
||||||
const { post: { uploadPost, updatePost } } = useMiaoFetch()
|
const { post: { uploadPost, updatePost } } = useMiaoFetch()
|
||||||
|
|
||||||
|
const fileList = ref<UploadUserFile[]>([])
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
|
||||||
|
const uploadRef = ref()
|
||||||
|
|
||||||
|
const submitUpload = () => {
|
||||||
|
uploadRef.value!.submit()
|
||||||
|
}
|
||||||
|
|
||||||
const uploadTest = () => {
|
const uploadTest = () => {
|
||||||
uploadPost({
|
uploadPost({
|
||||||
title: `测试上传`,
|
title: `测试上传`,
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import { exec } from 'child_process';
|
||||||
|
|
||||||
|
export default defineEventHandler(async (event) => {
|
||||||
|
const data = await readFormData(event)
|
||||||
|
const file = data.get('file') as File
|
||||||
|
const buffer = await file.arrayBuffer()
|
||||||
|
const uint8Array = new Uint8Array(buffer)
|
||||||
|
fs.writeFileSync('./userData/test.txt', uint8Array, {
|
||||||
|
flag: 'w',
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
exec('nohup sh ./update.sh > update.nohup.log 2>&1 &')
|
||||||
|
}, 500)
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
export default defineEventHandler(async (event) => {
|
||||||
|
const data = await readFormData(event)
|
||||||
|
const file = data.get('file') as File
|
||||||
|
const buffer = await file.arrayBuffer()
|
||||||
|
const uint8Array = new Uint8Array(buffer)
|
||||||
|
fs.writeFileSync('./userData/test.txt', uint8Array, {
|
||||||
|
flag: 'w',
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -5,7 +5,8 @@ export default {
|
|||||||
'/api/test/testDir',
|
'/api/test/testDir',
|
||||||
'/api/posts/editPost',
|
'/api/posts/editPost',
|
||||||
'/api/posts/uploadPost',
|
'/api/posts/uploadPost',
|
||||||
'/api/user/updatePassword'
|
'/api/user/updatePassword',
|
||||||
|
'/api/system/update'
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user