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