Jump to content

Giao diện:Vector/2022

From mediawiki.org
This page is a translated version of the page Skin:Vector/2022 and the translation is 6% complete.
Outdated translations are marked like this.
MediaWiki skins manual - category
Vector 2022
Release status: stable
Compatibility policy Snapshots releases along with MediaWiki. Master is not backwards compatible.
Composer mediawiki/vector-skin
License GNU General Public License 2.0 or later
Download
Example
Parameters
  • $wgVectorDefaultSkinVersionForExistingAccounts
  • $wgVectorDefaultSkinVersionForNewAccounts
  • $wgVectorFontSizeConfigurableOptions
  • $wgVectorLanguageInHeader
  • $wgVectorLanguageInMainPageHeader
  • $wgVectorMaxWidthOptions
  • $wgVectorNightModeOptions
  • $wgVectorPromoteAddTopic
  • $wgVectorResponsive
  • $wgVectorTableOfContentsCollapseAtCount
  • $wgVectorTypeahead
  • $wgVectorUseIconWatch
  • $wgVectorWebABTestEnrollment
  • $wgVectorWrapTablesTemporary
Quarterly downloads 0
Public wikis using 14,010 (Ranked 2nd)
Public wikis using as default skin 5,943
Translate the Vector/2022 skin if it is available at translatewiki.net
Vagrant role vector
Issues Open tasks · Report a bug

Vector 2022 là bước phát triển thứ hai của giao diện MediaWiki Vector và đang được phát triển như một phần của dự án Cải tiến máy tính để bàn. Nó đã được đóng gói trong MediaWiki kể từ $2. It has been bundled in MediaWiki since MediaWiki 1.38 . Nó là giao diện mặc định cho các dự án Wikimedia khác nhau.

Vector 2022 differs from most skins in that it does not have its own code base; rather, its code is part of the Vector skin's, and the two are downloaded together.

Version MediaWiki 1.38 of this skin marked official 3rd party support.

Nếu một trang web đang chạy MediaWiki 1.36 hoặc 1.37 đang sử dụng Vector 2022, trang web đó sẽ gặp phải những thách thức khi nâng cấp lên bản phát hành 1.38. Xem T299104Extension:WikimediaMaintenance để biết thêm chi tiết.

Cài đặt

This skin comes with MediaWiki 1.38 and later, so you do not need to download it. The remaining configuration instructions must still be followed.
  • Tải và đặt (các) tệp trong một thư mục với tên Vector trong thư mục skins/ của bạn.
  • Thêm mã sau vào dưới cùng tệp LocalSettings.php của bạn:
    wfLoadSkin( 'Vector' );
    
  • Configure as required.
  • Yes Xong - Chuyển tới Special:Version trên wiki của bạn để xác nhận skin được cài đặt thành công.

Optional dependencies

Vector 2022 can make use of the following extensions if they are installed, though none are required:

  • UniversalLanguageSelector for the language switch button
  • PageImages to include an image for each page (if available) in the search bar
  • ShortDescription to include a description for each page in the search bar (Wikimedia projects have similar functionality, but not using this extension)

Configuration

Making Vector 2022 the default skin

For MediaWiki 1.38 and higher, add the following to LocalSettings.php to make this the default skin:

$wgDefaultSkin = 'vector-2022';

Features

Dark mode

Phiên bản MediaWiki:
1.43

Vector 2022 features a night mode (aka dark mode), which has three possible states:

  • dayalso known as light mode
  • nightalso known as dark mode
  • osalso known as automatic. This mode will automatically adapt to the state of the operating system or browser

Night mode is gated by a feature flag. To enable it, set $wgVectorNightMode as follows:

$wgVectorNightMode['beta'] = true;
$wgVectorNightMode['logged_out'] = true;
$wgVectorNightMode['logged_in'] = true;

When enabled, the default theme mode is day. To change the default theme for all users to automatic mode or night mode, you set the default for the user option with either:

$wgDefaultUserOptions['vector-theme'] = 'os';
// or 
$wgDefaultUserOptions['vector-theme'] = 'night';

Please note that your content has to be night mode compatible. You might want to read the recommendations for Wikimedia wikis .

Configurability

Note that Vector 2022 has several unstable feature flags, which may disappear at any time. Most of these feature flags relate to incomplete features. It is not recommended to change any feature flag from its default value unless listed here.

  • $wgVectorMaxWidthOptions - Can be used to configure whether the max-width applies. Relatively stable at this point.
  • $wgVectorLanguageInMainPageHeader - Controls whether the language button is shown on the main page in the header.
  • $wgVectorTypeahead - Associative array with configuration keys for API URLs and options such as showDescription and showThumbnail (both booleans).

Pinning

Vector 2022 allows control over whether various menus appear pinned in the sidebar or collapsed into the header. These options can be configured both by users in their preferences and by administrators as default settings.

The following pinning options are available:

  • vector-main-menu-pinnedControls the main navigation menu position
    • 1 (default) – Menu is pinned in the left sidebar
    • 0 – Menu is collapsed into header hamburger icon
  • vector-page-tools-pinnedControls the page tools menu position
    • 1 (default) – Tools are pinned in the right sidebar
    • 0 – Tools are collapsed into header icon
  • vector-toc-pinnedControls the table of contents position
    • 1 (default) – Table of contents is pinned in the left sidebar
    • 0 – Table of contents is collapsed into a floating button
  • vector-appearance-pinnedControls the appearance menu position
    • 1 (default) – Appearance options are pinned in the sidebar
    • 0 – Appearance options are collapsed into header icon

To change any of these defaults for logged in users, add the corresponding lines to LocalSettings.php:

Note this will not work for anonymous users due until T366999 is worked on.

// Example: Collapse all menus
$wgDefaultUserOptions['vector-main-menu-pinned'] = 0;
$wgDefaultUserOptions['vector-page-tools-pinned'] = 0;
$wgDefaultUserOptions['vector-toc-pinned'] = 0;
$wgDefaultUserOptions['vector-appearance-pinned'] = 0;

Workarounds

Cảnh báo Cảnh báo: This code should never be run on Wikimedia production sites as it causes the page to be re-rendered which can impact SEO as well as user experience.

To pin the sidebar for anonymous users by default, this code can be added at the beginning of MediaWiki:Common.js (see live example):

if (!mw.config.get('wgUserName')) {
	const observer = new MutationObserver((mutationsList, observer) => {
		for (const mutation of mutationsList) {
			if (mutation.target.classList.contains('vector-animations-ready')) {
				document.querySelector( '[data-event-name="pinnable-header.vector-main-menu.pin"]' ).click()
				observer.disconnect();
				break;
			}
		}
	});
	
	observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
}

If you also want to pin the tools for anonymous users by default, you can add the following line of code (after line 5):

document.querySelector( '[data-event-name="pinnable-header.vector-page-tools.pin"]' ).click()

See also