mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-29 00:30:44 +00:00
perf: 文件消息新增显示文件菜单
This commit is contained in:
parent
954f1be44d
commit
06815b4b8c
@ -164,6 +164,7 @@ class FileController extends AbstractController
|
|||||||
* @apiGroup file
|
* @apiGroup file
|
||||||
* @apiName search
|
* @apiName search
|
||||||
*
|
*
|
||||||
|
* @apiParam {String} [link] 通过分享地址搜索(如:https://t.hitosea.com/single/file/ODcwOCwzOSxpa0JBS2lmVQ==)
|
||||||
* @apiParam {String} [key] 关键词
|
* @apiParam {String} [key] 关键词
|
||||||
*
|
*
|
||||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||||
@ -174,28 +175,42 @@ class FileController extends AbstractController
|
|||||||
{
|
{
|
||||||
$user = User::auth();
|
$user = User::auth();
|
||||||
//
|
//
|
||||||
|
$link = trim(Request::input('link'));
|
||||||
$key = trim(Request::input('key'));
|
$key = trim(Request::input('key'));
|
||||||
|
$id = 0;
|
||||||
|
$take = 50;
|
||||||
|
if (preg_match("/\/single\/file\/(.*?)$/i", $link, $match)) {
|
||||||
|
$id = intval(FileLink::whereCode($match[1])->value('file_id'));
|
||||||
|
$take = 1;
|
||||||
|
}
|
||||||
// 搜索自己的
|
// 搜索自己的
|
||||||
$builder = File::whereUserid($user->userid);
|
$builder = File::whereUserid($user->userid);
|
||||||
|
if ($id) {
|
||||||
|
$builder->where("id", $id);
|
||||||
|
}
|
||||||
if ($key) {
|
if ($key) {
|
||||||
$builder->where("name", "like", "%{$key}%");
|
$builder->where("name", "like", "%{$key}%");
|
||||||
}
|
}
|
||||||
$array = $builder->take(50)->get()->toArray();
|
$array = $builder->take($take)->get()->toArray();
|
||||||
// 搜索共享的
|
// 搜索共享的
|
||||||
$take = 50 - count($array);
|
$take = $take - count($array);
|
||||||
if ($take > 0 && $key) {
|
if ($take > 0 && ($id || $key)) {
|
||||||
$list = File::where("name", "like", "%{$key}%")
|
$builder = File::whereIn('pshare', function ($queryA) use ($user) {
|
||||||
->whereIn('pshare', function ($queryA) use ($user) {
|
$queryA->select('files.id')
|
||||||
$queryA->select('files.id')
|
->from('files')
|
||||||
->from('files')
|
->join('file_users', 'files.id', '=', 'file_users.file_id')
|
||||||
->join('file_users', 'files.id', '=', 'file_users.file_id')
|
->where('files.userid', '!=', $user->userid)
|
||||||
->where('files.userid', '!=', $user->userid)
|
->where(function ($queryB) use ($user) {
|
||||||
->where(function ($queryB) use ($user) {
|
$queryB->whereIn('file_users.userid', [0, $user->userid]);
|
||||||
$queryB->whereIn('file_users.userid', [0, $user->userid]);
|
});
|
||||||
});
|
});
|
||||||
})
|
if ($id) {
|
||||||
->take($take)
|
$builder->where("id", $id);
|
||||||
->get();
|
}
|
||||||
|
if ($key) {
|
||||||
|
$builder->where("name", "like", "%{$key}%");
|
||||||
|
}
|
||||||
|
$list = $builder->take($take)->get();
|
||||||
if ($list->isNotEmpty()) {
|
if ($list->isNotEmpty()) {
|
||||||
foreach ($list as $file) {
|
foreach ($list as $file) {
|
||||||
$temp = $file->toArray();
|
$temp = $file->toArray();
|
||||||
|
|||||||
@ -643,7 +643,8 @@ export default {
|
|||||||
'wsOpenNum',
|
'wsOpenNum',
|
||||||
'touchBackInProgress',
|
'touchBackInProgress',
|
||||||
'dialogIns',
|
'dialogIns',
|
||||||
'cacheUserBasic'
|
'cacheUserBasic',
|
||||||
|
'fileLinks'
|
||||||
]),
|
]),
|
||||||
|
|
||||||
...mapGetters(['isLoad']),
|
...mapGetters(['isLoad']),
|
||||||
@ -2006,6 +2007,9 @@ export default {
|
|||||||
value: $A.rightDelete(event.target.currentSrc, '_thumb.jpg'),
|
value: $A.rightDelete(event.target.currentSrc, '_thumb.jpg'),
|
||||||
})
|
})
|
||||||
} else if (event.target.nodeName === 'A') {
|
} else if (event.target.nodeName === 'A') {
|
||||||
|
if (event.target.classList.contains("mention") && event.target.classList.contains("file")) {
|
||||||
|
this.findOperateFile(this.operateItem.id, event.target.href)
|
||||||
|
}
|
||||||
this.operateCopys.push({
|
this.operateCopys.push({
|
||||||
type: 'link',
|
type: 'link',
|
||||||
icon: '',
|
icon: '',
|
||||||
@ -2147,7 +2151,10 @@ export default {
|
|||||||
url: value,
|
url: value,
|
||||||
token: false
|
token: false
|
||||||
})
|
})
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'filepos':
|
||||||
|
this.goForward({name: 'manage-file', params: value});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'link':
|
case 'link':
|
||||||
@ -2552,6 +2559,47 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
findOperateFile(msgId, link) {
|
||||||
|
const file = this.fileLinks.find(item => item.link === link)
|
||||||
|
if (file) {
|
||||||
|
this.addFileMenu(msgId, file)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.$store.dispatch("searchFiles", {
|
||||||
|
link
|
||||||
|
}).then(({data}) => {
|
||||||
|
if (data.length === 1) {
|
||||||
|
const file = {
|
||||||
|
link,
|
||||||
|
id: data[0].id,
|
||||||
|
pid: data[0].pid,
|
||||||
|
}
|
||||||
|
this.fileLinks.push(file)
|
||||||
|
this.addFileMenu(msgId, file)
|
||||||
|
}
|
||||||
|
}).catch(_ => {})
|
||||||
|
},
|
||||||
|
|
||||||
|
addFileMenu(msgId, data) {
|
||||||
|
if (this.operateItem.id != msgId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.operateCopys.findIndex(item => item.type === 'filepos') !== -1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const index = Math.max(0, this.operateCopys.findIndex(item => item.type === 'link') - 1)
|
||||||
|
this.operateCopys.splice(index, 0, {
|
||||||
|
type: 'filepos',
|
||||||
|
icon: '',
|
||||||
|
label: '显示文件',
|
||||||
|
value: {
|
||||||
|
folderId: data.pid,
|
||||||
|
fileId: null,
|
||||||
|
shakeId: data.id
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
getBase64Image(url) {
|
getBase64Image(url) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
let canvas = document.createElement('CANVAS'),
|
let canvas = document.createElement('CANVAS'),
|
||||||
|
|||||||
@ -927,6 +927,7 @@ export default {
|
|||||||
this.$store.dispatch("getFiles", this.pid).then(async () => {
|
this.$store.dispatch("getFiles", this.pid).then(async () => {
|
||||||
this.loadIng--;
|
this.loadIng--;
|
||||||
this.openFileJudge()
|
this.openFileJudge()
|
||||||
|
this.shakeFile(this.$route.params.shakeId);
|
||||||
await $A.IDBSet("fileFolderId", this.pid)
|
await $A.IDBSet("fileFolderId", this.pid)
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
this.loadIng--;
|
this.loadIng--;
|
||||||
@ -997,9 +998,9 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
browseFolder(id) {
|
browseFolder(id, shakeId = null) {
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
this.goForward({name: 'manage-file', params: {folderId: id, fileId: null}});
|
this.goForward({name: 'manage-file', params: {folderId: id, fileId: null, shakeId}});
|
||||||
} else {
|
} else {
|
||||||
this.searchKey = '';
|
this.searchKey = '';
|
||||||
this.goForward({name: 'manage-file'});
|
this.goForward({name: 'manage-file'});
|
||||||
@ -1152,7 +1153,7 @@ export default {
|
|||||||
|
|
||||||
case 'upperFolder':
|
case 'upperFolder':
|
||||||
this.searchKey = '';
|
this.searchKey = '';
|
||||||
this.browseFolder(item.pid)
|
this.browseFolder(item.pid, item.id)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'select':
|
case 'select':
|
||||||
@ -1624,6 +1625,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
shakeFile(fileId) {
|
shakeFile(fileId) {
|
||||||
|
if (!fileId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.$nextTick(_ => {
|
this.$nextTick(_ => {
|
||||||
const dom = $A(this.$el).find(`[data-id="${fileId}"]`)
|
const dom = $A(this.$el).find(`[data-id="${fileId}"]`)
|
||||||
if (dom.length > 0) {
|
if (dom.length > 0) {
|
||||||
|
|||||||
11
resources/assets/js/store/actions.js
vendored
11
resources/assets/js/store/actions.js
vendored
@ -747,16 +747,17 @@ export default {
|
|||||||
* 搜索文件
|
* 搜索文件
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param key
|
* @param data
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
searchFiles({state, dispatch}, key) {
|
searchFiles({state, dispatch}, data) {
|
||||||
|
if (!$A.isJson(data)) {
|
||||||
|
data = {key: data}
|
||||||
|
}
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'file/search',
|
url: 'file/search',
|
||||||
data: {
|
data,
|
||||||
key,
|
|
||||||
},
|
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
dispatch("saveFile", result.data);
|
dispatch("saveFile", result.data);
|
||||||
resolve(result)
|
resolve(result)
|
||||||
|
|||||||
1
resources/assets/js/store/state.js
vendored
1
resources/assets/js/store/state.js
vendored
@ -88,6 +88,7 @@ export default {
|
|||||||
|
|
||||||
// 文件
|
// 文件
|
||||||
fileLists: [],
|
fileLists: [],
|
||||||
|
fileLinks: [],
|
||||||
|
|
||||||
// 项目任务
|
// 项目任务
|
||||||
projectId: 0,
|
projectId: 0,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user