新增客户端下载地址

This commit is contained in:
kuaifan 2021-08-29 11:21:04 +08:00
parent 729befb55f
commit 2939a6beb2
10 changed files with 412 additions and 2 deletions

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
use App\Models\User;
use App\Module\Base;
use Request;
use Response;
/**
* @apiDefine system
@ -196,6 +197,81 @@ class SystemController extends AbstractController
return Base::getIpInfo(Request::input("ip"));
}
/**
* @api {get} api/system/get/appinfo 06. 获取应用下载信息
*
* @apiVersion 1.0.0
* @apiGroup system
* @apiName get__appinfo
*
* @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function get__appinfo() {
$array = [
'name' => '',
'version' => '',
'list' => [],
];
//
$file = base_path("electron/package.json");
$dist = base_path("electron/dist");
if (file_exists($file)) {
$packageArray = json_decode(file_get_contents($file), true);
$array['name'] = $packageArray['name'] ?? 'No app';
$array['version'] = $packageArray['version'] ?? '';
//
$list = [
[
'icon' => 'logo-apple',
'name' => 'macOS Intel',
'file' => "{$array['name']}-{$array['version']}-mac.zip"
],
[
'icon' => 'logo-apple',
'name' => 'macOS M1',
'file' => "{$array['name']}-{$array['version']}-arm64-mac.zip"
],
[
'icon' => 'logo-windows',
'name' => 'Windows x64',
'file' => "{$array['name']} Setup {$array['version']}.exe"
]
];
foreach ($list as $item) {
if (file_exists("{$dist}/{$item['file']}")) {
$item['url'] = Base::fillUrl('api/system/get/appdown?file=' . urlencode($item['file']));
$item['size'] = filesize("{$dist}/{$item['file']}");
$array['list'][] = $item;
}
}
}
//
if (count($array['list']) == 0) {
return Base::retError('No file');
}
return Base::retSuccess('success', $array);
}
/**
* @api {get} api/system/get/appdown 06. 下载应用
*
* @apiVersion 1.0.0
* @apiGroup system
* @apiName get__appdown
*
* @apiParam {String} file 文件名称
*/
public function get__appdown() {
$file = Request::input("file");
$path = base_path("electron/dist/" . $file);
if (!file_exists($path)) {
return Base::ajaxError("No file");
}
return Response::download($path);
}
/**
* @api {post} api/system/imgupload 10. 上传图片
*

View File

@ -1,6 +1,6 @@
{
"name": "DooTask",
"version": "0.3.4",
"version": "0.3.10",
"description": "DooTask is task management system.",
"main": "main.js",
"license": "MIT",

View File

@ -0,0 +1,59 @@
<template>
<div class="page-download">
<PageTitle :title="$L('下载')"/>
<div v-if="loadIng > 0" class="download-load">
<Loading/>
</div>
<div class="download-body">
<canvas class="orb-canvas-1"></canvas>
<canvas class="orb-canvas-2"></canvas>
<div v-if="name" class="download-name">{{name}}</div>
<div v-if="version" class="download-version">v{{version}}</div>
<ul v-if="list.length > 0" class="download-list">
<li v-for="(item, key) in list" :key="key">
<div class="app-icon">
<Icon :type="item.icon"/>
</div>
<div class="app-name">{{item.name}}</div>
<div class="app-size">{{$A.bytesToSize(item.size)}}</div>
<div class="app-button">
<a :href="item.url" target="_blank">{{$L('立即下载')}}</a>
</div>
</li>
</ul>
</div>
</div>
</template>
<script>
export default {
data() {
return {
loadIng: 0,
name: "Loading",
version: "",
list: []
}
},
mounted() {
this.getAppInfo()
},
methods: {
getAppInfo() {
this.loadIng++;
this.$store.dispatch("call", {
url: 'system/get/appinfo',
}).then(({data}) => {
this.loadIng--;
this.name = data.name;
this.version = data.version;
this.list = data.list;
}).catch(({msg}) => {
this.loadIng--;
$A.modalError(msg);
});
}
}
}
</script>

View File

@ -38,6 +38,9 @@
<div class="login-forgot">{{$L('忘记密码了?')}}<a href="javascript:void(0)" @click="forgotPassword">{{$L('重置密码')}}</a></div>
</div>
</div>
<div v-if="downList.length > 0" class="download-app">
<Button icon="md-download" type="primary" to="./download" target="_blank">{{$L('客户端下载')}}</Button>
</div>
</div>
</template>
@ -55,6 +58,13 @@ export default {
password: '',
password2: '',
code: '',
downList: []
}
},
mounted() {
if (!this.isElectron) {
this.getAppInfo();
}
},
computed: {
@ -63,6 +73,14 @@ export default {
}
},
methods: {
getAppInfo() {
this.$store.dispatch("call", {
url: 'system/get/appinfo',
}).then(({data}) => {
this.downList = data.list;
});
},
forgotPassword() {
$A.modalWarning("请联系管理员!");
},

View File

@ -91,6 +91,9 @@
</ul>
</template>
</div>
<div v-if="downList.length > 0" class="download-app">
<Button icon="md-download" type="primary" @click="goDownApp">{{$L('客户端下载')}}</Button>
</div>
</div>
</template>
@ -107,7 +110,9 @@ export default {
active: false,
dashboard: 'today',
taskLoad: {}
taskLoad: {},
downList: []
}
},
@ -115,6 +120,9 @@ export default {
this.nowInterval = setInterval(() => {
this.nowTime = Math.round(new Date().getTime() / 1000);
}, 1000)
if (!this.isElectron) {
this.getAppInfo();
}
},
destroyed() {
@ -206,6 +214,18 @@ export default {
},
methods: {
getAppInfo() {
this.$store.dispatch("call", {
url: 'system/get/appinfo',
}).then(({data}) => {
this.downList = data.list;
});
},
goDownApp() {
this.goForward({path: '/manage/download'});
},
getTask() {
let data = {complete: "no"};
switch (this.dashboard) {

View File

@ -68,8 +68,18 @@ export default [
path: 'file',
component: () => import('./pages/manage/file.vue'),
},
{
name: 'manage-download',
path: 'download',
component: () => import('./pages/download.vue'),
},
]
},
{
name: 'download',
path: '/download',
component: () => import('./pages/download.vue'),
},
{
name: 'login',
path: '/login',

View File

@ -1,6 +1,7 @@
@import "common";
@import "page-calendar";
@import "page-dashboard";
@import "page-download";
@import "page-file";
@import "page-login";
@import "page-manage";

View File

@ -149,6 +149,12 @@
}
}
}
.download-app {
position: absolute;
bottom: 26px;
right: 26px;
z-index: 1;
}
.nopage {
width: 100%;
height: 100%;

View File

@ -0,0 +1,214 @@
.page-download {
overflow: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
.download-load {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
}
.download-body {
position: relative;
margin-top: 50px;
.orb-canvas-1 {
position: absolute;
top: 0;
left: 50%;
width: 500px;
height: 500px;
z-index: -1;
background: linear-gradient(rgba(186, 117, 255, 0.49) 26.56%, rgb(57, 19, 184) 100%);
opacity: .1;
transform: translate(-50%, 0) rotate(-90deg);
margin-top: 20px;
margin-left: -50px;
border-radius: 24% 76% 35% 65% / 27% 36% 64% 73%;
}
.orb-canvas-2 {
position: absolute;
top: 0;
left: 50%;
width: 500px;
height: 500px;
background: linear-gradient(rgba(47, 184, 255, 0.42) 31.77%, rgb(158, 236, 217) 100%);
z-index: -1;
animation: 25s ease 0s infinite alternate none running izRuqW;
opacity: .1;
transform: translate(-50%, 0) rotate(-90deg);
margin-top: 120px;
margin-left: 50px;
border-radius: 51% 49% 58% 42% / 34% 78% 22% 66%;
}
.download-name {
color: #2A2A2A;
text-align: center;
font-size: 24px;
padding-top: 64px;
line-height: 1;
}
.download-version {
color: #8a919c;
text-align: center;
font-size: 14px;
padding-top: 20px;
line-height: 1;
}
.download-list {
margin-top: 100px;
display: flex;
align-items: center;
justify-content: center;
> li {
display: flex;
flex-direction: column;
align-items: center;
list-style: none;
background: rgba(255,255,255,.7);
border-radius: 20px;
overflow: hidden;
margin: 0 12px;
padding: 30px 46px;
position: relative;
z-index: 5;
box-shadow: 0 30px 70px 0 rgba(223, 227, 234, 0.5);
.app-icon,
.app-name,
.app-size {
transition: all 0.3s ease-in-out;
}
.app-icon {
display: flex;
align-items: center;
justify-content: center;
height: 60px;
> i {
font-size: 60px;
&.ivu-icon-logo-windows {
font-size: 52px;
}
}
}
.app-name {
margin-top: 15px;
font-size: 18px;
}
.app-size {
margin-top: 15px;
opacity: 0.6;
}
.app-button {
margin-top: 22px;
> a {
display: inline-block;
position: relative;
z-index: 1;
line-height: 32px;
border-radius: 6px;
text-align: center;
padding: 0 18px;
text-transform: capitalize;
transition: all 0.3s ease-in-out;
color: #8bcf70;
border: 1px solid #8bcf70;
&:before {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
border-radius: 36px;
transition: all 0.3s ease-in-out;
transform: scale(0,1);
z-index: -1;
}
&:hover {
&:before {
border-radius: 4px;
background: #ffffff;
transform: scale(1);
}
}
}
}
&:before {
content: '';
position: absolute;
z-index: -1;
width: 100%;
height: 100%;
top:0;
left:0;
background: linear-gradient( 130deg, rgb(131,239,146) 0%, rgb(0,211,139) 100%);
opacity: 0;
transition: all 0.3s ease-in-out;
}
&:after {
content: '';
position: absolute;
width: 160px;
height: 160px;
border-radius: 50%;
background: rgba(255,255,255,0.13);
z-index: -1;
top:-80px;
right: -80px;
opacity: 0;
transform: scale(0.2);
transition: all 0.3s ease-in-out;
}
&:hover {
.app-icon,
.app-name,
.app-size {
color: #ffffff
}
.app-button {
> a {
color: #ffffff;
border-color: #ffffff;
&:hover {
color: #0de49d;
}
}
}
&:before {
opacity: 1;
}
&:after {
opacity: 1;
transform: scale(1);
transition-duration: 1s;
}
}
}
@media (max-width: 720px) {
flex-direction: column;
> li {
padding: 52px 64px;
margin-bottom: 32px;
}
}
}
}
&.manage-box-view {
display: flex;
align-items: center;
justify-content: center;
.download-body {
transform: translateY(-16%);
.download-name {
padding-top: 16%;
}
}
}
}

View File

@ -104,4 +104,10 @@
}
}
}
.download-app {
position: absolute;
bottom: 26px;
right: 26px;
z-index: 1;
}
}