修复插件配置问题

This commit is contained in:
Jerry Yan 2022-08-17 12:56:26 +08:00
parent 6632d8cea1
commit 916507d7f2
Signed by: q792602257
GPG Key ID: D070F653AF6C0004
5 changed files with 205 additions and 26 deletions

View File

@ -60,11 +60,18 @@ class ProgramAppendConstructController extends BaseController
}
public function from_list(Request $request) {
$query = ProgramAppends::query()->groupBy("from")->select("from")->selectRaw("count(1) as total_count")->orderByDesc("total_count");
if ($request->has("value")) {
$keyword = $request->get("value");
$query->where("from", "like", "%{$keyword}%");
}
return $query->get()->toArray();
$query = ProgramAppends::query()->groupBy("from")
->select("from")
->selectRaw("count(1) as total_count")
->having("total_count", ">", 1)
->orderByDesc("total_count");
return $query->get()->map(function ($item) {
return [
"text" => $item["from"],
"value" => $item["from"],
"alias" => implode("", \pinyin($item["from"], PINYIN_NO_TONE)),
"abbr" => \pinyin_abbr($item["from"]),
];
})->toArray();
}
}

View File

@ -6,14 +6,15 @@
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"ext-json": "*",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5",
"league/flysystem-aws-s3-v3": "~1.0",
"web-auth/webauthn-lib": "^3.3",
"ext-json": "*"
"overtrue/laravel-pinyin": "~4.0",
"web-auth/webauthn-lib": "^3.3"
},
"require-dev": {
"facade/ignition": "^2.5",

149
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "8591e794c9f0a98f4ee8696e4cb97b2d",
"content-hash": "6f048c3c6fc09674ba2be347f3a1682d",
"packages": [
{
"name": "asm89/stack-cors",
@ -2918,6 +2918,150 @@
},
"time": "2022-01-27T09:35:39+00:00"
},
{
"name": "overtrue/laravel-pinyin",
"version": "4.0.0",
"source": {
"type": "git",
"url": "https://github.com/overtrue/laravel-pinyin.git",
"reference": "c0b15aa49eac08bff80122010b91a0b3fe0f1e21"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/overtrue/laravel-pinyin/zipball/c0b15aa49eac08bff80122010b91a0b3fe0f1e21",
"reference": "c0b15aa49eac08bff80122010b91a0b3fe0f1e21",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"overtrue/pinyin": "~4.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Overtrue\\LaravelPinyin\\ServiceProvider"
],
"aliases": {
"Pinyin": "Overtrue\\LaravelPinyin\\Facades\\Pinyin"
}
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Overtrue\\LaravelPinyin\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "overtrue",
"email": "anzhengchao@gmail.com"
}
],
"description": "Chinese to Pinyin translator.",
"keywords": [
"Chinese",
"Pinyin",
"laravel",
"overtrue"
],
"support": {
"issues": "https://github.com/overtrue/laravel-pinyin/issues",
"source": "https://github.com/overtrue/laravel-pinyin/tree/master"
},
"time": "2018-10-10T09:02:46+00:00"
},
{
"name": "overtrue/pinyin",
"version": "4.0.8",
"source": {
"type": "git",
"url": "https://github.com/overtrue/pinyin.git",
"reference": "04bdb4d33d50e8fb1aa5a824064c5151c4b15dc2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/overtrue/pinyin/zipball/04bdb4d33d50e8fb1aa5a824064c5151c4b15dc2",
"reference": "04bdb4d33d50e8fb1aa5a824064c5151c4b15dc2",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=7.1"
},
"require-dev": {
"brainmaestro/composer-git-hooks": "^2.7",
"friendsofphp/php-cs-fixer": "^2.16",
"phpunit/phpunit": "~8.0"
},
"type": "library",
"extra": {
"hooks": {
"pre-commit": [
"composer test",
"composer fix-style"
],
"pre-push": [
"composer test",
"composer check-style"
]
}
},
"autoload": {
"files": [
"src/const.php"
],
"psr-4": {
"Overtrue\\Pinyin\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "overtrue",
"email": "anzhengchao@gmail.com",
"homepage": "http://github.com/overtrue"
}
],
"description": "Chinese to pinyin translator.",
"homepage": "https://github.com/overtrue/pinyin",
"keywords": [
"Chinese",
"Pinyin",
"cn2pinyin"
],
"support": {
"issues": "https://github.com/overtrue/pinyin/issues",
"source": "https://github.com/overtrue/pinyin/tree/4.0.8"
},
"funding": [
{
"url": "https://www.patreon.com/overtrue",
"type": "patreon"
}
],
"time": "2021-07-19T03:43:32+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.8.1",
@ -10191,7 +10335,8 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^7.3|^8.0"
"php": "^7.3|^8.0",
"ext-json": "*"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"

View File

@ -1,19 +1,28 @@
import PickleComplate from "../vendor/picomplete/picomplete";
(function () {
new PickleComplate({
request: {
url: '/programs/construct/append/from_list?',
type: 'GET',
value: 'from',
text: 'from',
},
config: {
type: 'server',
const pickle_config = {
target: '#from_select',
suggest: ["alias", "abbr"],
clickCallback: (target, node) => {
target.value = node.value;
},
},
}
};
let local_data_string = window.localStorage.getItem("append_from_list");
if (!local_data_string) {
return fetch("/programs/construct/append/from_list", {
"method": "GET",
}).then((response) => response.json()).then((data) => {
window.localStorage.setItem("append_from_list", JSON.stringify(data));
new PickleComplate({
data: data,
config: pickle_config,
})
});
} else {
new PickleComplate({
data: JSON.parse(local_data_string),
config: pickle_config,
})
}
})()

View File

@ -96,7 +96,7 @@ export default class PickleComplate {
this.sug_div = document.createElement('DIV');
this.sug_div.classList.add('picomplete-items');
for (let i = 0; i < this.container.length; i++) {
if (this.container[i].text.toLowerCase().includes(el.value.toLowerCase()) || this.container[i].value.toLowerCase().includes(el.value.toLowerCase())) {
if (this.containsSuggest(this.container[i], el.value)) {
//create list item
let item = document.createElement('DIV');
//set class
@ -117,6 +117,23 @@ export default class PickleComplate {
if(this.sug_div !== null) this.element.parentNode.appendChild(this.sug_div);
}
containsSuggest(item, value) {
if (item.text.toLowerCase().includes(value.toLowerCase()) ||
item.value.toLowerCase().includes(value.toLowerCase())) {
return true;
}
if (this.config.suggest) {
if (typeof this.config.suggest === "string") {
this.config.suggest = [this.config.suggest]
}
for (const suggest_key of this.config.suggest) {
if (item.hasOwnProperty(suggest_key) && item[suggest_key].toLowerCase().includes(value.toLowerCase())) {
return true;
}
}
}
}
/**